Re: [tip: x86/urgent] x86/e820: Discard high memory that can't be addressed by 32-bit systems

From: Dave Hansen
Date: Mon Apr 14 2025 - 10:55:56 EST


On 4/13/25 02:23, tip-bot2 for Mike Rapoport (Microsoft) wrote:
> + /*
> + * 32-bit systems are limited to 4BG of memory even with HIGHMEM and
> + * to even less without it.
> + * Discard memory after max_pfn - the actual limit detected at runtime.
> + */
> + if (IS_ENABLED(CONFIG_X86_32))
> + memblock_remove(PFN_PHYS(max_pfn), -1);

Mike, thanks for the quick fix! I did verify that this gets my silly
test VM booting again.

The patch obviously _works_. But in the case I was hitting max_pfn was
set MAX_NONPAE_PFN. The unfortunate part about this hunk is that it's
far away from the related warning:

> if (max_pfn > MAX_NONPAE_PFN) {
> max_pfn = MAX_NONPAE_PFN;
> printk(KERN_WARNING MSG_HIGHMEM_TRIMMED);
> }

and it's logically doing the same thing: truncating memory at
MAX_NONPAE_PFN.

How about we reuse 'MAX_NONPAE_PFN' like this:

if (IS_ENABLED(CONFIG_X86_32))
memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);

Would that make the connection more obvious?