summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm.c
diff options
context:
space:
mode:
authorJoerg Roedel2010-02-19 16:23:03 +0100
committerAvi Kivity2010-04-25 11:34:13 +0200
commitcdbbdc1210223879450555fee04c29ebf116576b (patch)
tree1c026d7307c7d022976ccd8b8bcf69ccfeaf1908 /arch/x86/kvm/svm.c
parentKVM: SVM: Fix schedule-while-atomic on nested exception handling (diff)
downloadkernel-qcow2-linux-cdbbdc1210223879450555fee04c29ebf116576b.tar.gz
kernel-qcow2-linux-cdbbdc1210223879450555fee04c29ebf116576b.tar.xz
kernel-qcow2-linux-cdbbdc1210223879450555fee04c29ebf116576b.zip
KVM: SVM: Sync all control registers on nested vmexit
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>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r--arch/x86/kvm/svm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index c27da0ad040c..02f8d491d15a 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -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;