Si-Wei Liu
2023-Oct-18 08:49 UTC
[PATCH 2/4] vhost-vdpa: reset vendor specific mapping to initial state in .release
On 10/18/2023 12:00 AM, Jason Wang wrote:>> Unfortunately, it's a must to stick to ABI. I agree it's a mess but we >> don't have a better choice. Or we can fail the probe if userspace >> doesn't ack this feature. > Antoher idea we can just do the following in vhost_vdpa reset? > > config->reset() > if (IOTLB_PERSIST is not set) { > config->reset_map() > } > > Then we don't have the burden to maintain them in the parent? > > ThanksPlease see my earlier response in the other email, thanks. ----------------%<----------------%<---------------- First, the ideal fix would be to leave this reset_vendor_mappings() emulation code on the individual driver itself, which already has the broken behavior. But today there's no backend feature negotiation between vhost-vdpa and the parent driver. Do we want to send down the acked_backend_features to parent drivers? Second, IOTLB_PERSIST is needed but not sufficient. Due to lack of backend feature negotiation in parent driver, if vhost-vdpa has to provide the old-behaviour emulation for compatibility on driver's behalf, it needs to be done per-driver basis. There could be good on-chip or vendor IOMMU implementation which doesn't clear the IOTLB in .reset, and vendor specific IOMMU doesn't have to provide .reset_map, we should allow these good driver implementations rather than unconditionally stick to some specific problematic behavior for every other good driver. Then we need a set of device flags (backend_features bit again?) to indicate the specific driver needs upper layer's help on old-behaviour emulation. Last but not least, I'm not sure how to properly emulate reset_vendor_mappings() from vhost-vdpa layer. If a vendor driver has no .reset_map op implemented, or if .reset_map has a slightly different implementation than what it used to reset the iotlb in the .reset op, then this either becomes effectively dead code if no one ends up using, or the vhost-vdpa emulation is helpless and limited in scope, unable to cover all the cases. ----------------%<----------------%<----------------
Jason Wang
2023-Oct-19 02:53 UTC
[PATCH 2/4] vhost-vdpa: reset vendor specific mapping to initial state in .release
On Wed, Oct 18, 2023 at 4:49?PM Si-Wei Liu <si-wei.liu at oracle.com> wrote:> > > > On 10/18/2023 12:00 AM, Jason Wang wrote: > >> Unfortunately, it's a must to stick to ABI. I agree it's a mess but we > >> don't have a better choice. Or we can fail the probe if userspace > >> doesn't ack this feature. > > Antoher idea we can just do the following in vhost_vdpa reset? > > > > config->reset() > > if (IOTLB_PERSIST is not set) { > > config->reset_map() > > } > > > > Then we don't have the burden to maintain them in the parent? > > > > Thanks > Please see my earlier response in the other email, thanks. > > ----------------%<----------------%<---------------- > > First, the ideal fix would be to leave this reset_vendor_mappings() > emulation code on the individual driver itself, which already has the > broken behavior.So the point is, not about whether the existing behavior is "broken" or not. It's about whether we could stick to the old behaviour without too much cost. And I believe we could. And just to clarify here, reset_vendor_mappings() = config->reset_map()> But today there's no backend feature negotiation > between vhost-vdpa and the parent driver. Do we want to send down the > acked_backend_features to parent drivers?There's no need to do that with the above code, or anything I missed here? config->reset() if (IOTLB_PERSIST is not set) { config->reset_map() }> > Second, IOTLB_PERSIST is needed but not sufficient. Due to lack of > backend feature negotiation in parent driver, if vhost-vdpa has to > provide the old-behaviour emulation for compatibility on driver's > behalf, it needs to be done per-driver basis. There could be good > on-chip or vendor IOMMU implementation which doesn't clear the IOTLB in > .reset, and vendor specific IOMMU doesn't have to provide .reset_map,Then we just don't offer IOTLB_PRESIST, isn't this by design?> we > should allow these good driver implementations rather than > unconditionally stick to some specific problematic behavior for every > other good driver.Then you can force reset_map() with set_map() that is what I suggest in another thread, no?> Then we need a set of device flags (backend_features > bit again?) to indicate the specific driver needs upper layer's help on > old-behaviour emulation. > > Last but not least, I'm not sure how to properly emulate > reset_vendor_mappings() from vhost-vdpa layer. If a vendor driver has no > .reset_map op implemented, or if .reset_map has a slightly different > implementation than what it used to reset the iotlb in the .reset op,See above, for reset_vendor_mappings() I meant config->reset_map() exactly. Thanks> then this either becomes effectively dead code if no one ends up using, > or the vhost-vdpa emulation is helpless and limited in scope, unable to > cover all the cases. > > ----------------%<----------------%<---------------- >