Avi Kivity wrote: > Anthony Liguori wrote: >> Author: Anthony Liguori >> Date: Sun Apr 22 20:34:03 2007 -0500 >> >> Lazy FPU support for SVM. >> Signed-off-by: Anthony Liguori >> >> diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h >> index d1a90c5..4859c32 100644 >> --- a/drivers/kvm/kvm.h >> +++ b/drivers/kvm/kvm.h >> @@ -63,6 +63,9 @@ >> #define FX_BUF_SIZE (2 * FX_IMAGE_SIZE + FX_IMAGE_ALIGN) >> >> #define DE_VECTOR 0 >> +#define DB_VECTOR 2 >> +#define UD_VECTOR 6 >> +#define NM_VECTOR 7 >> > > This, while a nice cleanup, is unrelated. I had to add the NM_VECTOR so I moved the others too. Attached is a patch that doesn't move those. I noticed that the #define's in general need some love. There's quite a lot in kvm.h that's specific to vmx and there's a bit of asymmetry between vmx and svm (svm has kvm_svm.h, vmx used to but it was removed recently). There's also a ton of unused #define's (quite a few that are typos). I was planning on submitting a cleanup patch series today so I'll just fold the above changes into that. >> >> +static int nm_interception(struct kvm_vcpu *vcpu, struct kvm_run >> *kvm_run) >> +{ >> + spin_lock(&vcpu->kvm->lock); >> > > Why is the lock needed? everything below is vcpu-local AFAICS. You're right, removed in attached patch. >> @@ -1664,6 +1685,12 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu, >> unsigned long root) >> { >> vcpu->svm->vmcb->save.cr3 = root; >> force_new_asid(vcpu); >> + + if (vcpu->fpu_active) { >> + vcpu->svm->vmcb->control.intercept_exceptions |= (1 << >> NM_VECTOR); >> + vcpu->svm->vmcb->save.cr0 |= CR0_TS_MASK; >> + vcpu->fpu_active = 0; >> + } >> } >> >> static void svm_inject_page_fault(struct kvm_vcpu *vcpu, >> > > Any numbers? I use user/test/vmexit.c to test as it gives the highest > relative speedup. Hard to say exactly because of the noise. I did two runs of 4 test/vmexit: Before 4091, 4194, 4559, 4439 After: 3979, 4324, 3918, 3910 So there's definitely a speedup, but probably only 100-200 cycles. Regards, Anthony Liguori