Re: [PATCH 1/1] x86: Exclude E820_RESERVED regions and memory holesabove 4 GB from direct mapping.

From: H. Peter Anvin
Date: Fri Dec 16 2011 - 12:55:25 EST


On 12/16/2011 09:42 AM, Yinghai Lu wrote:

no, you change the meaning max_low_pfn_mapped and max_pfn_mapped for x86_64 at least.

before your patch:
max_low_pfn_mapped is the mapped pfn beblow 4g.
max_pfn_mapped: is mapped pfn.

after your patch, those two variables does not mean the memory [0, max_low_pfn_mapped) and [4g<<12, max_pfn_mapped)
are really mapped.


And that's exactly the problem. It is BROKEN -- as in fundamentally dangerous -- for these mappings to exist. It is because the model is too inflexible.

so in arch/x86/platform/efi/efi.c

if (end_pfn<= max_low_pfn_mapped
|| (end_pfn> (1UL<< (32 - PAGE_SHIFT))
&& end_pfn<= max_pfn_mapped))
va = __va(md->phys_addr);
else
va = efi_ioremap(md->phys_addr, size, md->type);


and others will have problem.

to solve your problem:
1. unmap the HT range ?
2. or introduce mapped_pfn_range array?

1 is fundamentally a braindead hack that solves one case without solving the overall problem.

For 2 - why can't we simply make the invariant that E820_RAM is mapped and nothing else, with the sole exceptions being the 1 MiB (fixed MTRR)?

For things like efi.c we should make sure to have interfaces instead of open-code this kind of stuff.

-hpa

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/