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] [day] [month] [year] [list]
Date:   Tue, 14 Nov 2023 16:36:53 +0800
From:   Baoquan He <bhe@...hat.com>
To:     Yuntao Wang <ytcoode@...il.com>
Cc:     alexander.shishkin@...ux.intel.com, bp@...en8.de,
        dave.hansen@...ux.intel.com, hpa@...or.com, jgross@...e.com,
        linux-kernel@...r.kernel.org, mingo@...hat.com,
        peterz@...radead.org, ssengar@...ux.microsoft.com,
        tglx@...utronix.de, x86@...nel.org,
        Andy Lutomirski <luto@...nel.org>,
        Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v2] x86/setup: Use a more concise memblock API

On 11/14/23 at 03:37pm, Yuntao Wang wrote:
> When executing relocate_initrd()/numa_emulation()/numa_alloc_distance(),
> the memblock.current_limit field has already been set to
> `max_pfn_mapped << PAGE_SHIFT`, therefore we can replace
> memblock_phys_alloc_range() with memblock_phys_alloc(), which has the same
> functionality but is more concise.
> 
> Signed-off-by: Yuntao Wang <ytcoode@...il.com>
> ---
> v1 -> v2:
> 
> Also replace memblock_phys_alloc_range() in numa_emulation() and
> numa_alloc_distance() with memblock_phys_alloc()

LGTM,

Reviewed-by: Baoquan He <bhe@...hat.com>

> 
>  arch/x86/kernel/setup.c      | 3 +--
>  arch/x86/mm/numa.c           | 3 +--
>  arch/x86/mm/numa_emulation.c | 3 +--
>  3 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index ec2c21a1844e..422497c17eec 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -259,8 +259,7 @@ static void __init relocate_initrd(void)
>  	u64 area_size     = PAGE_ALIGN(ramdisk_size);
> 
>  	/* We need to move the initrd down into directly mapped mem */
> -	u64 relocated_ramdisk = memblock_phys_alloc_range(area_size, PAGE_SIZE, 0,
> -						      PFN_PHYS(max_pfn_mapped));
> +	u64 relocated_ramdisk = memblock_phys_alloc(area_size, PAGE_SIZE);
>  	if (!relocated_ramdisk)
>  		panic("Cannot find place for new RAMDISK of size %lld\n",
>  		      ramdisk_size);
> diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
> index b29ceb19e46e..29cd8fc8ede1 100644
> --- a/arch/x86/mm/numa.c
> +++ b/arch/x86/mm/numa.c
> @@ -378,8 +378,7 @@ static int __init numa_alloc_distance(void)
>  	cnt++;
>  	size = cnt * cnt * sizeof(numa_distance[0]);
> 
> -	phys = memblock_phys_alloc_range(size, PAGE_SIZE, 0,
> -					 PFN_PHYS(max_pfn_mapped));
> +	phys = memblock_phys_alloc(size, PAGE_SIZE);
>  	if (!phys) {
>  		pr_warn("Warning: can't allocate distance table!\n");
>  		/* don't retry until explicitly reset */
> diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
> index 9a9305367fdd..8acb8d0f7d0f 100644
> --- a/arch/x86/mm/numa_emulation.c
> +++ b/arch/x86/mm/numa_emulation.c
> @@ -447,8 +447,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
>  	if (numa_dist_cnt) {
>  		u64 phys;
> 
> -		phys = memblock_phys_alloc_range(phys_size, PAGE_SIZE, 0,
> -						 PFN_PHYS(max_pfn_mapped));
> +		phys = memblock_phys_alloc(phys_size, PAGE_SIZE);
>  		if (!phys) {
>  			pr_warn("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n");
>  			goto no_emu;
> --
> 2.42.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ