On 2020/2/5 ??10:05, Tiwei Bie wrote:> On Tue, Feb 04, 2020 at 02:46:16PM +0800, Jason Wang wrote: >> On 2020/2/4 ??2:01, Michael S. Tsirkin wrote: >>> On Tue, Feb 04, 2020 at 11:30:11AM +0800, Jason Wang wrote: >>>> 5) generate diffs of memory table and using IOMMU API to setup the dma >>>> mapping in this method >>> Frankly I think that's a bunch of work. Why not a MAP/UNMAP interface? >>> >> Sure, so that basically VHOST_IOTLB_UPDATE/INVALIDATE I think? > Do you mean we let userspace to only use VHOST_IOTLB_UPDATE/INVALIDATE > to do the DMA mapping in vhost-vdpa case? When vIOMMU isn't available, > userspace will set msg->iova to GPA, otherwise userspace will set > msg->iova to GIOVA, and vhost-vdpa module will get HPA from msg->uaddr? > > Thanks, > TiweiI think so. Michael, do you think this makes sense? Thanks> >> Thanks >> >>
On Wed, Feb 05, 2020 at 11:12:21AM +0800, Jason Wang wrote:> > On 2020/2/5 ??10:05, Tiwei Bie wrote: > > On Tue, Feb 04, 2020 at 02:46:16PM +0800, Jason Wang wrote: > > > On 2020/2/4 ??2:01, Michael S. Tsirkin wrote: > > > > On Tue, Feb 04, 2020 at 11:30:11AM +0800, Jason Wang wrote: > > > > > 5) generate diffs of memory table and using IOMMU API to setup the dma > > > > > mapping in this method > > > > Frankly I think that's a bunch of work. Why not a MAP/UNMAP interface? > > > > > > > Sure, so that basically VHOST_IOTLB_UPDATE/INVALIDATE I think? > > Do you mean we let userspace to only use VHOST_IOTLB_UPDATE/INVALIDATE > > to do the DMA mapping in vhost-vdpa case? When vIOMMU isn't available, > > userspace will set msg->iova to GPA, otherwise userspace will set > > msg->iova to GIOVA, and vhost-vdpa module will get HPA from msg->uaddr? > > > > Thanks, > > Tiwei > > > I think so. Michael, do you think this makes sense? > > Thanksto make sure, could you post the suggested argument format for these ioctls?> > > > > > Thanks > > > > > >
On 2020/2/5 ??1:31, Michael S. Tsirkin wrote:> On Wed, Feb 05, 2020 at 11:12:21AM +0800, Jason Wang wrote: >> On 2020/2/5 ??10:05, Tiwei Bie wrote: >>> On Tue, Feb 04, 2020 at 02:46:16PM +0800, Jason Wang wrote: >>>> On 2020/2/4 ??2:01, Michael S. Tsirkin wrote: >>>>> On Tue, Feb 04, 2020 at 11:30:11AM +0800, Jason Wang wrote: >>>>>> 5) generate diffs of memory table and using IOMMU API to setup the dma >>>>>> mapping in this method >>>>> Frankly I think that's a bunch of work. Why not a MAP/UNMAP interface? >>>>> >>>> Sure, so that basically VHOST_IOTLB_UPDATE/INVALIDATE I think? >>> Do you mean we let userspace to only use VHOST_IOTLB_UPDATE/INVALIDATE >>> to do the DMA mapping in vhost-vdpa case? When vIOMMU isn't available, >>> userspace will set msg->iova to GPA, otherwise userspace will set >>> msg->iova to GIOVA, and vhost-vdpa module will get HPA from msg->uaddr? >>> >>> Thanks, >>> Tiwei >> I think so. Michael, do you think this makes sense? >> >> Thanks > to make sure, could you post the suggested argument format for > these ioctls? >It's the existed uapi: /* no alignment requirement */ struct vhost_iotlb_msg { ??? __u64 iova; ??? __u64 size; ??? __u64 uaddr; #define VHOST_ACCESS_RO????? 0x1 #define VHOST_ACCESS_WO????? 0x2 #define VHOST_ACCESS_RW????? 0x3 ??? __u8 perm; #define VHOST_IOTLB_MISS?????????? 1 #define VHOST_IOTLB_UPDATE???????? 2 #define VHOST_IOTLB_INVALIDATE???? 3 #define VHOST_IOTLB_ACCESS_FAIL??? 4 ??? __u8 type; }; #define VHOST_IOTLB_MSG 0x1 #define VHOST_IOTLB_MSG_V2 0x2 struct vhost_msg { ??? int type; ??? union { ??? ??? struct vhost_iotlb_msg iotlb; ??? ??? __u8 padding[64]; ??? }; }; struct vhost_msg_v2 { ??? __u32 type; ??? __u32 reserved; ??? union { ??? ??? struct vhost_iotlb_msg iotlb; ??? ??? __u8 padding[64]; ??? }; };