Message ID | 20240507092043.1172717-5-zhenzhong.duan@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add a host IOMMU device abstraction to check with vIOMMU | expand |
On 5/7/24 11:20, Zhenzhong Duan wrote: > TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO represents a host IOMMU device under > VFIO iommufd backend. It will be created during VFIO device attaching > and passed to vIOMMU. > > It will have its own .realize() implementation. > > Suggested-by: Cédric Le Goater <clg@redhat.com> > Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> > --- > include/hw/vfio/vfio-common.h | 3 +++ > hw/vfio/iommufd.c | 5 ++++- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h > index 05a199ce65..affb73f209 100644 > --- a/include/hw/vfio/vfio-common.h > +++ b/include/hw/vfio/vfio-common.h > @@ -32,6 +32,7 @@ > #include "sysemu/sysemu.h" > #include "hw/vfio/vfio-container-base.h" > #include "sysemu/host_iommu_device.h" > +#include "sysemu/iommufd.h" I don't think you need this include. Thanks, C. > > #define VFIO_MSG_PREFIX "vfio %s: " > > @@ -149,6 +150,8 @@ typedef struct VFIOGroup { > } VFIOGroup; > > #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" > +#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ > + TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" > > typedef struct VFIODMABuf { > QemuDmaBuf buf; > diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c > index 554f9a6292..e4a507d55c 100644 > --- a/hw/vfio/iommufd.c > +++ b/hw/vfio/iommufd.c > @@ -624,7 +624,10 @@ static const TypeInfo types[] = { > .name = TYPE_VFIO_IOMMU_IOMMUFD, > .parent = TYPE_VFIO_IOMMU, > .class_init = vfio_iommu_iommufd_class_init, > - }, > + }, { > + .name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO, > + .parent = TYPE_HOST_IOMMU_DEVICE_IOMMUFD, > + } > }; > > DEFINE_TYPES(types)
>-----Original Message----- >From: Cédric Le Goater <clg@redhat.com> >Subject: Re: [PATCH v4 04/19] vfio/iommufd: Introduce >TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO device > >On 5/7/24 11:20, Zhenzhong Duan wrote: >> TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO represents a host IOMMU >device under >> VFIO iommufd backend. It will be created during VFIO device attaching >> and passed to vIOMMU. >> >> It will have its own .realize() implementation. >> >> Suggested-by: Cédric Le Goater <clg@redhat.com> >> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> >> --- >> include/hw/vfio/vfio-common.h | 3 +++ >> hw/vfio/iommufd.c | 5 ++++- >> 2 files changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio- >common.h >> index 05a199ce65..affb73f209 100644 >> --- a/include/hw/vfio/vfio-common.h >> +++ b/include/hw/vfio/vfio-common.h >> @@ -32,6 +32,7 @@ >> #include "sysemu/sysemu.h" >> #include "hw/vfio/vfio-container-base.h" >> #include "sysemu/host_iommu_device.h" >> +#include "sysemu/iommufd.h" > >I don't think you need this include. Yes, maybe not now. TYPE_HOST_IOMMU_DEVICE_IOMMUFD is needed: #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" it can be replaced with: #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ TYPE_HOST_IOMMU_DEVICE "-iommufd-vfio" But the main usage is in nesting series. Below structure references HostIOMMUDeviceIOMMUFD which is in sysemu/iommufd.h struct HostIOMMUDeviceIOMMUFDVFIO { HostIOMMUDeviceIOMMUFD parent_obj; VFIODevice *vdev; }; Thanks Zhenzhong
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 05a199ce65..affb73f209 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -32,6 +32,7 @@ #include "sysemu/sysemu.h" #include "hw/vfio/vfio-container-base.h" #include "sysemu/host_iommu_device.h" +#include "sysemu/iommufd.h" #define VFIO_MSG_PREFIX "vfio %s: " @@ -149,6 +150,8 @@ typedef struct VFIOGroup { } VFIOGroup; #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" +#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \ + TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" typedef struct VFIODMABuf { QemuDmaBuf buf; diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 554f9a6292..e4a507d55c 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -624,7 +624,10 @@ static const TypeInfo types[] = { .name = TYPE_VFIO_IOMMU_IOMMUFD, .parent = TYPE_VFIO_IOMMU, .class_init = vfio_iommu_iommufd_class_init, - }, + }, { + .name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO, + .parent = TYPE_HOST_IOMMU_DEVICE_IOMMUFD, + } }; DEFINE_TYPES(types)
TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO represents a host IOMMU device under VFIO iommufd backend. It will be created during VFIO device attaching and passed to vIOMMU. It will have its own .realize() implementation. Suggested-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> --- include/hw/vfio/vfio-common.h | 3 +++ hw/vfio/iommufd.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-)