aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/power/cpu_64.c
diff options
context:
space:
mode:
authorSergio Luis <sergio@larces.uece.br>2009-04-27 18:27:00 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2009-06-12 15:32:30 -0400
commitf9ebbe53e79c5978d0e8ead0843a3717b41ad3d5 (patch)
treebceb57f37200a72cbca2ffd15881306fecffd649 /arch/x86/power/cpu_64.c
parent833b2ca0795526898a66c7b6770273bb16567e19 (diff)
x86: unify power/cpu_(32|64) regarding saving processor state
In this step we do unify cpu_32.c and cpu_64.c functions that work on saving the processor state. Signed-off-by: Sergio Luis <sergio@larces.uece.br> Signed-off-by: Lauro Salmito <laurosalmito@gmail.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'arch/x86/power/cpu_64.c')
-rw-r--r--arch/x86/power/cpu_64.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/arch/x86/power/cpu_64.c b/arch/x86/power/cpu_64.c
index 6ce0eca847c3..11ea7d0ba5d9 100644
--- a/arch/x86/power/cpu_64.c
+++ b/arch/x86/power/cpu_64.c
@@ -50,19 +50,35 @@ struct saved_context saved_context;
50 */ 50 */
51static void __save_processor_state(struct saved_context *ctxt) 51static void __save_processor_state(struct saved_context *ctxt)
52{ 52{
53#ifdef CONFIG_X86_32
54 mtrr_save_fixed_ranges(NULL);
55#endif
53 kernel_fpu_begin(); 56 kernel_fpu_begin();
54 57
55 /* 58 /*
56 * descriptor tables 59 * descriptor tables
57 */ 60 */
61#ifdef CONFIG_X86_32
62 store_gdt(&ctxt->gdt);
63 store_idt(&ctxt->idt);
64#else
65/* CONFIG_X86_64 */
58 store_gdt((struct desc_ptr *)&ctxt->gdt_limit); 66 store_gdt((struct desc_ptr *)&ctxt->gdt_limit);
59 store_idt((struct desc_ptr *)&ctxt->idt_limit); 67 store_idt((struct desc_ptr *)&ctxt->idt_limit);
68#endif
60 store_tr(ctxt->tr); 69 store_tr(ctxt->tr);
61 70
62 /* XMM0..XMM15 should be handled by kernel_fpu_begin(). */ 71 /* XMM0..XMM15 should be handled by kernel_fpu_begin(). */
63 /* 72 /*
64 * segment registers 73 * segment registers
65 */ 74 */
75#ifdef CONFIG_X86_32
76 savesegment(es, ctxt->es);
77 savesegment(fs, ctxt->fs);
78 savesegment(gs, ctxt->gs);
79 savesegment(ss, ctxt->ss);
80#else
81/* CONFIG_X86_64 */
66 asm volatile ("movw %%ds, %0" : "=m" (ctxt->ds)); 82 asm volatile ("movw %%ds, %0" : "=m" (ctxt->ds));
67 asm volatile ("movw %%es, %0" : "=m" (ctxt->es)); 83 asm volatile ("movw %%es, %0" : "=m" (ctxt->es));
68 asm volatile ("movw %%fs, %0" : "=m" (ctxt->fs)); 84 asm volatile ("movw %%fs, %0" : "=m" (ctxt->fs));
@@ -74,21 +90,32 @@ static void __save_processor_state(struct saved_context *ctxt)
74 rdmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base); 90 rdmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base);
75 mtrr_save_fixed_ranges(NULL); 91 mtrr_save_fixed_ranges(NULL);
76 92
93 rdmsrl(MSR_EFER, ctxt->efer);
94#endif
95
77 /* 96 /*
78 * control registers 97 * control registers
79 */ 98 */
80 rdmsrl(MSR_EFER, ctxt->efer);
81 ctxt->cr0 = read_cr0(); 99 ctxt->cr0 = read_cr0();
82 ctxt->cr2 = read_cr2(); 100 ctxt->cr2 = read_cr2();
83 ctxt->cr3 = read_cr3(); 101 ctxt->cr3 = read_cr3();
102#ifdef CONFIG_X86_32
103 ctxt->cr4 = read_cr4_safe();
104#else
105/* CONFIG_X86_64 */
84 ctxt->cr4 = read_cr4(); 106 ctxt->cr4 = read_cr4();
85 ctxt->cr8 = read_cr8(); 107 ctxt->cr8 = read_cr8();
108#endif
86} 109}
87 110
111/* Needed by apm.c */
88void save_processor_state(void) 112void save_processor_state(void)
89{ 113{
90 __save_processor_state(&saved_context); 114 __save_processor_state(&saved_context);
91} 115}
116#ifdef CONFIG_X86_32
117EXPORT_SYMBOL(save_processor_state);
118#endif
92 119
93static void do_fpu_end(void) 120static void do_fpu_end(void)
94{ 121{