ia64/xen-unstable

view xen/arch/x86/acpi/suspend.c @ 19169:8303bd33d030

x86: recover pat value for bsp after S3 resume.

host pat is set to cover all memory types by Xen, which is
necessary to support guest mtrr/pat, especially when device
is passthroughed with VT-d. However pat on bsp is not=20
recovered which could make assigned device defunct after S3
resume

Signed-off-by Kevin Tian <kevin.tian@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 05 12:14:09 2009 +0000 (2009-02-05)
parents 338f3c34e656
children e1562a36094e
line source
1 /*
2 * Portions are:
3 * Copyright (c) 2002 Pavel Machek <pavel@suse.cz>
4 * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org>
5 */
7 #include <xen/config.h>
8 #include <xen/acpi.h>
9 #include <xen/smp.h>
10 #include <asm/processor.h>
11 #include <asm/msr.h>
12 #include <asm/flushtlb.h>
13 #include <asm/hvm/hvm.h>
14 #include <asm/hvm/support.h>
15 #include <asm/i387.h>
17 #if defined(CONFIG_X86_64)
18 static unsigned long saved_lstar, saved_cstar;
19 #endif
21 void save_rest_processor_state(void)
22 {
23 if ( !is_idle_vcpu(current) )
24 unlazy_fpu(current);
26 #if defined(CONFIG_X86_64)
27 rdmsrl(MSR_CSTAR, saved_cstar);
28 rdmsrl(MSR_LSTAR, saved_lstar);
29 #endif
30 }
32 void restore_rest_processor_state(void)
33 {
34 int cpu = smp_processor_id();
35 struct tss_struct *t = &init_tss[cpu];
36 struct vcpu *v = current;
38 /* Rewriting the TSS desc is necessary to clear the Busy flag. */
39 set_tss_desc(cpu, t);
40 load_TR(cpu);
42 #if defined(CONFIG_X86_64)
43 /* Recover syscall MSRs */
44 wrmsrl(MSR_LSTAR, saved_lstar);
45 wrmsrl(MSR_CSTAR, saved_cstar);
46 wrmsr(MSR_STAR, 0, (FLAT_RING3_CS32<<16) | __HYPERVISOR_CS);
47 wrmsr(MSR_SYSCALL_MASK, EF_VM|EF_RF|EF_NT|EF_DF|EF_IE|EF_TF, 0U);
48 #else /* !defined(CONFIG_X86_64) */
49 if ( supervisor_mode_kernel && cpu_has_sep )
50 wrmsr(MSR_IA32_SYSENTER_ESP, &t->esp1, 0);
51 #endif
53 /* Maybe load the debug registers. */
54 BUG_ON(is_hvm_vcpu(v));
55 if ( !is_idle_vcpu(v) && unlikely(v->arch.guest_context.debugreg[7]) )
56 {
57 write_debugreg(0, v->arch.guest_context.debugreg[0]);
58 write_debugreg(1, v->arch.guest_context.debugreg[1]);
59 write_debugreg(2, v->arch.guest_context.debugreg[2]);
60 write_debugreg(3, v->arch.guest_context.debugreg[3]);
61 write_debugreg(6, v->arch.guest_context.debugreg[6]);
62 write_debugreg(7, v->arch.guest_context.debugreg[7]);
63 }
65 /* Reload FPU state on next FPU use. */
66 stts();
68 if (cpu_has_pat)
69 wrmsrl(MSR_IA32_CR_PAT, host_pat);
71 mtrr_ap_init();
72 mcheck_init(&boot_cpu_data);
73 }