Run EFI in physical mode
Subsystems (4)
[email protected]
Acked-bySent from my android device.
-----Original Message-----
From: Takao Indoh <[email protected]>
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Sent: Fri, 13 Aug 2010 03:18 PM
Subject: [PATCH][EFI] Run EFI in physical mode
Hi all,
The attached patch enables EFI to run in physical mode.
Basically EFI is in physical mode at first and it's switched to virtual mode after calling SetVirtualAddressMap. By applying this patch, you can run EFI always in physical mode. And you can also specify "virtefi" as kernel boot parameter to run EFI in virtual mode as before. Note that this patch supports only x86_64.
This is needed to run kexec/kdump in EFI-booted system. The following is an original discussion. In this thread, I explained that kdump does not work because EFI system table is modified by SetVirtualAddressMap. And the idea to run EFI in physical mode was proposed. This patch implements it.
http://marc.info/?l=linux-kernel&m=128018221820234&w=2
Quoted 9 lines
When the 1st kernel boots, EFI system
table(efi_system_table_t)is modified by SetVirtualAddressMap, which is one of EFI runtime service. This runtime changes physical address in EFI system table to virtual address.When the 2nd kernel boots, it also receives the same EFI system table, and the address included in it is already virtual address(1st kernel rewrote it). But 2nd kernel does not know that, 2nd kernel thinks it is a physical address. This causes problems.
Basic idea of this patch is to create EFI own pagetable. This pagetable maps physical address of EFI runtime to the virtual address which is the same value so that we can call it directly. For example, physical address 0x800000 is mapped to virtual address 0x800000. Before calling EFI runtime, cr3 register is switched to this pagetable, and restored when we come back from EFI.
Any comments would be appreciated.
Looks good
--- arch/x86/include/asm/efi.h | 3 arch/x86/kernel/efi.c | 142 ++++++++++++++++++++++++++++++++++- arch/x86/kernel/efi_32.c | 4 arch/x86/kernel/efi_64.c | 92 ++++++++++++++++++++++ include/linux/efi.h | 1 include/linux/init.h | 1 init/main.c | 16 +++ 7 files changed, 254 insertions(+), 5 deletions(-)
arch/x86/include/asm/efi.h +3 -0
@@ -93,6 +93,9 @@ extern int add_efi_memmap;extern void efi_reserve_early (void );extern void efi_call_phys_prelog (void );extern void efi_call_phys_epilog (void ); +extern void efi_call_phys_prelog_in_physmode (void ); +extern void efi_call_phys_epilog_in_physmode (void ); +extern void efi_pagetable_init (void );#ifndef CONFIG_EFI /*
arch/x86/kernel/efi.c +140 -2
178 lines not on this page · raw message
arch/x86/kernel/efi_32.c +4 -0
@@ -110,3 +110,7 @@ void efi_call_phys_epilog(void)local_irq_restore (efi_rt_eflags); } + +void efi_call_phys_prelog_in_physmode (void ) {/* Not supported */ } +void efi_call_phys_epilog_in_physmode (void ) {/* Not supported */ } +
arch/x86/kernel/efi_64.c +91 -1
107 lines not on this page · raw message
include/linux/efi.h +1 -0
@@ -290,6 +290,7 @@ extern void efi_map_pal_code (void);extern void efi_memmap_walk (efi_freemem_callback_t callback,void *arg);extern void efi_gettimeofday (struct timespec *ts);extern void efi_enter_virtual_mode (void );/* switch EFI to virtual mode, if possible */ +extern void efi_setup_physical_mode (void );extern u64 efi_get_iobase (void );extern u32 efi_mem_type (unsigned long phys_addr);extern u64 efi_mem_attributes (unsigned long phys_addr);
include/linux/init.h +1 -0
@@ -142,6 +142,7 @@ extern int do_one_initcall(initcall_t fnextern char __initdata boot_command_line[];extern char *saved_command_line;extern unsigned int reset_devices; +extern unsigned int usevirtefi;/* used by init/main.c */ void setup_arch (char **);
init/main.c +14 -2
@@ -200,6 +200,14 @@ static int __init set_reset_devices(char__setup ("reset_devices" , set_reset_devices); +unsigned int usevirtefi; +static int __init set_virt_efi (char *str) +{ + usevirtefi =1 ; +return 1 ; +} +__setup ("virtefi" , set_virt_efi); +static char * argv_init[MAX_INIT_ARGS +2 ] = {"init" ,NULL , };char * envp_init[MAX_INIT_ENVS +2 ] = {"HOME=/" ,"TERM=linux" ,NULL , };static const char *panic_later, *panic_param;
@@ -676,8 +684,12 @@ asmlinkage void __init start_kernel(voidpidmap_init ();anon_vma_init ();#ifdef CONFIG_X86 -if (efi_enabled) -efi_enter_virtual_mode (); +if (efi_enabled) { +if (usevirtefi) +efi_enter_virtual_mode (); +else +efi_setup_physical_mode (); + }#endif thread_info_cache_init ();cred_init ();
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec