KVM: SVM: Sync all control registers on nested vmexit
authorJoerg Roedel <joerg.roedel@amd.com>
Fri, 19 Feb 2010 15:23:03 +0000 (16:23 +0100)
committerAvi Kivity <avi@redhat.com>
Sun, 25 Apr 2010 09:34:13 +0000 (12:34 +0300)
Currently the vmexit emulation does not sync control
registers were the access is typically intercepted by the
nested hypervisor. But we can not count on that intercepts
to sync these registers too and make the code
architecturally more correct.

Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/svm.c

index c27da0ad040c2bc83f3171612ced4acacc2859ca..02f8d491d15adc94bab18b1e63076a61c49f7ac4 100644 (file)
@@ -1647,9 +1647,13 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
        nested_vmcb->save.ds     = vmcb->save.ds;
        nested_vmcb->save.gdtr   = vmcb->save.gdtr;
        nested_vmcb->save.idtr   = vmcb->save.idtr;
+       nested_vmcb->save.cr0    = kvm_read_cr0(&svm->vcpu);
        if (npt_enabled)
                nested_vmcb->save.cr3    = vmcb->save.cr3;
+       else
+               nested_vmcb->save.cr3    = svm->vcpu.arch.cr3;
        nested_vmcb->save.cr2    = vmcb->save.cr2;
+       nested_vmcb->save.cr4    = svm->vcpu.arch.cr4;
        nested_vmcb->save.rflags = vmcb->save.rflags;
        nested_vmcb->save.rip    = vmcb->save.rip;
        nested_vmcb->save.rsp    = vmcb->save.rsp;