diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-06-17 06:52:15 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-17 06:56:49 -0400 |
commit | eadb8a091b27a840de7450f84ecff5ef13476424 (patch) | |
tree | 58c3782d40def63baa8167f3d31e3048cb4c7660 /arch/x86/power | |
parent | 73874005cd8800440be4299bd095387fff4b90ac (diff) | |
parent | 65795efbd380a832ae508b04dba8f8e53f0b84d9 (diff) |
Merge branch 'linus' into tracing/hw-breakpoints
Conflicts:
arch/x86/Kconfig
arch/x86/kernel/traps.c
arch/x86/power/cpu.c
arch/x86/power/cpu_32.c
kernel/Makefile
Semantic conflict:
arch/x86/kernel/hw_breakpoint.c
Merge reason: Resolve the conflicts, move from put_cpu_no_sched() to
put_cpu() in arch/x86/kernel/hw_breakpoint.c.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/power')
-rw-r--r-- | arch/x86/power/Makefile | 2 | ||||
-rw-r--r-- | arch/x86/power/cpu.c (renamed from arch/x86/power/cpu_64.c) | 137 | ||||
-rw-r--r-- | arch/x86/power/cpu_32.c | 141 |
3 files changed, 106 insertions, 174 deletions
diff --git a/arch/x86/power/Makefile b/arch/x86/power/Makefile index 58b32db33125..de2abbd07544 100644 --- a/arch/x86/power/Makefile +++ b/arch/x86/power/Makefile | |||
@@ -3,5 +3,5 @@ | |||
3 | nostackp := $(call cc-option, -fno-stack-protector) | 3 | nostackp := $(call cc-option, -fno-stack-protector) |
4 | CFLAGS_cpu_$(BITS).o := $(nostackp) | 4 | CFLAGS_cpu_$(BITS).o := $(nostackp) |
5 | 5 | ||
6 | obj-$(CONFIG_PM_SLEEP) += cpu_$(BITS).o | 6 | obj-$(CONFIG_PM_SLEEP) += cpu.o |
7 | obj-$(CONFIG_HIBERNATION) += hibernate_$(BITS).o hibernate_asm_$(BITS).o | 7 | obj-$(CONFIG_HIBERNATION) += hibernate_$(BITS).o hibernate_asm_$(BITS).o |
diff --git a/arch/x86/power/cpu_64.c b/arch/x86/power/cpu.c index 46866a13a93a..394cbb88987c 100644 --- a/arch/x86/power/cpu_64.c +++ b/arch/x86/power/cpu.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Suspend and hibernation support for x86-64 | 2 | * Suspend support specific for i386/x86-64. |
3 | * | 3 | * |
4 | * Distribute under GPLv2 | 4 | * Distribute under GPLv2 |
5 | * | 5 | * |
@@ -8,19 +8,29 @@ | |||
8 | * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org> | 8 | * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org> |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/smp.h> | ||
12 | #include <linux/suspend.h> | 11 | #include <linux/suspend.h> |
13 | #include <asm/proto.h> | 12 | #include <linux/smp.h> |
14 | #include <asm/page.h> | 13 | |
15 | #include <asm/pgtable.h> | 14 | #include <asm/pgtable.h> |
15 | #include <asm/proto.h> | ||
16 | #include <asm/mtrr.h> | 16 | #include <asm/mtrr.h> |
17 | #include <asm/page.h> | ||
18 | #include <asm/mce.h> | ||
17 | #include <asm/xcr.h> | 19 | #include <asm/xcr.h> |
18 | #include <asm/suspend.h> | 20 | #include <asm/suspend.h> |
19 | #include <asm/debugreg.h> | 21 | #include <asm/debugreg.h> |
20 | 22 | ||
21 | static void fix_processor_context(void); | 23 | #ifdef CONFIG_X86_32 |
24 | static struct saved_context saved_context; | ||
22 | 25 | ||
26 | unsigned long saved_context_ebx; | ||
27 | unsigned long saved_context_esp, saved_context_ebp; | ||
28 | unsigned long saved_context_esi, saved_context_edi; | ||
29 | unsigned long saved_context_eflags; | ||
30 | #else | ||
31 | /* CONFIG_X86_64 */ | ||
23 | struct saved_context saved_context; | 32 | struct saved_context saved_context; |
33 | #endif | ||
24 | 34 | ||
25 | /** | 35 | /** |
26 | * __save_processor_state - save CPU registers before creating a | 36 | * __save_processor_state - save CPU registers before creating a |
@@ -39,19 +49,35 @@ struct saved_context saved_context; | |||
39 | */ | 49 | */ |
40 | static void __save_processor_state(struct saved_context *ctxt) | 50 | static void __save_processor_state(struct saved_context *ctxt) |
41 | { | 51 | { |
52 | #ifdef CONFIG_X86_32 | ||
53 | mtrr_save_fixed_ranges(NULL); | ||
54 | #endif | ||
42 | kernel_fpu_begin(); | 55 | kernel_fpu_begin(); |
43 | 56 | ||
44 | /* | 57 | /* |
45 | * descriptor tables | 58 | * descriptor tables |
46 | */ | 59 | */ |
60 | #ifdef CONFIG_X86_32 | ||
61 | store_gdt(&ctxt->gdt); | ||
62 | store_idt(&ctxt->idt); | ||
63 | #else | ||
64 | /* CONFIG_X86_64 */ | ||
47 | store_gdt((struct desc_ptr *)&ctxt->gdt_limit); | 65 | store_gdt((struct desc_ptr *)&ctxt->gdt_limit); |
48 | store_idt((struct desc_ptr *)&ctxt->idt_limit); | 66 | store_idt((struct desc_ptr *)&ctxt->idt_limit); |
67 | #endif | ||
49 | store_tr(ctxt->tr); | 68 | store_tr(ctxt->tr); |
50 | 69 | ||
51 | /* XMM0..XMM15 should be handled by kernel_fpu_begin(). */ | 70 | /* XMM0..XMM15 should be handled by kernel_fpu_begin(). */ |
52 | /* | 71 | /* |
53 | * segment registers | 72 | * segment registers |
54 | */ | 73 | */ |
74 | #ifdef CONFIG_X86_32 | ||
75 | savesegment(es, ctxt->es); | ||
76 | savesegment(fs, ctxt->fs); | ||
77 | savesegment(gs, ctxt->gs); | ||
78 | savesegment(ss, ctxt->ss); | ||
79 | #else | ||
80 | /* CONFIG_X86_64 */ | ||
55 | asm volatile ("movw %%ds, %0" : "=m" (ctxt->ds)); | 81 | asm volatile ("movw %%ds, %0" : "=m" (ctxt->ds)); |
56 | asm volatile ("movw %%es, %0" : "=m" (ctxt->es)); | 82 | asm volatile ("movw %%es, %0" : "=m" (ctxt->es)); |
57 | asm volatile ("movw %%fs, %0" : "=m" (ctxt->fs)); | 83 | asm volatile ("movw %%fs, %0" : "=m" (ctxt->fs)); |
@@ -63,31 +89,68 @@ static void __save_processor_state(struct saved_context *ctxt) | |||
63 | rdmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base); | 89 | rdmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base); |
64 | mtrr_save_fixed_ranges(NULL); | 90 | mtrr_save_fixed_ranges(NULL); |
65 | 91 | ||
92 | rdmsrl(MSR_EFER, ctxt->efer); | ||
93 | #endif | ||
94 | |||
66 | /* | 95 | /* |
67 | * control registers | 96 | * control registers |
68 | */ | 97 | */ |
69 | rdmsrl(MSR_EFER, ctxt->efer); | ||
70 | ctxt->cr0 = read_cr0(); | 98 | ctxt->cr0 = read_cr0(); |
71 | ctxt->cr2 = read_cr2(); | 99 | ctxt->cr2 = read_cr2(); |
72 | ctxt->cr3 = read_cr3(); | 100 | ctxt->cr3 = read_cr3(); |
101 | #ifdef CONFIG_X86_32 | ||
102 | ctxt->cr4 = read_cr4_safe(); | ||
103 | #else | ||
104 | /* CONFIG_X86_64 */ | ||
73 | ctxt->cr4 = read_cr4(); | 105 | ctxt->cr4 = read_cr4(); |
74 | ctxt->cr8 = read_cr8(); | 106 | ctxt->cr8 = read_cr8(); |
107 | #endif | ||
75 | hw_breakpoint_disable(); | 108 | hw_breakpoint_disable(); |
76 | } | 109 | } |
77 | 110 | ||
111 | /* Needed by apm.c */ | ||
78 | void save_processor_state(void) | 112 | void save_processor_state(void) |
79 | { | 113 | { |
80 | __save_processor_state(&saved_context); | 114 | __save_processor_state(&saved_context); |
81 | } | 115 | } |
116 | #ifdef CONFIG_X86_32 | ||
117 | EXPORT_SYMBOL(save_processor_state); | ||
118 | #endif | ||
82 | 119 | ||
83 | static void do_fpu_end(void) | 120 | static void do_fpu_end(void) |
84 | { | 121 | { |
85 | /* | 122 | /* |
86 | * Restore FPU regs if necessary | 123 | * Restore FPU regs if necessary. |
87 | */ | 124 | */ |
88 | kernel_fpu_end(); | 125 | kernel_fpu_end(); |
89 | } | 126 | } |
90 | 127 | ||
128 | static void fix_processor_context(void) | ||
129 | { | ||
130 | int cpu = smp_processor_id(); | ||
131 | struct tss_struct *t = &per_cpu(init_tss, cpu); | ||
132 | |||
133 | set_tss_desc(cpu, t); /* | ||
134 | * This just modifies memory; should not be | ||
135 | * necessary. But... This is necessary, because | ||
136 | * 386 hardware has concept of busy TSS or some | ||
137 | * similar stupidity. | ||
138 | */ | ||
139 | |||
140 | #ifdef CONFIG_X86_64 | ||
141 | get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9; | ||
142 | |||
143 | syscall_init(); /* This sets MSR_*STAR and related */ | ||
144 | #endif | ||
145 | load_TR_desc(); /* This does ltr */ | ||
146 | load_LDT(¤t->active_mm->context); /* This does lldt */ | ||
147 | |||
148 | /* | ||
149 | * Now maybe reload the debug registers | ||
150 | */ | ||
151 | load_debug_registers(); | ||
152 | } | ||
153 | |||
91 | /** | 154 | /** |
92 | * __restore_processor_state - restore the contents of CPU registers saved | 155 | * __restore_processor_state - restore the contents of CPU registers saved |
93 | * by __save_processor_state() | 156 | * by __save_processor_state() |
@@ -98,9 +161,16 @@ static void __restore_processor_state(struct saved_context *ctxt) | |||
98 | /* | 161 | /* |
99 | * control registers | 162 | * control registers |
100 | */ | 163 | */ |
164 | /* cr4 was introduced in the Pentium CPU */ | ||
165 | #ifdef CONFIG_X86_32 | ||
166 | if (ctxt->cr4) | ||
167 | write_cr4(ctxt->cr4); | ||
168 | #else | ||
169 | /* CONFIG X86_64 */ | ||
101 | wrmsrl(MSR_EFER, ctxt->efer); | 170 | wrmsrl(MSR_EFER, ctxt->efer); |
102 | write_cr8(ctxt->cr8); | 171 | write_cr8(ctxt->cr8); |
103 | write_cr4(ctxt->cr4); | 172 | write_cr4(ctxt->cr4); |
173 | #endif | ||
104 | write_cr3(ctxt->cr3); | 174 | write_cr3(ctxt->cr3); |
105 | write_cr2(ctxt->cr2); | 175 | write_cr2(ctxt->cr2); |
106 | write_cr0(ctxt->cr0); | 176 | write_cr0(ctxt->cr0); |
@@ -109,13 +179,31 @@ static void __restore_processor_state(struct saved_context *ctxt) | |||
109 | * now restore the descriptor tables to their proper values | 179 | * now restore the descriptor tables to their proper values |
110 | * ltr is done i fix_processor_context(). | 180 | * ltr is done i fix_processor_context(). |
111 | */ | 181 | */ |
182 | #ifdef CONFIG_X86_32 | ||
183 | load_gdt(&ctxt->gdt); | ||
184 | load_idt(&ctxt->idt); | ||
185 | #else | ||
186 | /* CONFIG_X86_64 */ | ||
112 | load_gdt((const struct desc_ptr *)&ctxt->gdt_limit); | 187 | load_gdt((const struct desc_ptr *)&ctxt->gdt_limit); |
113 | load_idt((const struct desc_ptr *)&ctxt->idt_limit); | 188 | load_idt((const struct desc_ptr *)&ctxt->idt_limit); |
114 | 189 | #endif | |
115 | 190 | ||
116 | /* | 191 | /* |
117 | * segment registers | 192 | * segment registers |
118 | */ | 193 | */ |
194 | #ifdef CONFIG_X86_32 | ||
195 | loadsegment(es, ctxt->es); | ||
196 | loadsegment(fs, ctxt->fs); | ||
197 | loadsegment(gs, ctxt->gs); | ||
198 | loadsegment(ss, ctxt->ss); | ||
199 | |||
200 | /* | ||
201 | * sysenter MSRs | ||
202 | */ | ||
203 | if (boot_cpu_has(X86_FEATURE_SEP)) | ||
204 | enable_sep_cpu(); | ||
205 | #else | ||
206 | /* CONFIG_X86_64 */ | ||
119 | asm volatile ("movw %0, %%ds" :: "r" (ctxt->ds)); | 207 | asm volatile ("movw %0, %%ds" :: "r" (ctxt->ds)); |
120 | asm volatile ("movw %0, %%es" :: "r" (ctxt->es)); | 208 | asm volatile ("movw %0, %%es" :: "r" (ctxt->es)); |
121 | asm volatile ("movw %0, %%fs" :: "r" (ctxt->fs)); | 209 | asm volatile ("movw %0, %%fs" :: "r" (ctxt->fs)); |
@@ -125,6 +213,7 @@ static void __restore_processor_state(struct saved_context *ctxt) | |||
125 | wrmsrl(MSR_FS_BASE, ctxt->fs_base); | 213 | wrmsrl(MSR_FS_BASE, ctxt->fs_base); |
126 | wrmsrl(MSR_GS_BASE, ctxt->gs_base); | 214 | wrmsrl(MSR_GS_BASE, ctxt->gs_base); |
127 | wrmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base); | 215 | wrmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base); |
216 | #endif | ||
128 | 217 | ||
129 | /* | 218 | /* |
130 | * restore XCR0 for xsave capable cpu's. | 219 | * restore XCR0 for xsave capable cpu's. |
@@ -136,33 +225,17 @@ static void __restore_processor_state(struct saved_context *ctxt) | |||
136 | 225 | ||
137 | do_fpu_end(); | 226 | do_fpu_end(); |
138 | mtrr_ap_init(); | 227 | mtrr_ap_init(); |
228 | |||
229 | #ifdef CONFIG_X86_32 | ||
230 | mcheck_init(&boot_cpu_data); | ||
231 | #endif | ||
139 | } | 232 | } |
140 | 233 | ||
234 | /* Needed by apm.c */ | ||
141 | void restore_processor_state(void) | 235 | void restore_processor_state(void) |
142 | { | 236 | { |
143 | __restore_processor_state(&saved_context); | 237 | __restore_processor_state(&saved_context); |
144 | } | 238 | } |
145 | 239 | #ifdef CONFIG_X86_32 | |
146 | static void fix_processor_context(void) | 240 | EXPORT_SYMBOL(restore_processor_state); |
147 | { | 241 | #endif |
148 | int cpu = smp_processor_id(); | ||
149 | struct tss_struct *t = &per_cpu(init_tss, cpu); | ||
150 | |||
151 | /* | ||
152 | * This just modifies memory; should not be necessary. But... This | ||
153 | * is necessary, because 386 hardware has concept of busy TSS or some | ||
154 | * similar stupidity. | ||
155 | */ | ||
156 | set_tss_desc(cpu, t); | ||
157 | |||
158 | get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9; | ||
159 | |||
160 | syscall_init(); /* This sets MSR_*STAR and related */ | ||
161 | load_TR_desc(); /* This does ltr */ | ||
162 | load_LDT(¤t->active_mm->context); /* This does lldt */ | ||
163 | |||
164 | /* | ||
165 | * Now maybe reload the debug registers | ||
166 | */ | ||
167 | load_debug_registers(); | ||
168 | } | ||
diff --git a/arch/x86/power/cpu_32.c b/arch/x86/power/cpu_32.c deleted file mode 100644 index 2bc3b016de90..000000000000 --- a/arch/x86/power/cpu_32.c +++ /dev/null | |||
@@ -1,141 +0,0 @@ | |||
1 | /* | ||
2 | * Suspend support specific for i386. | ||
3 | * | ||
4 | * Distribute under GPLv2 | ||
5 | * | ||
6 | * Copyright (c) 2002 Pavel Machek <pavel@suse.cz> | ||
7 | * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org> | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/suspend.h> | ||
12 | #include <asm/mtrr.h> | ||
13 | #include <asm/mce.h> | ||
14 | #include <asm/xcr.h> | ||
15 | #include <asm/suspend.h> | ||
16 | #include <asm/debugreg.h> | ||
17 | |||
18 | static struct saved_context saved_context; | ||
19 | |||
20 | unsigned long saved_context_ebx; | ||
21 | unsigned long saved_context_esp, saved_context_ebp; | ||
22 | unsigned long saved_context_esi, saved_context_edi; | ||
23 | unsigned long saved_context_eflags; | ||
24 | |||
25 | static void __save_processor_state(struct saved_context *ctxt) | ||
26 | { | ||
27 | mtrr_save_fixed_ranges(NULL); | ||
28 | kernel_fpu_begin(); | ||
29 | |||
30 | /* | ||
31 | * descriptor tables | ||
32 | */ | ||
33 | store_gdt(&ctxt->gdt); | ||
34 | store_idt(&ctxt->idt); | ||
35 | store_tr(ctxt->tr); | ||
36 | |||
37 | /* | ||
38 | * segment registers | ||
39 | */ | ||
40 | savesegment(es, ctxt->es); | ||
41 | savesegment(fs, ctxt->fs); | ||
42 | savesegment(gs, ctxt->gs); | ||
43 | savesegment(ss, ctxt->ss); | ||
44 | |||
45 | /* | ||
46 | * control registers | ||
47 | */ | ||
48 | ctxt->cr0 = read_cr0(); | ||
49 | ctxt->cr2 = read_cr2(); | ||
50 | ctxt->cr3 = read_cr3(); | ||
51 | ctxt->cr4 = read_cr4_safe(); | ||
52 | hw_breakpoint_disable(); | ||
53 | } | ||
54 | |||
55 | /* Needed by apm.c */ | ||
56 | void save_processor_state(void) | ||
57 | { | ||
58 | __save_processor_state(&saved_context); | ||
59 | } | ||
60 | EXPORT_SYMBOL(save_processor_state); | ||
61 | |||
62 | static void do_fpu_end(void) | ||
63 | { | ||
64 | /* | ||
65 | * Restore FPU regs if necessary. | ||
66 | */ | ||
67 | kernel_fpu_end(); | ||
68 | } | ||
69 | |||
70 | static void fix_processor_context(void) | ||
71 | { | ||
72 | int cpu = smp_processor_id(); | ||
73 | struct tss_struct *t = &per_cpu(init_tss, cpu); | ||
74 | |||
75 | set_tss_desc(cpu, t); /* | ||
76 | * This just modifies memory; should not be | ||
77 | * necessary. But... This is necessary, because | ||
78 | * 386 hardware has concept of busy TSS or some | ||
79 | * similar stupidity. | ||
80 | */ | ||
81 | |||
82 | load_TR_desc(); /* This does ltr */ | ||
83 | load_LDT(¤t->active_mm->context); /* This does lldt */ | ||
84 | |||
85 | /* | ||
86 | * Now maybe reload the debug registers | ||
87 | */ | ||
88 | load_debug_registers(); | ||
89 | } | ||
90 | |||
91 | static void __restore_processor_state(struct saved_context *ctxt) | ||
92 | { | ||
93 | /* | ||
94 | * control registers | ||
95 | */ | ||
96 | /* cr4 was introduced in the Pentium CPU */ | ||
97 | if (ctxt->cr4) | ||
98 | write_cr4(ctxt->cr4); | ||
99 | write_cr3(ctxt->cr3); | ||
100 | write_cr2(ctxt->cr2); | ||
101 | write_cr0(ctxt->cr0); | ||
102 | |||
103 | /* | ||
104 | * now restore the descriptor tables to their proper values | ||
105 | * ltr is done i fix_processor_context(). | ||
106 | */ | ||
107 | load_gdt(&ctxt->gdt); | ||
108 | load_idt(&ctxt->idt); | ||
109 | |||
110 | /* | ||
111 | * segment registers | ||
112 | */ | ||
113 | loadsegment(es, ctxt->es); | ||
114 | loadsegment(fs, ctxt->fs); | ||
115 | loadsegment(gs, ctxt->gs); | ||
116 | loadsegment(ss, ctxt->ss); | ||
117 | |||
118 | /* | ||
119 | * sysenter MSRs | ||
120 | */ | ||
121 | if (boot_cpu_has(X86_FEATURE_SEP)) | ||
122 | enable_sep_cpu(); | ||
123 | |||
124 | /* | ||
125 | * restore XCR0 for xsave capable cpu's. | ||
126 | */ | ||
127 | if (cpu_has_xsave) | ||
128 | xsetbv(XCR_XFEATURE_ENABLED_MASK, pcntxt_mask); | ||
129 | |||
130 | fix_processor_context(); | ||
131 | do_fpu_end(); | ||
132 | mtrr_ap_init(); | ||
133 | mcheck_init(&boot_cpu_data); | ||
134 | } | ||
135 | |||
136 | /* Needed by apm.c */ | ||
137 | void restore_processor_state(void) | ||
138 | { | ||
139 | __restore_processor_state(&saved_context); | ||
140 | } | ||
141 | EXPORT_SYMBOL(restore_processor_state); | ||