aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-15 18:15:24 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-15 18:20:41 -0500
commit11520e5e7c1855fc3bf202bb3be35a39d9efa034 (patch)
tree734ea170f825000dceef3f724dff474b46fce11d /arch/x86/kernel
parent5bd665f28db2b04a8d6fe277342479906fc60b62 (diff)
Revert "x86-64/efi: Use EFI to deal with platform wall clock (again)"
This reverts commit bd52276fa1d4 ("x86-64/efi: Use EFI to deal with platform wall clock (again)"), and the two supporting commits: da5a108d05b4: "x86/kernel: remove tboot 1:1 page table creation code" 185034e72d59: "x86, efi: 1:1 pagetable mapping for virtual EFI calls") as they all depend semantically on commit 53b87cf088e2 ("x86, mm: Include the entire kernel memory map in trampoline_pgd") that got reverted earlier due to the problems it caused. This was pointed out by Yinghai Lu, and verified by me on my Macbook Air that uses EFI. Pointed-out-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/tboot.c78
1 files changed, 73 insertions, 5 deletions
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index d4f460f962ee..f84fe00fad48 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -103,13 +103,71 @@ void __init tboot_probe(void)
103 pr_debug("tboot_size: 0x%x\n", tboot->tboot_size); 103 pr_debug("tboot_size: 0x%x\n", tboot->tboot_size);
104} 104}
105 105
106static pgd_t *tboot_pg_dir;
107static struct mm_struct tboot_mm = {
108 .mm_rb = RB_ROOT,
109 .pgd = swapper_pg_dir,
110 .mm_users = ATOMIC_INIT(2),
111 .mm_count = ATOMIC_INIT(1),
112 .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem),
113 .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock),
114 .mmlist = LIST_HEAD_INIT(init_mm.mmlist),
115};
116
106static inline void switch_to_tboot_pt(void) 117static inline void switch_to_tboot_pt(void)
107{ 118{
108#ifdef CONFIG_X86_32 119 write_cr3(virt_to_phys(tboot_pg_dir));
109 load_cr3(initial_page_table); 120}
110#else 121
111 write_cr3(real_mode_header->trampoline_pgd); 122static int map_tboot_page(unsigned long vaddr, unsigned long pfn,
112#endif 123 pgprot_t prot)
124{
125 pgd_t *pgd;
126 pud_t *pud;
127 pmd_t *pmd;
128 pte_t *pte;
129
130 pgd = pgd_offset(&tboot_mm, vaddr);
131 pud = pud_alloc(&tboot_mm, pgd, vaddr);
132 if (!pud)
133 return -1;
134 pmd = pmd_alloc(&tboot_mm, pud, vaddr);
135 if (!pmd)
136 return -1;
137 pte = pte_alloc_map(&tboot_mm, NULL, pmd, vaddr);
138 if (!pte)
139 return -1;
140 set_pte_at(&tboot_mm, vaddr, pte, pfn_pte(pfn, prot));
141 pte_unmap(pte);
142 return 0;
143}
144
145static int map_tboot_pages(unsigned long vaddr, unsigned long start_pfn,
146 unsigned long nr)
147{
148 /* Reuse the original kernel mapping */
149 tboot_pg_dir = pgd_alloc(&tboot_mm);
150 if (!tboot_pg_dir)
151 return -1;
152
153 for (; nr > 0; nr--, vaddr += PAGE_SIZE, start_pfn++) {
154 if (map_tboot_page(vaddr, start_pfn, PAGE_KERNEL_EXEC))
155 return -1;
156 }
157
158 return 0;
159}
160
161static void tboot_create_trampoline(void)
162{
163 u32 map_base, map_size;
164
165 /* Create identity map for tboot shutdown code. */
166 map_base = PFN_DOWN(tboot->tboot_base);
167 map_size = PFN_UP(tboot->tboot_size);
168 if (map_tboot_pages(map_base << PAGE_SHIFT, map_base, map_size))
169 panic("tboot: Error mapping tboot pages (mfns) @ 0x%x, 0x%x\n",
170 map_base, map_size);
113} 171}
114 172
115#ifdef CONFIG_ACPI_SLEEP 173#ifdef CONFIG_ACPI_SLEEP
@@ -167,6 +225,14 @@ void tboot_shutdown(u32 shutdown_type)
167 if (!tboot_enabled()) 225 if (!tboot_enabled())
168 return; 226 return;
169 227
228 /*
229 * if we're being called before the 1:1 mapping is set up then just
230 * return and let the normal shutdown happen; this should only be
231 * due to very early panic()
232 */
233 if (!tboot_pg_dir)
234 return;
235
170 /* if this is S3 then set regions to MAC */ 236 /* if this is S3 then set regions to MAC */
171 if (shutdown_type == TB_SHUTDOWN_S3) 237 if (shutdown_type == TB_SHUTDOWN_S3)
172 if (tboot_setup_sleep()) 238 if (tboot_setup_sleep())
@@ -277,6 +343,8 @@ static __init int tboot_late_init(void)
277 if (!tboot_enabled()) 343 if (!tboot_enabled())
278 return 0; 344 return 0;
279 345
346 tboot_create_trampoline();
347
280 atomic_set(&ap_wfs_count, 0); 348 atomic_set(&ap_wfs_count, 0);
281 register_hotcpu_notifier(&tboot_cpu_notifier); 349 register_hotcpu_notifier(&tboot_cpu_notifier);
282 350