On Mon, Jan 16, 2023 at 11:16:04AM +0000, "Huang, Kai" <kai.huang@xxxxxxxxx> wrote: > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > > index 6111e3e9266d..dffacb7eb15a 100644 > > --- a/arch/x86/kvm/mmu/tdp_mmu.c > > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > > @@ -19,6 +19,14 @@ int kvm_mmu_init_tdp_mmu(struct kvm *kvm) > > { > > struct workqueue_struct *wq; > > > > + /* > > + * TDs require mmio_caching to clear suppress_ve bit of SPTE for GPA > > + * of MMIO so that TD can convert #VE triggered by MMIO into > > + * TDG.VP.VMCALL<MMIO>. > > + */ > > + if (kvm->arch.vm_type == KVM_X86_TDX_VM && !enable_mmio_caching) > > + return -EOPNOTSUPP; > > SEV-ES does the check in hardware_setup: > > void __init sev_hardware_setup(void) > { > ... > /* > * SEV-ES requires MMIO caching as KVM doesn't have access to the guest > * instruction stream, i.e. can't emulate in response to a #NPF and > * instead relies on #NPF(RSVD) being reflected into the guest as #VC > * (the guest can then do a #VMGEXIT to request MMIO emulation). > */ > if (!enable_mmio_caching) > goto out; > > ... > } > > TDX should be done in the same way. > > And IMO this chunk really doesn't belong to this patch -- I interpret this patch > as a "infrastructure patch to track shadow MMIO value on per-VM basis" (which > even should have no functional change IMHO), but this chunk is clearly doing > more than that. It's cleaner to do in hardware_setup(). So I moved the logic into hardware_setup() and an independent patch. -- Isaku Yamahata <isaku.yamahata@xxxxxxxxx>