On Tue, Jun 11, 2024 at 3:18 PM Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx> wrote: > >> } > >> > >> diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c > >> index ed46e7e57c18..4f3b872cd401 100644 > >> --- a/arch/x86/kvm/vmx/main.c > >> +++ b/arch/x86/kvm/vmx/main.c > >> @@ -283,6 +283,43 @@ static void vt_msr_filter_changed(struct kvm_vcpu *vcpu) > >> vmx_msr_filter_changed(vcpu); > >> } > >> > >> +#ifdef CONFIG_KVM_SMM > >> +static int vt_smi_allowed(struct kvm_vcpu *vcpu, bool for_injection) > >> +{ > >> + if (is_td_vcpu(vcpu)) > >> + return tdx_smi_allowed(vcpu, for_injection); > > Adding stubs for something that TDX will never support is silly. Bug the VM and > > return an error. > > > > if (KVM_BUG_ON(is_td_vcpu(vcpu))) > > return -EIO; > > is_td_vcpu() is defined in tdx.h. > Do you mind using open code to check whether the VM is TD in vmx.c? > "vcpu->kvm->arch.vm_type == KVM_X86_TDX_VM" I'd move it to some place that main.c can see. Or vmx.c as Sean says below, but I am not sure I like the idea too much. Paolo > > And I wouldn't even bother with vt_* wrappers, just put that right in vmx_*(). > > Same thing for everything below. If it's a KVM_BUG_ON()