intel_iommu_accel: Add pasid bits size check
If pasid bits size is bigger than host side, host could fail to emulate all bindings in guest. Add a check to fail device plug early. Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Tested-by: Xudong Hao <xudong.hao@intel.com> Reviewed-by: Clement Mathieu--Drif <clement.mathieu--drif@bull.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260527054658.1021096-17-zhenzhong.duan@intel.com>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
4101df1201
commit
fa1ce94ea8
@@ -22,6 +22,7 @@ bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hiod,
|
||||
HostIOMMUDevice *hiod = vtd_hiod->hiod;
|
||||
struct HostIOMMUDeviceCaps *caps = &hiod->caps;
|
||||
struct iommu_hw_info_vtd *vtd = &caps->vendor_caps.vtd;
|
||||
uint8_t hpasid = VTD_ECAP_GET_PSS(vtd->ecap_reg) + 1;
|
||||
PCIBus *bus = vtd_hiod->bus;
|
||||
PCIDevice *pdev = bus->devices[vtd_hiod->devfn];
|
||||
|
||||
@@ -42,6 +43,13 @@ bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hiod,
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Only do the check when host device support PASIDs */
|
||||
if (caps->max_pasid_log2 && s->pasid > hpasid) {
|
||||
error_setg(errp, "PASID bits size %d > host IOMMU PASID bits size %d",
|
||||
s->pasid, hpasid);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pci_device_get_iommu_bus_devfn(pdev, &bus, NULL, NULL)) {
|
||||
error_setg(errp, "Host device downstream to a PCI bridge is "
|
||||
"unsupported when fsts=on");
|
||||
|
||||
@@ -196,6 +196,7 @@
|
||||
#define VTD_ECAP_SRS (1ULL << 31)
|
||||
#define VTD_ECAP_NWFS (1ULL << 33)
|
||||
#define VTD_ECAP_SET_PSS(x, v) ((x)->ecap = deposit64((x)->ecap, 35, 5, v))
|
||||
#define VTD_ECAP_GET_PSS(ecap) extract64(ecap, 35, 5)
|
||||
#define VTD_ECAP_PASID (1ULL << 40)
|
||||
#define VTD_ECAP_PDS (1ULL << 42)
|
||||
#define VTD_ECAP_SMTS (1ULL << 43)
|
||||
|
||||
Reference in New Issue
Block a user