diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-03-12 13:16:28 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-05-13 13:12:40 +0200 |
commit | 43175fa96add507afee6c0a83ec9ffe0ca130fc3 (patch) | |
tree | 3b720e0bcd3c0d806f0276bf8e38f9943bb38ee2 /target-i386/helper.c | |
parent | 05e7e819d7d159a75a46354aead95e1199b8f168 (diff) |
target-i386: preserve FPU and MSR state on INIT
Most MSRs, plus the FPU, MMX, MXCSR, XMM and YMM registers should not
be zeroed on INIT (Table 9-1 in the Intel SDM). Copy them out of
CPUX86State and back in, instead of special casing env->pat.
The relevant fields are already consecutive except PAT and SMBASE.
However:
- KVM and Hyper-V MSRs should be reset because they include memory
locations written by the hypervisor. These MSRs are moved together
at the end of the preserved area.
- SVM state can be moved out of the way since it is written by VMRUN.
Cc: Andreas Faerber <afaerber@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target-i386/helper.c')
-rw-r--r-- | target-i386/helper.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/target-i386/helper.c b/target-i386/helper.c index 27b35826e9..46d20e4b89 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1330,12 +1330,18 @@ void do_cpu_init(X86CPU *cpu) { CPUState *cs = CPU(cpu); CPUX86State *env = &cpu->env; + CPUX86State *save = g_new(CPUX86State, 1); int sipi = cs->interrupt_request & CPU_INTERRUPT_SIPI; - uint64_t pat = env->pat; + + *save = *env; cpu_reset(cs); cs->interrupt_request = sipi; - env->pat = pat; + memcpy(&env->start_init_save, &save->start_init_save, + offsetof(CPUX86State, end_init_save) - + offsetof(CPUX86State, start_init_save)); + g_free(save); + if (kvm_enabled()) { kvm_arch_do_init_vcpu(cpu); } |