Re: [PATCH v3] RISC-V: Fix Maximum Physical Memory 2GiB option for 64bit systems

From: Palmer Dabbelt
Date: Fri Apr 05 2019 - 17:17:31 EST


On Thu, 04 Apr 2019 23:01:11 PDT (-0700), anup@xxxxxxxxxxxxxx wrote:
On Fri, Apr 5, 2019 at 11:24 AM Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:

On Fri, Apr 05, 2019 at 05:49:34AM +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 removing unusable memory region in
> setup_bootmem().
>
> Signed-off-by: Anup Patel <anup.patel@xxxxxxx>
> Reviewed-by: Christoph Hellwig <hch@xxxxxx>

Btw, what is the rationale behind even offering the 2GiB option and
the medlow model on 64-bit? Do we reall have use cases where the
slightly more effient generated code matters so much to keep up
the support burden of this mostly unused and unusual configuration?

I'd be OK dropping medlow on rv64. The performance impact of medany is pretty minor these days, and even back when we added the option it was mostly paranoia about the linker being correct. medany has been solid on rv64 for a while, but we did recently find a pretty major toolchain bug in medany/rv32 so if we were to drop that we'd need to enforce a pretty recent binutils version (the latest release is OK, I'd have to check on the previous one). I'd prefer to avoid that, and since medany doesn't really buy us anything on rv32 it seems fine to leave it that way.

Given how many issues we've found here recently I doubt anyone is flipping this option away from the default for their base ISA.

Yes, if we want to use medlow with 64bit then max physical memory
can be 2GiB. Otherwise, I don't any practical use of restricting max
physical memory to 2GiB on 64bit systems.

BTW, as-per latest revision of RISC-V priviledge spece the MMU SV32
mode will be able to access 34bit physical memory (i.e. 16GiB) so
max physical memory 2GiB will also be required for 32bit system for
medlow.

It's a bit more complicated that than. The 34-bit physical addresses have been in the spec for a long time, but we've never bothered supporting them in Linux. Right now we assume we can map all physical memory into a contiguous region, which is why we tie PAGE_OFFSET to the maximum physical memory. It's impossible to map all physical memory with 34-bit physical addresses on a 32-bit system, so we'll need to break that assumption to move forward with 34-bit physical addresses anyway.

Additionally: medlow can map everything on 32-bit systems anyway, so moving to medany doesn't buy you anything.