lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191105093708.GE4743@lakrids.cambridge.arm.com>
Date:   Tue, 5 Nov 2019 09:37:08 +0000
From:   Mark Rutland <mark.rutland@....com>
To:     Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc:     Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>,
        linux-arm-kernel@...ts.infradead.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Anshuman Khandual <anshuman.khandual@....com>,
        Ard Biesheuvel <ard.biesheuvel@...aro.org>,
        David Hildenbrand <david@...hat.com>,
        Hsin-Yi Wang <hsinyi@...omium.org>,
        Robin Murphy <robin.murphy@....com>,
        Steve Capper <steve.capper@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Yu Zhao <yuzhao@...gle.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arm64: mm: simplify the page end calculation in
 __create_pgd_mapping()

On Sun, Nov 03, 2019 at 09:35:58PM +0900, Masahiro Yamada wrote:
> Calculate the page-aligned end address more simply.
> 
> The local variable, "length" is unneeded.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
> ---
> 
>  arch/arm64/mm/mmu.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 60c929f3683b..a9f541912289 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -338,7 +338,7 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
>  				 phys_addr_t (*pgtable_alloc)(int),
>  				 int flags)
>  {
> -	unsigned long addr, length, end, next;
> +	unsigned long addr, end, next;
>  	pgd_t *pgdp = pgd_offset_raw(pgdir, virt);
>  
>  	/*
> @@ -350,9 +350,8 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
>  
>  	phys &= PAGE_MASK;
>  	addr = virt & PAGE_MASK;
> -	length = PAGE_ALIGN(size + (virt & ~PAGE_MASK));
> +	end = PAGE_ALIGN(virt + size);
>  
> -	end = addr + length;

While looking at this, I got confused by the old code and thought that
there was an existing bug, but I now see that's not the case, and the
old and new code are equivalent.

The new code looks cleaner, and leaves less room for confusion, so I
think that's preferable:

Reviewed-by: Mark Rutland <mark.rutland@....com>

Mark.

>  	do {
>  		next = pgd_addr_end(addr, end);
>  		alloc_init_pud(pgdp, addr, next, phys, prot, pgtable_alloc,
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ