On Tue, Nov 16, 2021, Thomas Gleixner wrote: > > One of potential drawbacks of the Option 2 might be additional > > checks in the host, although we can minimize the impact by having > > CONFIG_KVM_TBD. We believe that the case > > "XFD != 0 and XINUSE != 0" should be very infrequent. > > I really don't like the idea of having an extra check in switch_to(). > > Can we start simple and do something like the uncompiled below and see > how much overhead it creates? > > Thanks, > > tglx > --- ... > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2686f2edb47c..9425fdbb4806 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -9576,6 +9576,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) > vcpu->arch.last_vmentry_cpu = vcpu->cpu; > vcpu->arch.last_guest_tsc = kvm_read_l1_tsc(vcpu, rdtsc()); > > + kvm_update_guest_xfd_state(); Is there a reason the XFD switch can't key off TIF_NEED_FPU_LOAD a la the other FPU stuff? I.e. piggyback this snippet in vcpu_enter_guest(): if (test_thread_flag(TIF_NEED_FPU_LOAD)) switch_fpu_return(); > + > vcpu->mode = OUTSIDE_GUEST_MODE; > smp_wmb(); > > >