vdpa_sim: do not reset IOTLB during device reset
PATCH 1/1 vdpa_sim: do not reset IOTLB during device reset
We reset IOTLB during device reset this breaks the assumption that the mapping needs to be controlled via vDPA DMA ops explicitly in a incremental way. So the networking will be broken after e.g a guest reset.
Fix this by not resetting the IOTLB during device reset.
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 -- 1 file changed, 2 deletions(-)
drivers/vdpa/vdpa_sim/vdpa_sim.c +0 -2
@@ -119,8 +119,6 @@ static void vdpasim_reset(struct vdpasim *vdpasim)for (i =0 ; i <VDPASIM_VQ_NUM ; i++)vdpasim_vq_reset (&vdpasim->vqs[i]); -vhost_iotlb_reset (vdpasim->iommu); - vdpasim->features =0 ; vdpasim->status =0 ; ++vdpasim->generation;
Signature · 1 line
2.20.1
Michael S. Tsirkin
maintainerQuoted 8 lines · Jason Wang
We reset IOTLB during device reset this breaks the assumption that the mapping needs to be controlled via vDPA DMA ops explicitly in a incremental way. So the networking will be broken after e.g a guest reset.
Fix this by not resetting the IOTLB during device reset.
Signed-off-by Jason Wang <[email protected]>
That's a bit weird, and can be a security risk if state leaks between security domains through this. And there's 0 chance any hardware implementation can keep the translations around across resets - there is simply nowhere to keep them.
IMHO we need a different way to make this work, simulator needs to look like a hardware device as much as possible.
Quoted 19 lines
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 -- 1 file changed, 2 deletions(-)drivers/vdpa/vdpa_sim/vdpa_sim.c +0
-2@@ -119,8 +119,6 @@ static void vdpasim_reset(struct vdpasim *vdpasim)for (i =0 ; i <VDPASIM_VQ_NUM ; i++)vdpasim_vq_reset (&vdpasim->vqs[i]); -vhost_iotlb_reset (vdpasim->iommu); - vdpasim->features =0 ; vdpasim->status =0 ; ++vdpasim->generation;Signature · 1 line
2.20.1
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang
We reset IOTLB during device reset this breaks the assumption that the mapping needs to be controlled via vDPA DMA ops explicitly in a incremental way. So the networking will be broken after e.g a guest reset.
Quoted 6 lines
Quoted 3 lines
Fix this by not resetting the IOTLB during device reset.
Signed-off-by Jason Wang <[email protected]>That's a bit weird, and can be a security risk if state leaks between security domains through this.
I'm not sure I get this. Note that:
1) For devices that depend on platform IOMMU, the mappings are valid across device reset
2) vhost_vdpa will reset IOTLB during release, so I think there's no security leak in this case
If we reset IOTLB during device reset, there will be an inconsistency between on-chip IOMMU devices and platform IOMMU devices. We can fix this inconsistency in another way, e.g unmap during vhost_vdpa_reset. This means userspace need to replay the mapping before DRIVER_OK, which seems a burden to userspace.
Quoted 3 lines
And there's 0 chance any hardware implementation can keep the translations around across resets - there is simply nowhere to keep them.
It depends on the hardware implementation, e.g the IOMMU does not belong to VF but PF.
Thanks
Quoted 24 lines
IMHO we need a different way to make this work, simulator needs to look like a hardware device as much as possible.
Quoted 19 lines
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 -- 1 file changed, 2 deletions(-)drivers/vdpa/vdpa_sim/vdpa_sim.c +0
-2@@ -119,8 +119,6 @@ static void vdpasim_reset(struct vdpasim *vdpasim)for (i =0 ; i <VDPASIM_VQ_NUM ; i++)vdpasim_vq_reset (&vdpasim->vqs[i]); -vhost_iotlb_reset (vdpasim->iommu); - vdpasim->features =0 ; vdpasim->status =0 ; ++vdpasim->generation;Signature · 1 line
2.20.1