Re: [PATCH v10 104/108] KVM: TDX: Silently ignore INIT/SIPI

Isaku Yamahata
2022-12-16T03:50:36Z

On Wed, Nov 23, 2022 at 11:17:44PM +0800,
Binbin Wu <binbin.wu@linux.intel.com> wrote:

> > diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c
> > index 4acba8d8cb27..d776d5d169d0 100644
> > --- a/arch/x86/kvm/vmx/main.c
> > +++ b/arch/x86/kvm/vmx/main.c
> > @@ -286,6 +286,25 @@ static void vt_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode,
> > vmx_deliver_interrupt(apic, delivery_mode, trig_mode, vector);
> > }
> > +static void vt_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
> > +{
> > + if (is_td_vcpu(vcpu))
> > + return;
> > +
> > + kvm_vcpu_deliver_sipi_vector(vcpu, vector);
> > +}
> > +
> > +static void vt_vcpu_deliver_init(struct kvm_vcpu *vcpu)
> > +{
> > + if (is_td_vcpu(vcpu)) {
> > + /* TDX doesn't support INIT. Ignore INIT event */
> > + vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
> > + return;
> > + }
> > +
> > + kvm_vcpu_deliver_init(vcpu);
> > +}
> > +
>
> Is it better to add WARN_ON_ONCE in the above two functions for TD case?

No because KVM_SET_VCPU_EVENTS ioctl can trigger those callback.

--
Isaku Yamahata <isaku.yamahata@gmail.com>