aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/efi.c
diff options
context:
space:
mode:
authorHuang, Ying <ying.huang@intel.com>2008-01-30 07:33:55 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:55 -0500
commita2172e2586f6662af996e47f417bb718c37cf8d2 (patch)
treef2430abad9fd9417653a3a2faa472d9df0c308bd /arch/x86/kernel/efi.c
parentcd58289667293593b04fd315ec7f2f37589134cb (diff)
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.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/arch/x86/kernel/efi.c b/arch/x86/kernel/efi.c
index 5d492f99d967..834ecfb41e97 100644
--- a/arch/x86/kernel/efi.c
+++ b/arch/x86/kernel/efi.c
@@ -40,6 +40,8 @@
40#include <asm/setup.h> 40#include <asm/setup.h>
41#include <asm/efi.h> 41#include <asm/efi.h>
42#include <asm/time.h> 42#include <asm/time.h>
43#include <asm/cacheflush.h>
44#include <asm/tlbflush.h>
43 45
44#define EFI_DEBUG 1 46#define EFI_DEBUG 1
45#define PFX "EFI: " 47#define PFX "EFI: "
@@ -379,6 +381,32 @@ void __init efi_init(void)
379#endif 381#endif
380} 382}
381 383
384#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
385static void __init runtime_code_page_mkexec(void)
386{
387 efi_memory_desc_t *md;
388 unsigned long end;
389 void *p;
390
391 if (!(__supported_pte_mask & _PAGE_NX))
392 return;
393
394 /* Make EFI runtime service code area executable */
395 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
396 md = p;
397 end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
398 if (md->type == EFI_RUNTIME_SERVICES_CODE &&
399 (end >> PAGE_SHIFT) <= end_pfn_map)
400 change_page_attr_addr(md->virt_addr,
401 md->num_pages,
402 PAGE_KERNEL_EXEC_NOCACHE);
403 }
404 __flush_tlb_all();
405}
406#else
407static inline void __init runtime_code_page_mkexec(void) { }
408#endif
409
382/* 410/*
383 * This function will switch the EFI runtime services to virtual mode. 411 * This function will switch the EFI runtime services to virtual mode.
384 * Essentially, look through the EFI memmap and map every region that 412 * Essentially, look through the EFI memmap and map every region that
@@ -399,9 +427,9 @@ void __init efi_enter_virtual_mode(void)
399 md = p; 427 md = p;
400 if (!(md->attribute & EFI_MEMORY_RUNTIME)) 428 if (!(md->attribute & EFI_MEMORY_RUNTIME))
401 continue; 429 continue;
430 end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
402 if ((md->attribute & EFI_MEMORY_WB) && 431 if ((md->attribute & EFI_MEMORY_WB) &&
403 (((md->phys_addr + (md->num_pages<<EFI_PAGE_SHIFT)) >> 432 ((end >> PAGE_SHIFT) <= end_pfn_map))
404 PAGE_SHIFT) < end_pfn_map))
405 md->virt_addr = (unsigned long)__va(md->phys_addr); 433 md->virt_addr = (unsigned long)__va(md->phys_addr);
406 else 434 else
407 md->virt_addr = (unsigned long) 435 md->virt_addr = (unsigned long)
@@ -410,7 +438,6 @@ void __init efi_enter_virtual_mode(void)
410 if (!md->virt_addr) 438 if (!md->virt_addr)
411 printk(KERN_ERR PFX "ioremap of 0x%llX failed!\n", 439 printk(KERN_ERR PFX "ioremap of 0x%llX failed!\n",
412 (unsigned long long)md->phys_addr); 440 (unsigned long long)md->phys_addr);
413 end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
414 if ((md->phys_addr <= (unsigned long)efi_phys.systab) && 441 if ((md->phys_addr <= (unsigned long)efi_phys.systab) &&
415 ((unsigned long)efi_phys.systab < end)) 442 ((unsigned long)efi_phys.systab < end))
416 efi.systab = (efi_system_table_t *)(unsigned long) 443 efi.systab = (efi_system_table_t *)(unsigned long)
@@ -448,9 +475,7 @@ void __init efi_enter_virtual_mode(void)
448 efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count; 475 efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count;
449 efi.reset_system = virt_efi_reset_system; 476 efi.reset_system = virt_efi_reset_system;
450 efi.set_virtual_address_map = virt_efi_set_virtual_address_map; 477 efi.set_virtual_address_map = virt_efi_set_virtual_address_map;
451#ifdef CONFIG_X86_64
452 runtime_code_page_mkexec(); 478 runtime_code_page_mkexec();
453#endif
454} 479}
455 480
456/* 481/*