Message ID | 9852ad79d1078088743a57008226c869b0316da1.1637799475.git.isaku.yamahata@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: X86: TDX support | expand |
On 11/25/21 01:20, isaku.yamahata@intel.com wrote: > From: Sean Christopherson<sean.j.christopherson@intel.com> > > Return true for kvm_vcpu_has_events() if the vCPU has a pending APICv > interrupt to support TDX's usage of APICv. Unlike VMX, TDX doesn't have > access to vmcs.GUEST_INTR_STATUS and so can't emulate posted interrupts, > i.e. needs to generate a posted interrupt and more importantly can't > manually move requested interrupts into the vIRR (which it also doesn't > have access to). Does this mean it is impossible to disable APICv on TDX? If so, please add a WARN. Paolo
On Thu, Nov 25, 2021, Paolo Bonzini wrote: > On 11/25/21 01:20, isaku.yamahata@intel.com wrote: > > From: Sean Christopherson<sean.j.christopherson@intel.com> > > > > Return true for kvm_vcpu_has_events() if the vCPU has a pending APICv > > interrupt to support TDX's usage of APICv. Unlike VMX, TDX doesn't have > > access to vmcs.GUEST_INTR_STATUS and so can't emulate posted interrupts, > > i.e. needs to generate a posted interrupt and more importantly can't > > manually move requested interrupts into the vIRR (which it also doesn't > > have access to). > > Does this mean it is impossible to disable APICv on TDX? If so, please add > a WARN. Yes, APICv is forced. Rereading this patch, checking only for a pending posted interrupt isn't correct, a pending interrupt that's below the PPR shouldn't be considered a wake event. A much better approach would be to have vt_sync_pir_to_irr() redirect to a TDX implementation to read the PIR but not update the vIRR, that way common x86 doesn't need to be touched. Hopefully that can be done in a race-free way.
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8161475082a7..c6e56f105673 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11914,7 +11914,9 @@ static inline bool kvm_vcpu_has_events(struct kvm_vcpu *vcpu) if (kvm_arch_interrupt_allowed(vcpu) && (kvm_cpu_has_interrupt(vcpu) || - kvm_guest_apic_has_interrupt(vcpu))) + kvm_guest_apic_has_interrupt(vcpu) || + (vcpu->arch.apicv_active && + kvm_x86_ops.dy_apicv_has_pending_interrupt(vcpu)))) return true; if (kvm_hv_has_stimer_pending(vcpu))