Allow empty e820 map if EFI map will be provided later.
RFC PATCH 1/1 Allow empty e820 map if EFI map will be provided later.
If you are booting an x86-based system from an EFI BIOS that does not provide any e820-style memory maps, setup_arch() calls functions that expect to find the e820 maps long before it calls functions to find the EFI maps. The default behavior in arch/x86/kernel/e820.c is that if no e820 map exists, default_machine_specific_memory_setup() adds two default regions just in case. Later, when you get around to using the EFI maps, these default regions interfere with the real memory map.
This patch provides a config option that allows the lack of e820 maps to be ignored, under the assumption that you know what you're doing and will provide a valid EFI memory map to use.
The reason this problem has not arisen before now is that under most circumstances either the EFI BIOS' Compatibility Support Module provides an e820-style memory map in the first place, or the EFI-aware bootloader (grub2, elilo) translates the EFI map to the e280 format before booting the kernel.
I'm trying to reduce the boot time and BIOS footprint, so I'm booting without either of those pre-boot map translations. This patch allows that to happen.
--- arch/x86/Kconfig | 10 ++++++++++ arch/x86/include/asm/e820.h | 5 +++++ arch/x86/kernel/e820.c | 2 +- 3 files changed, 16 insertions(+), 1 deletions(-)
arch/x86/Kconfig +10 -0
@@ -1468,6 +1468,16 @@ config EFI resultant kernel should continue to boot on existing non-EFI platforms. +config ALLOW_EMPTY_E820 + bool "Allow empty e820 memory maps" + default y + depends on EFI && (X86_64 || X86_32) + ---help--- + Enable this if you are using EFI memory maps instead of e820. + The EFI memory maps are scanned much later than the e820 maps, and + without this option the e280 setup code will automatically add + some default mappings that may conflict with the real EFI maps. + config SECCOMP def_bool y prompt "Enable seccomp to safely compute untrusted bytecode"
arch/x86/include/asm/e820.h +5 -0
@@ -134,6 +134,11 @@ extern void e820_reserve_resources(void);extern void e820_reserve_resources_late (void );extern void setup_memory_map (void );extern char *default_machine_specific_memory_setup (void ); +#ifdef CONFIG_ALLOW_EMPTY_E820 +static inline int no_e820_map_return (void ) {return 0 ; } +#else +static inline int no_e820_map_return (void ) {return -1 ; } +#endif /* * Returns true iff the specified range [s,e) is completely contained inside
arch/x86/kernel/e820.c +1 -1
@@ -416,7 +416,7 @@ static int __init append_e820_map(struct e820entry *biosmap, int nr_map) {/* Only one memory region (or negative)? Ignore it */ if (nr_map <2 ) -return -1 ; +return no_e820_map_return ();return __append_e820_map (biosmap, nr_map); }
Signature · 6 lines
1.7.0.1 -- Art for Art's Sake Engineering for Money
H. Peter Anvin
reviewerNo! Bloody **** hell no!
This is yet another attempt at doing more of the wrong thing, which not only will make it harder to push things that should be earlier in the kernel there.
This was settled in 2007 -- it is the boot loaders duty to provide a memory map. The fact that we allowed a hack in to let the kernel itself add additional ranges from EFI has proven to be an utter mistake, and this is yet another example of it.
Vetoed in the extreme.
-hpa
Quoted 23 lines · Bill Richardson
If you are booting an x86-based system from an EFI BIOS that does not provide any e820-style memory maps,
setup_arch()calls functions that expect to find the e820 maps long before it calls functions to find the EFI maps. The default behavior inarch/x86/kernel/e820.cis that if no e820 map exists,default_machine_specific_memory_setup()adds two default regions just in case. Later, when you get around to using the EFI maps, these default regions interfere with the real memory map.This patch provides a config option that allows the lack of e820 maps to be ignored, under the assumption that you know what you're doing and will provide a valid EFI memory map to use.
The reason this problem has not arisen before now is that under most circumstances either the EFI BIOS' Compatibility Support Module provides an e820-style memory map in the first place, or the EFI-aware bootloader (grub2, elilo) translates the EFI map to the e280 format before booting the kernel.
I'm trying to reduce the boot time and BIOS footprint, so I'm booting without either of those pre-boot map translations. This patch allows that to happen.
Signed-off-by Bill Richardson<[email protected]>
Quoted 2 lines · H. Peter Anvin
No! Bloody **** hell no!
Heh. Well, that answers that.
Quoted 3 lines
This was settled in 2007 -- it is the boot loaders duty to provide a memory map. The fact that we allowed a hack in to let the kernel itself add additional ranges from EFI has proven to be an utter mistake, and this is yet another example of it.
Ah. With that hint, I've now found some of the original discussion. Sorry I missed it before. Having dealt with EFI for some weeks now, I can't say I find your reaction overstated.
Thanks for the quick response.
Bill