vdpa_sim: implement .reset_map support
authorSi-Wei Liu <si-wei.liu@oracle.com>
Sat, 21 Oct 2023 09:25:19 +0000 (02:25 -0700)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 1 Nov 2023 13:20:00 +0000 (09:20 -0400)
commit86f6c224c97911b4392cb7b402e6a4ed323a449e
tree8e390d759719a35753e486accf0480511e08eb80
parent2eacf4b5e3ebe771f0fca0c8913c5a10a1953b72
vdpa_sim: implement .reset_map support

In order to reduce excessive memory mapping cost in live migration and
VM reboot, it is desirable to decouple the vhost-vdpa IOTLB abstraction
from the virtio device life cycle, i.e. mappings can be kept intact
across virtio device reset. Leverage the .reset_map callback, which is
meant to destroy the iotlb on the given ASID and recreate the 1:1
passthrough/identity mapping. To be consistent, the mapping on device
creation is initiailized to passthrough/identity with PA 1:1 mapped as
IOVA. With this the device .reset op doesn't have to maintain and clean
up memory mappings by itself.

Additionally, implement .compat_reset to cater for older userspace,
which may wish to see mapping to be cleared during reset.

Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Tested-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <1697880319-4937-8-git-send-email-si-wei.liu@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Lei Yang <leiyang@redhat.com>
drivers/vdpa/vdpa_sim/vdpa_sim.c