x86: fixes some bugs about EFI memory map handling
PATCH 6/6 x86: fixes some bugs about EFI memory map handling
This patch fixes some bugs of EFI memory handing code.
- On x86_64, it is possible that EFI memory map can not be mapped via identity map, so efi_map_memmap is removed, just use early_ioremap.
- On i386, the EFI memory map mapping take effect cross paging_init, so it is not necessary to use efi_map_memmap.
- EFI memory map is unmapped in efi_enter_virtual_mode to avoid early_ioremap leak.
--- arch/x86/kernel/efi.c | 2 ++ arch/x86/kernel/efi_32.c | 15 --------------- arch/x86/kernel/efi_64.c | 9 --------- arch/x86/kernel/setup_32.c | 2 -- arch/x86/kernel/setup_64.c | 4 +--- 5 files changed, 3 insertions(+), 29 deletions(-)
arch/x86/kernel/efi_64.c +0 -9
@@ -103,15 +103,6 @@ void __init efi_call_phys_epilog(void)local_irq_restore (efi_flags); } -/* -* We need to map the EFI memory map again after init_memory_mapping(). -*/ -void __init efi_map_memmap (void ) -{ - memmap.map =__va (memmap.phys_map); - memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size); -} -void __init efi_reserve_bootmem (void ) { reserve_bootmem_generic((unsigned long)memmap.phys_map,
arch/x86/kernel/setup_64.c +1 -3
@@ -389,10 +389,8 @@ void __init setup_arch(char **cmdline_p)acpi_reserve_bootmem ();#endif -if (efi_enabled) { -efi_map_memmap (); +if (efi_enabled)efi_reserve_bootmem (); - }/* * Find and reserve possible boot-time SMP configuration:
arch/x86/kernel/efi.c +2 -0
@@ -474,6 +474,8 @@ void __init efi_enter_virtual_mode(void) efi.reset_system = virt_efi_reset_system; efi.set_virtual_address_map = virt_efi_set_virtual_address_map;runtime_code_page_mkexec (); +early_iounmap (memmap.map, memmap.nr_map * memmap.desc_size); + memmap.map =NULL ; }/*
arch/x86/kernel/efi_32.c +0 -15
@@ -109,18 +109,3 @@ void efi_call_phys_epilog(void)local_irq_restore (efi_rt_eflags); } - -/* -* We need to map the EFI memory map again after paging_init(). -*/ -void __init efi_map_memmap (void ) -{ - memmap.map =NULL ; - - memmap.map =early_ioremap ((unsigned long ) memmap.phys_map, - (memmap.nr_map * memmap.desc_size)); -if (memmap.map ==NULL ) -printk (KERN_ERR "Could not remap the EFI memmap!\n" ); - - memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size); -}
arch/x86/kernel/setup_32.c +0 -2
@@ -825,8 +825,6 @@ void __init setup_arch(char **cmdline_p)#ifdef CONFIG_X86_GENERICARCH generic_apic_probe ();#endif -if (efi_enabled) -efi_map_memmap ();#ifdef CONFIG_ACPI /*
Ingo Molnar
AppliedQuoted 10 lines · Huang, Ying
This patch fixes some bugs of EFI memory handing code.
- On
x86_64, it is possible that EFI memory map can not be mapped via identity map, soefi_map_memmapis removed, just useearly_ioremap.- On i386, the EFI memory map mapping take effect cross
paging_init, so it is not necessary to useefi_map_memmap.- EFI memory map is unmapped in
efi_enter_virtual_modeto avoidearly_ioremapleak.
thanks, applied.
btw., it would be nice to consolidate this some more. Why is there a separate efi_ioremap(), which is mapped to ioremap() on 32-bit, and which is mapped to a fixmap based special mapper on 64-bit?
To me it appears this wants to be ioremap() on both 64-bit and 32-bit, and we could remove efi_ioremap() altogether. Hm?
Ingo
Quoted 13 lines · Ingo Molnar
Quoted 10 lines · Huang, Ying
This patch fixes some bugs of EFI memory handing code.
- On
x86_64, it is possible that EFI memory map can not be mapped via identity map, soefi_map_memmapis removed, just useearly_ioremap.- On i386, the EFI memory map mapping take effect cross
paging_init, so it is not necessary to useefi_map_memmap.- EFI memory map is unmapped in
efi_enter_virtual_modeto avoidearly_ioremapleak.
Quoted 8 lines
thanks, applied.
btw., it would be nice to consolidate this some more. Why is there a separate
efi_ioremap(), which is mapped toioremap()on 32-bit, and which is mapped to a fixmap based special mapper on 64-bit?To me it appears this wants to be
ioremap()on both 64-bit and 32-bit, and we could removeefi_ioremap()altogether. Hm?
To support kexec, I want to map the EFI memory area on same virtual address on different boot of different version of kernel. Then, the EFI runtime service will always get the same execution environment. This is because a weakness of EFI runtime service, it can not reset its execution environment, except reboot.
Best Regards,
Huang Ying
Quoted 20 lines · Huang, Ying
Quoted 19 lines · Ingo Molnar
Quoted 10 lines · Huang, Ying
This patch fixes some bugs of EFI memory handing code.
- On
x86_64, it is possible that EFI memory map can not be mapped via identity map, soefi_map_memmapis removed, just useearly_ioremap.- On i386, the EFI memory map mapping take effect cross
paging_init, so it is not necessary to useefi_map_memmap.- EFI memory map is unmapped in
efi_enter_virtual_modeto avoidearly_ioremapleak.thanks, applied.
btw., it would be nice to consolidate this some more. Why is there a separate
efi_ioremap(), which is mapped toioremap()on 32-bit, and which is mapped to a fixmap based special mapper on 64-bit?
Quoted 8 lines
Quoted 2 lines
To me it appears this wants to be
ioremap()on both 64-bit and 32-bit, and we could removeefi_ioremap()altogether. Hm?To support kexec, I want to map the EFI memory area on same virtual address on different boot of different version of kernel. Then, the EFI runtime service will always get the same execution environment. This is because a weakness of EFI runtime service, it can not reset its execution environment, except reboot.
so this basically means that on 32-bit kexec wont work right - i.e. only 64-bit has been enhanced this way? What am i missing?
Ingo
Quoted 26 lines · Ingo Molnar
Quoted 23 lines · Huang, Ying
Quoted 21 lines · Ingo Molnar
Quoted 10 lines · Huang, Ying
This patch fixes some bugs of EFI memory handing code.
- On
x86_64, it is possible that EFI memory map can not be mapped via identity map, soefi_map_memmapis removed, just useearly_ioremap.- On i386, the EFI memory map mapping take effect cross
paging_init, so it is not necessary to useefi_map_memmap.- EFI memory map is unmapped in
efi_enter_virtual_modeto avoidearly_ioremapleak.thanks, applied.
btw., it would be nice to consolidate this some more. Why is there a separate
efi_ioremap(), which is mapped toioremap()on 32-bit, and which is mapped to a fixmap based special mapper on 64-bit?To me it appears this wants to be
ioremap()on both 64-bit and 32-bit, and we could removeefi_ioremap()altogether. Hm?
Quoted 8 lines
Quoted 5 lines
To support kexec, I want to map the EFI memory area on same virtual address on different boot of different version of kernel. Then, the EFI runtime service will always get the same execution environment. This is because a weakness of EFI runtime service, it can not reset its execution environment, except reboot.
so this basically means that on 32-bit kexec wont work right - i.e. only 64-bit has been enhanced this way? What am i missing?
Strictly, I should say on 32-bit, EFI runtime service won't work in kexeced kernel. That is, on EFI 32 platform, it is possible that:
- Boot kernel A with EFI runtime service
- kexec kernel B without EFI runtime service (such as with noefi in kernel command line)
I suspect this method can be used on 32-bit platform. Because the fixmap area on 32-bit is more limited than 64-bit. And because identity map area on 32-bit is too limited, it is possible that all EFI runtime code, data, IO areas need to be mapped via fixmap.
Best Regards,
Huang Ying