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: <20190402083456.GA2153@rapoport-lnx>
Date:   Tue, 2 Apr 2019 11:34:57 +0300
From:   Mike Rapoport <rppt@...ux.ibm.com>
To:     Anup Patel <Anup.Patel@....com>
Cc:     Palmer Dabbelt <palmer@...ive.com>,
        Albert Ou <aou@...s.berkeley.edu>,
        Atish Patra <Atish.Patra@....com>,
        Christoph Hellwig <hch@...radead.org>,
        Paul Walmsley <paul.walmsley@...ive.com>,
        "linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] RISC-V: Fix Maximum Physical Memory 2GiB option for
 64bit systems

On Tue, Apr 02, 2019 at 06:02:38AM +0000, Anup Patel wrote:
> The Maximum Physical Memory 2GiB option for 64bit systems is currently
> broken because kernel hangs at boot-time when this option is enabled
> and the underlying system has more than 2GiB memory.
> 
> This issue can be easily reproduced on SiFive Unleashed board where
> we have 8GiB of memory.
> 
> This patch fixes above issue by reserving unusable memory region in
> setup_bootmem().
> 
> Signed-off-by: Anup Patel <anup.patel@....com>
> ---
>  arch/riscv/mm/init.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 5fd8c922e1c2..6b063f20a9d0 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -121,6 +121,14 @@ void __init setup_bootmem(void)
>  			 */
>  			memblock_reserve(reg->base, vmlinux_end - reg->base);
>  			mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET);
> +
> +			/*
> +			 * Reserve from the end of usable area to the end of
> +			 * region
> +			 */
> +			if ((reg->base + mem_size) < end)
> +				memblock_reserve(reg->base + mem_size,
> +						 end - reg->base - mem_size);

The memory above MAXPHYSMEM should not be reserved. It should be either
removed from memblock with memblock_remove or not added at the first place.

Frankly, I fail to understand the logic behind setting PAGE_OFFSET to
MAXPHYSMEM and then using PAGE_OFFSET as the limit for accessible physical
memory. Still, as it is there, you can set MAX_MEMBLOCK_ADDR=PAGE_OFFSET in
arch/riscv/include/page.h and then early_init_dt_add_memory_arch() will
simply ignore the memory above PAGE_OFFSET.

More sustainable fix for the long term, IMHO, would be to break
PAGE_OFFSET and MAXPHYSMEM interdependency.


>  		}
>  	}
>  	BUG_ON(mem_size == 0);
> -- 
> 2.17.1
> 

-- 
Sincerely yours,
Mike.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ