Re: [PATCH 4/5] KVM: Lazify fpu activation and deactivation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/06/2010 05:18 AM, Avi Kivity wrote:
+static void svm_fpu_deactivate(struct kvm_vcpu *vcpu)
+{
+    struct vcpu_svm *svm = to_svm(vcpu);
+
+    if (npt_enabled) {
+        /* hack: npt requires active fpu at this time */
+        vcpu->fpu_active = 1;
+        return;
+    }
Why is that ?

A guest context switch will involve setting cr0.ts and possibly issuing clts after the fpu is first used:

  _switch_to()
     unlazy_fpu()
        stts()

So we will get an exit on cr0 writes on every guest context switch until the fpu is loaded. vmx avoids this by allowing writes that don't change important bits to proceed.

Hmm, I see the write is conditional, so it may not be as bad as that. We'll have to test other guests to make sure they all do conditional stts().

It can be done. If we see a cr0 write that doesn't change cr0, we can assume it's an stts(), load the guest fpu, and turn on selective cr0 intercepts. So the net effect will be:

- guests which only stts() when cr0.ts is clear will behave much like vmx
- guests which stts() unconditionally will see one extra exit and then load the fpu, like current behaviour

The only tricky bit is guests with cr0.wp=0 when npt is disabled, we have to keep cr0 intercepts there. But that's fine.

I'll write a patch.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux