On Wed, Oct 18, 2023 at 4:49 PM Si-Wei Liu <si-wei.liu@xxxxxxxxxx> wrote:Hold on, I thought earlier we all agreed upon that the existing behavior of vendor driver self-clearing maps during .reset violates the vhost iotlb abstraction and also breaks the .set_map/.dma_map API. This is 100% buggy driver implementation itself that we should discourage or eliminate as much as possible (that's part of the goal for this series), but here you seem to go existentialism and suggests the very opposite that every .set_map/.dma_map driver implementation, regardless being the current or the new/upcoming, should unconditionally try to emulate the broken reset behavior for the sake of not breaking older userspace. Set aside the criteria and definition for how userspace can be broken, can we step back to the original question why we think it's broken, and what we can do to promote good driver implementation instead of discuss the implementation details? Reading the below response I found my major points are not heard even if written for quite a few times. It's not that I don't understand the importance of not breaking old userspace, I appreciate your questions and extra patience, however I do feel the "broken" part is very relevant to our discussion here.
So the point is, not about whether the existing behavior is "broken"
On 10/18/2023 12:00 AM, Jason Wang wrote:
Please see my earlier response in the other email, thanks.Unfortunately, it's a must to stick to ABI. I agree it's a mess but weAntoher idea we can just do the following in vhost_vdpa reset?
don't have a better choice. Or we can fail the probe if userspace
doesn't ack this feature.
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
----------------%<----------------%<----------------
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.
or not.
It's about whether we could stick to the old behaviour withoutImplementation issue: this implies reset_map() has to be there for every .set_map implementations, but vendor driver implementation for custom IOMMU could well implement DMA ops by itself instead of .reset_map. This won't work for every set_map driver (think about the vduse case).
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 negotiationThere's no need to do that with the above code, or anything I missed here?
between vhost-vdpa and the parent driver. Do we want to send down the
acked_backend_features to parent drivers?
config->reset()
if (IOTLB_PERSIST is not set) {
config->reset_map()
}
Think about the vduse case, it can work with DMA ops directly so doesn't have to implement .reset_map, unless for some specific good reason. Because it's a conforming and valid/good driver implementation, we may still allow it to advertise IOTLB_PERSIST to userspace. Which belongs to the 3rd bullet below:Second, IOTLB_PERSIST is needed but not sufficient. Due to lack ofThen we just don't offer IOTLB_PRESIST, isn't this by design?
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,
This is exactly what I was afraid of that broken behavior emulation may become a dangerous slippery slope - in principle we should encourage good driver implementation, as they can work totally fine with older userspace. Why do they have to bother emulating broken behavior just because some other driver's misbehaving? And what's the boundary for this hack, do drivers backed by platform IOMMU even have to emulate (if not why not, and is there substantial difference in between)? After getting through all of this, do you still believe everything is just as easy and simple as what thought to be?
weThen you can force reset_map() with set_map() that is what I suggest
should allow these good driver implementations rather than
unconditionally stick to some specific problematic behavior for every
other good driver.
in another thread, no?
Then we need a set of device flags (backend_featuresSee above, for reset_vendor_mappings() I meant config->reset_map() exactly.
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,
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.
----------------%<----------------%<----------------