aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2010-04-22 06:33:09 -0400
committerAvi Kivity <avi@redhat.com>2010-05-17 05:19:20 -0400
commit2be4fc7a02c368dcfda83a386a5101c211b9535e (patch)
treec43bafd91cf461f51384a6e904604181235e71b8 /arch/x86/kvm
parent2041a06a50a2ef4062c8454482aa06e25f6cccde (diff)
KVM: SVM: Sync cr0 and cr3 to kvm state before nested handling
This patch syncs cr0 and cr3 from the vmcb to the kvm state before nested intercept handling is done. This allows to simplify the vmexit path. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/svm.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index c480d7f64a60..5ad9d802bd16 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1799,10 +1799,7 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
1799 nested_vmcb->save.gdtr = vmcb->save.gdtr; 1799 nested_vmcb->save.gdtr = vmcb->save.gdtr;
1800 nested_vmcb->save.idtr = vmcb->save.idtr; 1800 nested_vmcb->save.idtr = vmcb->save.idtr;
1801 nested_vmcb->save.cr0 = kvm_read_cr0(&svm->vcpu); 1801 nested_vmcb->save.cr0 = kvm_read_cr0(&svm->vcpu);
1802 if (npt_enabled) 1802 nested_vmcb->save.cr3 = svm->vcpu.arch.cr3;
1803 nested_vmcb->save.cr3 = vmcb->save.cr3;
1804 else
1805 nested_vmcb->save.cr3 = svm->vcpu.arch.cr3;
1806 nested_vmcb->save.cr2 = vmcb->save.cr2; 1803 nested_vmcb->save.cr2 = vmcb->save.cr2;
1807 nested_vmcb->save.cr4 = svm->vcpu.arch.cr4; 1804 nested_vmcb->save.cr4 = svm->vcpu.arch.cr4;
1808 nested_vmcb->save.rflags = vmcb->save.rflags; 1805 nested_vmcb->save.rflags = vmcb->save.rflags;
@@ -2641,6 +2638,11 @@ static int handle_exit(struct kvm_vcpu *vcpu)
2641 2638
2642 trace_kvm_exit(exit_code, vcpu); 2639 trace_kvm_exit(exit_code, vcpu);
2643 2640
2641 if (!(svm->vmcb->control.intercept_cr_write & INTERCEPT_CR0_MASK))
2642 vcpu->arch.cr0 = svm->vmcb->save.cr0;
2643 if (npt_enabled)
2644 vcpu->arch.cr3 = svm->vmcb->save.cr3;
2645
2644 if (unlikely(svm->nested.exit_required)) { 2646 if (unlikely(svm->nested.exit_required)) {
2645 nested_svm_vmexit(svm); 2647 nested_svm_vmexit(svm);
2646 svm->nested.exit_required = false; 2648 svm->nested.exit_required = false;
@@ -2668,11 +2670,6 @@ static int handle_exit(struct kvm_vcpu *vcpu)
2668 2670
2669 svm_complete_interrupts(svm); 2671 svm_complete_interrupts(svm);
2670 2672
2671 if (!(svm->vmcb->control.intercept_cr_write & INTERCEPT_CR0_MASK))
2672 vcpu->arch.cr0 = svm->vmcb->save.cr0;
2673 if (npt_enabled)
2674 vcpu->arch.cr3 = svm->vmcb->save.cr3;
2675
2676 if (svm->vmcb->control.exit_code == SVM_EXIT_ERR) { 2673 if (svm->vmcb->control.exit_code == SVM_EXIT_ERR) {
2677 kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY; 2674 kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY;
2678 kvm_run->fail_entry.hardware_entry_failure_reason 2675 kvm_run->fail_entry.hardware_entry_failure_reason