aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/efi_64.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_64.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_64.c')
-rw-r--r--arch/x86/kernel/efi_64.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/arch/x86/kernel/efi_64.c b/arch/x86/kernel/efi_64.c
index 1f8bbd9644d..9f8a7559439 100644
--- a/arch/x86/kernel/efi_64.c
+++ b/arch/x86/kernel/efi_64.c
@@ -33,7 +33,6 @@
33#include <asm/e820.h> 33#include <asm/e820.h>
34#include <asm/pgtable.h> 34#include <asm/pgtable.h>
35#include <asm/tlbflush.h> 35#include <asm/tlbflush.h>
36#include <asm/cacheflush.h>
37#include <asm/proto.h> 36#include <asm/proto.h>
38#include <asm/efi.h> 37#include <asm/efi.h>
39 38
@@ -55,7 +54,7 @@ static void __init early_mapping_set_exec(unsigned long start,
55 else 54 else
56 set_pte(kpte, __pte((pte_val(*kpte) | _PAGE_NX) & \ 55 set_pte(kpte, __pte((pte_val(*kpte) | _PAGE_NX) & \
57 __supported_pte_mask)); 56 __supported_pte_mask));
58 if (pte_huge(*kpte)) 57 if (level == 4)
59 start = (start + PMD_SIZE) & PMD_MASK; 58 start = (start + PMD_SIZE) & PMD_MASK;
60 else 59 else
61 start = (start + PAGE_SIZE) & PAGE_MASK; 60 start = (start + PAGE_SIZE) & PAGE_MASK;
@@ -67,6 +66,9 @@ static void __init early_runtime_code_mapping_set_exec(int executable)
67 efi_memory_desc_t *md; 66 efi_memory_desc_t *md;
68 void *p; 67 void *p;
69 68
69 if (!(__supported_pte_mask & _PAGE_NX))
70 return;
71
70 /* Make EFI runtime service code area executable */ 72 /* Make EFI runtime service code area executable */
71 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 73 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
72 md = p; 74 md = p;
@@ -116,22 +118,6 @@ void __init efi_reserve_bootmem(void)
116 memmap.nr_map * memmap.desc_size); 118 memmap.nr_map * memmap.desc_size);
117} 119}
118 120
119void __init runtime_code_page_mkexec(void)
120{
121 efi_memory_desc_t *md;
122 void *p;
123
124 /* Make EFI runtime service code area executable */
125 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
126 md = p;
127 if (md->type == EFI_RUNTIME_SERVICES_CODE)
128 change_page_attr_addr(md->virt_addr,
129 md->num_pages,
130 PAGE_KERNEL_EXEC);
131 }
132 __flush_tlb_all();
133}
134
135void __iomem * __init efi_ioremap(unsigned long offset, 121void __iomem * __init efi_ioremap(unsigned long offset,
136 unsigned long size) 122 unsigned long size)
137{ 123{
@@ -146,8 +132,8 @@ void __iomem * __init efi_ioremap(unsigned long offset,
146 return NULL; 132 return NULL;
147 133
148 for (i = 0; i < pages; i++) { 134 for (i = 0; i < pages; i++) {
149 set_fixmap_nocache(FIX_EFI_IO_MAP_FIRST_PAGE - pages_mapped, 135 __set_fixmap(FIX_EFI_IO_MAP_FIRST_PAGE - pages_mapped,
150 offset); 136 offset, PAGE_KERNEL_EXEC_NOCACHE);
151 offset += PAGE_SIZE; 137 offset += PAGE_SIZE;
152 pages_mapped++; 138 pages_mapped++;
153 } 139 }