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 | |
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')
-rw-r--r-- | arch/x86/Kconfig | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/tboot.h | 197 | ||||
-rw-r--r-- | arch/x86/kernel/reboot.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/setup.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/smpboot.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/tboot.c | 58 |
6 files changed, 54 insertions, 213 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 738bdc6b0f8b..b66f2102c35d 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -178,6 +178,10 @@ config ARCH_SUPPORTS_OPTIMIZED_INLINING | |||
178 | config ARCH_SUPPORTS_DEBUG_PAGEALLOC | 178 | config ARCH_SUPPORTS_DEBUG_PAGEALLOC |
179 | def_bool y | 179 | def_bool y |
180 | 180 | ||
181 | config HAVE_INTEL_TXT | ||
182 | def_bool y | ||
183 | depends on EXPERIMENTAL && DMAR && ACPI | ||
184 | |||
181 | # Use the generic interrupt handling code in kernel/irq/: | 185 | # Use the generic interrupt handling code in kernel/irq/: |
182 | config GENERIC_HARDIRQS | 186 | config GENERIC_HARDIRQS |
183 | bool | 187 | bool |
diff --git a/arch/x86/include/asm/tboot.h b/arch/x86/include/asm/tboot.h deleted file mode 100644 index b13929d4e5f4..000000000000 --- a/arch/x86/include/asm/tboot.h +++ /dev/null | |||
@@ -1,197 +0,0 @@ | |||
1 | /* | ||
2 | * tboot.h: shared data structure with tboot and kernel and functions | ||
3 | * used by kernel for runtime support of Intel(R) Trusted | ||
4 | * Execution Technology | ||
5 | * | ||
6 | * Copyright (c) 2006-2009, Intel Corporation | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms and conditions of the GNU General Public License, | ||
10 | * version 2, as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
15 | * more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License along with | ||
18 | * this program; if not, write to the Free Software Foundation, Inc., | ||
19 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef _ASM_TBOOT_H | ||
24 | #define _ASM_TBOOT_H | ||
25 | |||
26 | #include <acpi/acpi.h> | ||
27 | |||
28 | /* these must have the values from 0-5 in this order */ | ||
29 | enum { | ||
30 | TB_SHUTDOWN_REBOOT = 0, | ||
31 | TB_SHUTDOWN_S5, | ||
32 | TB_SHUTDOWN_S4, | ||
33 | TB_SHUTDOWN_S3, | ||
34 | TB_SHUTDOWN_HALT, | ||
35 | TB_SHUTDOWN_WFS | ||
36 | }; | ||
37 | |||
38 | #ifdef CONFIG_INTEL_TXT | ||
39 | |||
40 | /* used to communicate between tboot and the launched kernel */ | ||
41 | |||
42 | #define TB_KEY_SIZE 64 /* 512 bits */ | ||
43 | |||
44 | #define MAX_TB_MAC_REGIONS 32 | ||
45 | |||
46 | struct tboot_mac_region { | ||
47 | u64 start; /* must be 64 byte -aligned */ | ||
48 | u32 size; /* must be 64 byte -granular */ | ||
49 | } __packed; | ||
50 | |||
51 | /* GAS - Generic Address Structure (ACPI 2.0+) */ | ||
52 | struct tboot_acpi_generic_address { | ||
53 | u8 space_id; | ||
54 | u8 bit_width; | ||
55 | u8 bit_offset; | ||
56 | u8 access_width; | ||
57 | u64 address; | ||
58 | } __packed; | ||
59 | |||
60 | /* | ||
61 | * combines Sx info from FADT and FACS tables per ACPI 2.0+ spec | ||
62 | * (http://www.acpi.info/) | ||
63 | */ | ||
64 | struct tboot_acpi_sleep_info { | ||
65 | struct tboot_acpi_generic_address pm1a_cnt_blk; | ||
66 | struct tboot_acpi_generic_address pm1b_cnt_blk; | ||
67 | struct tboot_acpi_generic_address pm1a_evt_blk; | ||
68 | struct tboot_acpi_generic_address pm1b_evt_blk; | ||
69 | u16 pm1a_cnt_val; | ||
70 | u16 pm1b_cnt_val; | ||
71 | u64 wakeup_vector; | ||
72 | u32 vector_width; | ||
73 | u64 kernel_s3_resume_vector; | ||
74 | } __packed; | ||
75 | |||
76 | /* | ||
77 | * shared memory page used for communication between tboot and kernel | ||
78 | */ | ||
79 | struct tboot { | ||
80 | /* | ||
81 | * version 3+ fields: | ||
82 | */ | ||
83 | |||
84 | /* TBOOT_UUID */ | ||
85 | u8 uuid[16]; | ||
86 | |||
87 | /* version number: 5 is current */ | ||
88 | u32 version; | ||
89 | |||
90 | /* physical addr of tb_log_t log */ | ||
91 | u32 log_addr; | ||
92 | |||
93 | /* | ||
94 | * physical addr of entry point for tboot shutdown and | ||
95 | * type of shutdown (TB_SHUTDOWN_*) being requested | ||
96 | */ | ||
97 | u32 shutdown_entry; | ||
98 | u32 shutdown_type; | ||
99 | |||
100 | /* kernel-specified ACPI info for Sx shutdown */ | ||
101 | struct tboot_acpi_sleep_info acpi_sinfo; | ||
102 | |||
103 | /* tboot location in memory (physical) */ | ||
104 | u32 tboot_base; | ||
105 | u32 tboot_size; | ||
106 | |||
107 | /* memory regions (phys addrs) for tboot to MAC on S3 */ | ||
108 | u8 num_mac_regions; | ||
109 | struct tboot_mac_region mac_regions[MAX_TB_MAC_REGIONS]; | ||
110 | |||
111 | |||
112 | /* | ||
113 | * version 4+ fields: | ||
114 | */ | ||
115 | |||
116 | /* symmetric key for use by kernel; will be encrypted on S3 */ | ||
117 | u8 s3_key[TB_KEY_SIZE]; | ||
118 | |||
119 | |||
120 | /* | ||
121 | * version 5+ fields: | ||
122 | */ | ||
123 | |||
124 | /* used to 4byte-align num_in_wfs */ | ||
125 | u8 reserved_align[3]; | ||
126 | |||
127 | /* number of processors in wait-for-SIPI */ | ||
128 | u32 num_in_wfs; | ||
129 | } __packed; | ||
130 | |||
131 | /* | ||
132 | * UUID for tboot data struct to facilitate matching | ||
133 | * defined as {663C8DFF-E8B3-4b82-AABF-19EA4D057A08} by tboot, which is | ||
134 | * represented as {} in the char array used here | ||
135 | */ | ||
136 | #define TBOOT_UUID {0xff, 0x8d, 0x3c, 0x66, 0xb3, 0xe8, 0x82, 0x4b, 0xbf,\ | ||
137 | 0xaa, 0x19, 0xea, 0x4d, 0x5, 0x7a, 0x8} | ||
138 | |||
139 | extern struct tboot *tboot; | ||
140 | |||
141 | static inline int tboot_enabled(void) | ||
142 | { | ||
143 | return tboot != NULL; | ||
144 | } | ||
145 | |||
146 | extern void tboot_probe(void); | ||
147 | extern void tboot_create_trampoline(void); | ||
148 | extern void tboot_shutdown(u32 shutdown_type); | ||
149 | extern void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control); | ||
150 | extern int tboot_wait_for_aps(int num_aps); | ||
151 | extern struct acpi_table_header *tboot_get_dmar_table( | ||
152 | struct acpi_table_header *dmar_tbl); | ||
153 | extern int tboot_force_iommu(void); | ||
154 | |||
155 | #else /* CONFIG_INTEL_TXT */ | ||
156 | |||
157 | static inline int tboot_enabled(void) | ||
158 | { | ||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | static inline void tboot_probe(void) | ||
163 | { | ||
164 | } | ||
165 | |||
166 | static inline void tboot_create_trampoline(void) | ||
167 | { | ||
168 | } | ||
169 | |||
170 | static inline void tboot_shutdown(u32 shutdown_type) | ||
171 | { | ||
172 | } | ||
173 | |||
174 | static inline void tboot_sleep(u8 sleep_state, u32 pm1a_control, | ||
175 | u32 pm1b_control) | ||
176 | { | ||
177 | } | ||
178 | |||
179 | static inline int tboot_wait_for_aps(int num_aps) | ||
180 | { | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | static inline struct acpi_table_header *tboot_get_dmar_table( | ||
185 | struct acpi_table_header *dmar_tbl) | ||
186 | { | ||
187 | return dmar_tbl; | ||
188 | } | ||
189 | |||
190 | static inline int tboot_force_iommu(void) | ||
191 | { | ||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | #endif /* !CONFIG_INTEL_TXT */ | ||
196 | |||
197 | #endif /* _ASM_TBOOT_H */ | ||
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; | |||
145 | struct boot_params boot_params; | 146 | struct 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 | ||
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 | */ |