diff options
author | Huang, Ying <ying.huang@intel.com> | 2008-01-30 13:33:55 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 13:33:55 +0100 |
commit | a2172e2586f6662af996e47f417bb718c37cf8d2 (patch) | |
tree | f2430abad9fd9417653a3a2faa472d9df0c308bd /arch/x86/kernel/efi.c | |
parent | cd58289667293593b04fd315ec7f2f37589134cb (diff) | |
download | kernel-crypto-a2172e2586f6662af996e47f417bb718c37cf8d2.tar.gz kernel-crypto-a2172e2586f6662af996e47f417bb718c37cf8d2.tar.xz kernel-crypto-a2172e2586f6662af996e47f417bb718c37cf8d2.zip |
x86: fix some bugs about EFI runtime code mapping
This patch fixes some bugs of making EFI runtime code executable.
- Use change_page_attr in i386 too. Because the runtime code may be
mapped not through ioremap.
- If there is no _PAGE_NX in __supported_pte_mask, the change_page_attr
is not called.
- Make efi_ioremap map pages as PAGE_KERNEL_EXEC_NOCACHE, because EFI runtime
code may be mapped through efi_ioremap.
Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/efi.c')
-rw-r--r-- | arch/x86/kernel/efi.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/arch/x86/kernel/efi.c b/arch/x86/kernel/efi.c index 5d492f99d96..834ecfb41e9 100644 --- a/arch/x86/kernel/efi.c +++ b/arch/x86/kernel/efi.c @@ -40,6 +40,8 @@ #include <asm/setup.h> #include <asm/efi.h> #include <asm/time.h> +#include <asm/cacheflush.h> +#include <asm/tlbflush.h> #define EFI_DEBUG 1 #define PFX "EFI: " @@ -379,6 +381,32 @@ void __init efi_init(void) #endif } +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) +static void __init runtime_code_page_mkexec(void) +{ + efi_memory_desc_t *md; + unsigned long end; + void *p; + + if (!(__supported_pte_mask & _PAGE_NX)) + return; + + /* Make EFI runtime service code area executable */ + for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { + md = p; + end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT); + if (md->type == EFI_RUNTIME_SERVICES_CODE && + (end >> PAGE_SHIFT) <= end_pfn_map) + change_page_attr_addr(md->virt_addr, + md->num_pages, + PAGE_KERNEL_EXEC_NOCACHE); + } + __flush_tlb_all(); +} +#else +static inline void __init runtime_code_page_mkexec(void) { } +#endif + /* * This function will switch the EFI runtime services to virtual mode. * Essentially, look through the EFI memmap and map every region that @@ -399,9 +427,9 @@ void __init efi_enter_virtual_mode(void) md = p; if (!(md->attribute & EFI_MEMORY_RUNTIME)) continue; + end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT); if ((md->attribute & EFI_MEMORY_WB) && - (((md->phys_addr + (md->num_pages<<EFI_PAGE_SHIFT)) >> - PAGE_SHIFT) < end_pfn_map)) + ((end >> PAGE_SHIFT) <= end_pfn_map)) md->virt_addr = (unsigned long)__va(md->phys_addr); else md->virt_addr = (unsigned long) @@ -410,7 +438,6 @@ void __init efi_enter_virtual_mode(void) if (!md->virt_addr) printk(KERN_ERR PFX "ioremap of 0x%llX failed!\n", (unsigned long long)md->phys_addr); - end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT); if ((md->phys_addr <= (unsigned long)efi_phys.systab) && ((unsigned long)efi_phys.systab < end)) efi.systab = (efi_system_table_t *)(unsigned long) @@ -448,9 +475,7 @@ void __init efi_enter_virtual_mode(void) efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count; efi.reset_system = virt_efi_reset_system; efi.set_virtual_address_map = virt_efi_set_virtual_address_map; -#ifdef CONFIG_X86_64 runtime_code_page_mkexec(); -#endif } /* |