Re: [PATCH 2/4] vhost-vdpa: reset vendor specific mapping to initial state in .release

From: Si-Wei Liu
Date: Wed Oct 18 2023 - 04:49:53 EST




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. 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.

----------------%<----------------%<----------------