diff options
author | Shane Wang <shane.wang@intel.com> | 2009-09-01 21:25:07 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-09-01 21:25:07 -0400 |
commit | 69575d388603365f2afbf4166df93152df59b165 (patch) | |
tree | ca3d66668c8ec47befc0adbfa62cf135229bda59 /arch/x86/kernel/tboot.c | |
parent | 62a3207b8cf3de35368cdc3822b30b82d59eea95 (diff) |
x86, intel_txt: clean up the impact on generic code, unbreak non-x86
Move tboot.h from asm to linux to fix the build errors of intel_txt
patch on non-X86 platforms. Remove the tboot code from generic code
init/main.c and kernel/cpu.c.
Signed-off-by: Shane Wang <shane.wang@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/kernel/tboot.c')
-rw-r--r-- | arch/x86/kernel/tboot.c | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c index c2e760ca7b01..86c9f91b48ae 100644 --- a/arch/x86/kernel/tboot.c +++ b/arch/x86/kernel/tboot.c | |||
@@ -22,11 +22,14 @@ | |||
22 | #include <linux/dma_remapping.h> | 22 | #include <linux/dma_remapping.h> |
23 | #include <linux/init_task.h> | 23 | #include <linux/init_task.h> |
24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
25 | #include <linux/delay.h> | ||
25 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
26 | #include <linux/init.h> | 27 | #include <linux/init.h> |
27 | #include <linux/dmar.h> | 28 | #include <linux/dmar.h> |
29 | #include <linux/cpu.h> | ||
28 | #include <linux/pfn.h> | 30 | #include <linux/pfn.h> |
29 | #include <linux/mm.h> | 31 | #include <linux/mm.h> |
32 | #include <linux/tboot.h> | ||
30 | 33 | ||
31 | #include <asm/trampoline.h> | 34 | #include <asm/trampoline.h> |
32 | #include <asm/processor.h> | 35 | #include <asm/processor.h> |
@@ -36,7 +39,6 @@ | |||
36 | #include <asm/fixmap.h> | 39 | #include <asm/fixmap.h> |
37 | #include <asm/proto.h> | 40 | #include <asm/proto.h> |
38 | #include <asm/setup.h> | 41 | #include <asm/setup.h> |
39 | #include <asm/tboot.h> | ||
40 | #include <asm/e820.h> | 42 | #include <asm/e820.h> |
41 | #include <asm/io.h> | 43 | #include <asm/io.h> |
42 | 44 | ||
@@ -154,13 +156,10 @@ static int map_tboot_pages(unsigned long vaddr, unsigned long start_pfn, | |||
154 | return 0; | 156 | return 0; |
155 | } | 157 | } |
156 | 158 | ||
157 | void tboot_create_trampoline(void) | 159 | static void tboot_create_trampoline(void) |
158 | { | 160 | { |
159 | u32 map_base, map_size; | 161 | u32 map_base, map_size; |
160 | 162 | ||
161 | if (!tboot_enabled()) | ||
162 | return; | ||
163 | |||
164 | /* Create identity map for tboot shutdown code. */ | 163 | /* Create identity map for tboot shutdown code. */ |
165 | map_base = PFN_DOWN(tboot->tboot_base); | 164 | map_base = PFN_DOWN(tboot->tboot_base); |
166 | map_size = PFN_UP(tboot->tboot_size); | 165 | map_size = PFN_UP(tboot->tboot_size); |
@@ -295,21 +294,58 @@ void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control) | |||
295 | tboot_shutdown(acpi_shutdown_map[sleep_state]); | 294 | tboot_shutdown(acpi_shutdown_map[sleep_state]); |
296 | } | 295 | } |
297 | 296 | ||
298 | int tboot_wait_for_aps(int num_aps) | 297 | static atomic_t ap_wfs_count; |
298 | |||
299 | static int tboot_wait_for_aps(int num_aps) | ||
299 | { | 300 | { |
300 | unsigned long timeout; | 301 | unsigned long timeout; |
301 | 302 | ||
303 | timeout = AP_WAIT_TIMEOUT*HZ; | ||
304 | while (atomic_read((atomic_t *)&tboot->num_in_wfs) != num_aps && | ||
305 | timeout) { | ||
306 | mdelay(1); | ||
307 | timeout--; | ||
308 | } | ||
309 | |||
310 | if (timeout) | ||
311 | pr_warning("tboot wait for APs timeout\n"); | ||
312 | |||
313 | return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps); | ||
314 | } | ||
315 | |||
316 | static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb, | ||
317 | unsigned long action, void *hcpu) | ||
318 | { | ||
319 | switch (action) { | ||
320 | case CPU_DYING: | ||
321 | atomic_inc(&ap_wfs_count); | ||
322 | if (num_online_cpus() == 1) | ||
323 | if (tboot_wait_for_aps(atomic_read(&ap_wfs_count))) | ||
324 | return NOTIFY_BAD; | ||
325 | break; | ||
326 | } | ||
327 | return NOTIFY_OK; | ||
328 | } | ||
329 | |||
330 | static struct notifier_block tboot_cpu_notifier __cpuinitdata = | ||
331 | { | ||
332 | .notifier_call = tboot_cpu_callback, | ||
333 | }; | ||
334 | |||
335 | static __init int tboot_late_init(void) | ||
336 | { | ||
302 | if (!tboot_enabled()) | 337 | if (!tboot_enabled()) |
303 | return 0; | 338 | return 0; |
304 | 339 | ||
305 | timeout = jiffies + AP_WAIT_TIMEOUT*HZ; | 340 | tboot_create_trampoline(); |
306 | while (atomic_read((atomic_t *)&tboot->num_in_wfs) != num_aps && | ||
307 | time_before(jiffies, timeout)) | ||
308 | cpu_relax(); | ||
309 | 341 | ||
310 | return time_before(jiffies, timeout) ? 0 : 1; | 342 | atomic_set(&ap_wfs_count, 0); |
343 | register_hotcpu_notifier(&tboot_cpu_notifier); | ||
344 | return 0; | ||
311 | } | 345 | } |
312 | 346 | ||
347 | late_initcall(tboot_late_init); | ||
348 | |||
313 | /* | 349 | /* |
314 | * TXT configuration registers (offsets from TXT_{PUB, PRIV}_CONFIG_REGS_BASE) | 350 | * TXT configuration registers (offsets from TXT_{PUB, PRIV}_CONFIG_REGS_BASE) |
315 | */ | 351 | */ |