mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 11:04:58 -06:00
vfio/iommufd: Save vendor specific device info
Some device information returned by ioctl(IOMMU_GET_HW_INFO) are vendor specific. Save them as raw data in a union supporting different vendors, then vendor IOMMU can query the raw data with its fixed format for capability directly. Because IOMMU_GET_HW_INFO is only supported in linux, so declare those capability related structures with CONFIG_LINUX. Suggested-by: Eric Auger <eric.auger@redhat.com> Suggested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Link: https://lore.kernel.org/qemu-devel/20250604062115.4004200-5-zhenzhong.duan@intel.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
e50a3ead97
commit
1ab3d93fd2
2 changed files with 18 additions and 5 deletions
|
@ -839,16 +839,14 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
|
||||||
VFIODevice *vdev = opaque;
|
VFIODevice *vdev = opaque;
|
||||||
HostIOMMUDeviceIOMMUFD *idev;
|
HostIOMMUDeviceIOMMUFD *idev;
|
||||||
HostIOMMUDeviceCaps *caps = &hiod->caps;
|
HostIOMMUDeviceCaps *caps = &hiod->caps;
|
||||||
|
VendorCaps *vendor_caps = &caps->vendor_caps;
|
||||||
enum iommu_hw_info_type type;
|
enum iommu_hw_info_type type;
|
||||||
union {
|
|
||||||
struct iommu_hw_info_vtd vtd;
|
|
||||||
} data;
|
|
||||||
uint64_t hw_caps;
|
uint64_t hw_caps;
|
||||||
|
|
||||||
hiod->agent = opaque;
|
hiod->agent = opaque;
|
||||||
|
|
||||||
if (!iommufd_backend_get_device_info(vdev->iommufd, vdev->devid,
|
if (!iommufd_backend_get_device_info(vdev->iommufd, vdev->devid, &type,
|
||||||
&type, &data, sizeof(data),
|
vendor_caps, sizeof(*vendor_caps),
|
||||||
&hw_caps, errp)) {
|
&hw_caps, errp)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,13 @@
|
||||||
|
|
||||||
#include "qom/object.h"
|
#include "qom/object.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
#ifdef CONFIG_LINUX
|
||||||
|
#include "linux/iommufd.h"
|
||||||
|
|
||||||
|
typedef union VendorCaps {
|
||||||
|
struct iommu_hw_info_vtd vtd;
|
||||||
|
struct iommu_hw_info_arm_smmuv3 smmuv3;
|
||||||
|
} VendorCaps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct HostIOMMUDeviceCaps - Define host IOMMU device capabilities.
|
* struct HostIOMMUDeviceCaps - Define host IOMMU device capabilities.
|
||||||
|
@ -22,11 +29,17 @@
|
||||||
*
|
*
|
||||||
* @hw_caps: host platform IOMMU capabilities (e.g. on IOMMUFD this represents
|
* @hw_caps: host platform IOMMU capabilities (e.g. on IOMMUFD this represents
|
||||||
* the @out_capabilities value returned from IOMMU_GET_HW_INFO ioctl)
|
* the @out_capabilities value returned from IOMMU_GET_HW_INFO ioctl)
|
||||||
|
*
|
||||||
|
* @vendor_caps: host platform IOMMU vendor specific capabilities (e.g. on
|
||||||
|
* IOMMUFD this represents a user-space buffer filled by kernel
|
||||||
|
* with host IOMMU @type specific hardware information data)
|
||||||
*/
|
*/
|
||||||
typedef struct HostIOMMUDeviceCaps {
|
typedef struct HostIOMMUDeviceCaps {
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
uint64_t hw_caps;
|
uint64_t hw_caps;
|
||||||
|
VendorCaps vendor_caps;
|
||||||
} HostIOMMUDeviceCaps;
|
} HostIOMMUDeviceCaps;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TYPE_HOST_IOMMU_DEVICE "host-iommu-device"
|
#define TYPE_HOST_IOMMU_DEVICE "host-iommu-device"
|
||||||
OBJECT_DECLARE_TYPE(HostIOMMUDevice, HostIOMMUDeviceClass, HOST_IOMMU_DEVICE)
|
OBJECT_DECLARE_TYPE(HostIOMMUDevice, HostIOMMUDeviceClass, HOST_IOMMU_DEVICE)
|
||||||
|
@ -38,7 +51,9 @@ struct HostIOMMUDevice {
|
||||||
void *agent; /* pointer to agent device, ie. VFIO or VDPA device */
|
void *agent; /* pointer to agent device, ie. VFIO or VDPA device */
|
||||||
PCIBus *aliased_bus;
|
PCIBus *aliased_bus;
|
||||||
int aliased_devfn;
|
int aliased_devfn;
|
||||||
|
#ifdef CONFIG_LINUX
|
||||||
HostIOMMUDeviceCaps caps;
|
HostIOMMUDeviceCaps caps;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue