aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-01-10 05:14:04 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2010-03-01 10:35:51 -0500
commit888f9f3e0cfa32baf05b3840f0248f5502292a0f (patch)
tree11f035e747b6e41c227c0ea64bd07800500d296f /arch/x86/kvm
parentbff7827479ed004c0394e6e7b35ae601bb1a97ad (diff)
KVM: SVM: Restore unconditional cr0 intercept under npt
Currently we don't intercept cr0 at all when npt is enabled. This improves performance but requires us to activate the fpu at all times. Remove this behaviour in preparation for adding selective cr0 intercepts. Acked-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.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 949990e4a22e..27273ed24c41 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -643,10 +643,8 @@ static void init_vmcb(struct vcpu_svm *svm)
643 control->intercept &= ~((1ULL << INTERCEPT_TASK_SWITCH) | 643 control->intercept &= ~((1ULL << INTERCEPT_TASK_SWITCH) |
644 (1ULL << INTERCEPT_INVLPG)); 644 (1ULL << INTERCEPT_INVLPG));
645 control->intercept_exceptions &= ~(1 << PF_VECTOR); 645 control->intercept_exceptions &= ~(1 << PF_VECTOR);
646 control->intercept_cr_read &= ~(INTERCEPT_CR0_MASK| 646 control->intercept_cr_read &= ~INTERCEPT_CR3_MASK;
647 INTERCEPT_CR3_MASK); 647 control->intercept_cr_write &= ~INTERCEPT_CR3_MASK;
648 control->intercept_cr_write &= ~(INTERCEPT_CR0_MASK|
649 INTERCEPT_CR3_MASK);
650 save->g_pat = 0x0007040600070406ULL; 648 save->g_pat = 0x0007040600070406ULL;
651 save->cr3 = 0; 649 save->cr3 = 0;
652 save->cr4 = 0; 650 save->cr4 = 0;
@@ -982,15 +980,13 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
982 } 980 }
983 } 981 }
984#endif 982#endif
985 if (npt_enabled)
986 goto set;
987
988 vcpu->arch.cr0 = cr0; 983 vcpu->arch.cr0 = cr0;
989 cr0 |= X86_CR0_PG | X86_CR0_WP; 984
985 if (!npt_enabled)
986 cr0 |= X86_CR0_PG | X86_CR0_WP;
990 987
991 if (!vcpu->fpu_active) 988 if (!vcpu->fpu_active)
992 cr0 |= X86_CR0_TS; 989 cr0 |= X86_CR0_TS;
993set:
994 /* 990 /*
995 * re-enable caching here because the QEMU bios 991 * re-enable caching here because the QEMU bios
996 * does not do it - this results in some delay at 992 * does not do it - this results in some delay at
@@ -2386,21 +2382,10 @@ static int handle_exit(struct kvm_vcpu *vcpu)
2386 2382
2387 svm_complete_interrupts(svm); 2383 svm_complete_interrupts(svm);
2388 2384
2389 if (npt_enabled) { 2385 if (!(svm->vmcb->control.intercept_cr_write & INTERCEPT_CR0_MASK))
2390 int mmu_reload = 0;
2391 if ((kvm_read_cr0_bits(vcpu, X86_CR0_PG) ^ svm->vmcb->save.cr0)
2392 & X86_CR0_PG) {
2393 svm_set_cr0(vcpu, svm->vmcb->save.cr0);
2394 mmu_reload = 1;
2395 }
2396 vcpu->arch.cr0 = svm->vmcb->save.cr0; 2386 vcpu->arch.cr0 = svm->vmcb->save.cr0;
2387 if (npt_enabled)
2397 vcpu->arch.cr3 = svm->vmcb->save.cr3; 2388 vcpu->arch.cr3 = svm->vmcb->save.cr3;
2398 if (mmu_reload) {
2399 kvm_mmu_reset_context(vcpu);
2400 kvm_mmu_load(vcpu);
2401 }
2402 }
2403
2404 2389
2405 if (svm->vmcb->control.exit_code == SVM_EXIT_ERR) { 2390 if (svm->vmcb->control.exit_code == SVM_EXIT_ERR) {
2406 kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY; 2391 kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY;