> From: Jason Gunthorpe <jgg@xxxxxxxxxx> > Sent: Wednesday, June 8, 2022 7:17 PM > > On Wed, Jun 08, 2022 at 08:28:03AM +0000, Tian, Kevin wrote: > > > From: Nicolin Chen > > > Sent: Monday, June 6, 2022 2:19 PM > > > > > > From: Jason Gunthorpe <jgg@xxxxxxxxxx> > > > > > > The KVM mechanism for controlling wbinvd is only triggered during > > > kvm_vfio_group_add(), meaning it is a one-shot test done once the > devices > > > are setup. > > > > It's not one-shot. kvm_vfio_update_coherency() is called in both > > group_add() and group_del(). Then the coherency property is > > checked dynamically in wbinvd emulation: > > From the perspective of managing the domains that is still > one-shot. It doesn't get updated when individual devices are > added/removed to domains. It's unchanged per-domain but dynamic per-vm when multiple domains are added/removed (i.e. kvm->arch.noncoherent_dma_count). It's the latter being checked in the kvm. > > > given that I'm fine with the change in this patch. Even more probably > > we really want an explicit one-shot model so KVM can lock down > > the property once it starts to consume it then further adding a new > > group which would change the coherency is explicitly rejected and > > removing an existing group leaves it intact. > > Why? Once wbinvd is enabled it is compatible with all domain > configurations, so just leave it on and ignore everything at that > point. > More than that. My point was to make it a static policy so even if wbinvd is disabled in the start we want to leave it off and not affected by adding a device which doesn't have coherency. 'wbinvd off' is not a compatible configuration hence imo need a way to reject adding incompatible device. Thanks Kevin