From 9baf5b9894d4e4be05e665d80fd0ebac8b621aa4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Brucker Date: Tue, 2 Jun 2020 13:13:27 +0200 Subject: [PATCH] iommu: Allow page responses without PASID Some PCIe devices do not expect a PASID value in PRI Page Responses. If the "PRG Response PASID Required" bit in the PRI capability is zero, then the OS should not set the PASID field. Similarly on Arm SMMU, responses to stall events do not have a PASID. Currently iommu_page_response() checks that the PASID in the page response corresponds to the one in the page request without first checking the "PASID valid" bit. A page response coming from a guest OS does not necessarily have a PASID, if the passed-through device does not require one. Allow page responses without PASID. The page request corresponding to a page response is identified by device and by Page Response Group Index (or stall tag). Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index e61a9fc65b7e4..e481fdfafb77c 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1296,7 +1296,8 @@ int iommu_page_response(struct device *dev, */ list_for_each_entry(evt, ¶m->fault_param->faults, list) { prm = &evt->fault.prm; - pasid_valid = prm->flags & IOMMU_FAULT_PAGE_REQUEST_PASID_VALID; + pasid_valid = prm->flags & IOMMU_FAULT_PAGE_REQUEST_PASID_VALID + && msg->flags & IOMMU_PAGE_RESP_PASID_VALID; if ((pasid_valid && prm->pasid != msg->pasid) || prm->grpid != msg->grpid) -- 2.26.2