aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorShane Wang <shane.wang@intel.com>2009-09-01 21:25:07 -0400
committerH. Peter Anvin <hpa@zytor.com>2009-09-01 21:25:07 -0400
commit69575d388603365f2afbf4166df93152df59b165 (patch)
treeca3d66668c8ec47befc0adbfa62cf135229bda59 /arch/x86/kernel
parent62a3207b8cf3de35368cdc3822b30b82d59eea95 (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')
-rw-r--r--arch/x86/kernel/reboot.c3
-rw-r--r--arch/x86/kernel/setup.c3
-rw-r--r--arch/x86/kernel/smpboot.c2
-rw-r--r--arch/x86/kernel/tboot.c58
4 files changed, 50 insertions, 16 deletions
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 9de01c5d9794..18ce5c04242a 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -3,6 +3,7 @@
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/pm.h> 4#include <linux/pm.h>
5#include <linux/efi.h> 5#include <linux/efi.h>
6#include <linux/tboot.h>
6#include <acpi/reboot.h> 7#include <acpi/reboot.h>
7#include <asm/io.h> 8#include <asm/io.h>
8#include <asm/apic.h> 9#include <asm/apic.h>
@@ -24,8 +25,6 @@
24# include <asm/iommu.h> 25# include <asm/iommu.h>
25#endif 26#endif
26 27
27#include <asm/tboot.h>
28
29/* 28/*
30 * Power off function, if any 29 * Power off function, if any
31 */ 30 */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 80d6e9e32483..6ce0d6f38f7f 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -66,6 +66,7 @@
66 66
67#include <linux/percpu.h> 67#include <linux/percpu.h>
68#include <linux/crash_dump.h> 68#include <linux/crash_dump.h>
69#include <linux/tboot.h>
69 70
70#include <video/edid.h> 71#include <video/edid.h>
71 72
@@ -145,8 +146,6 @@ struct boot_params __initdata boot_params;
145struct boot_params boot_params; 146struct boot_params boot_params;
146#endif 147#endif
147 148
148#include <asm/tboot.h>
149
150/* 149/*
151 * Machine setup.. 150 * Machine setup..
152 */ 151 */
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 61cc40887c48..7d9d8eea20a0 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -47,6 +47,7 @@
47#include <linux/bootmem.h> 47#include <linux/bootmem.h>
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/nmi.h> 49#include <linux/nmi.h>
50#include <linux/tboot.h>
50 51
51#include <asm/acpi.h> 52#include <asm/acpi.h>
52#include <asm/desc.h> 53#include <asm/desc.h>
@@ -62,7 +63,6 @@
62#include <asm/vmi.h> 63#include <asm/vmi.h>
63#include <asm/apic.h> 64#include <asm/apic.h>
64#include <asm/setup.h> 65#include <asm/setup.h>
65#include <asm/tboot.h>
66#include <asm/uv/uv.h> 66#include <asm/uv/uv.h>
67#include <linux/mc146818rtc.h> 67#include <linux/mc146818rtc.h>
68 68
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
157void tboot_create_trampoline(void) 159static 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
298int tboot_wait_for_aps(int num_aps) 297static atomic_t ap_wfs_count;
298
299static 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
316static 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
330static struct notifier_block tboot_cpu_notifier __cpuinitdata =
331{
332 .notifier_call = tboot_cpu_callback,
333};
334
335static __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
347late_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 */