From: Vasant Hegde <vasant.hegde@amd.com>
To: <iommu@lists.linux.dev>, <joro@8bytes.org>
Cc: <will@kernel.org>, <robin.murphy@arm.com>,
<suravee.suthikulpanit@amd.com>,
Vasant Hegde <vasant.hegde@amd.com>,
Gaultier Delbarre <Gaultier.Delbarre@amd.com>,
Wei Huang <wei.huang2@amd.com>
Subject: [PATCH 3/5] iommu/amd: Fix missing CMD_COMPLETE_PPR response for invalid PPR requests
Date: Mon, 27 Jul 2026 05:39:05 +0000 [thread overview]
Message-ID: <20260727053907.7622-4-vasant.hegde@amd.com> (raw)
In-Reply-To: <20260727053907.7622-1-vasant.hegde@amd.com>
The AMD IOMMU spec, requires the host to respond with a CMD_COMPLETE_PPR
command when an EVENT_TYPE_INV_PPR_REQ event is received with the RX bit
cleared. This response was missing in the current implementation, leaving
invalid PPR requests unacknowledged.
Introduce amd_iommu_report_ppr_err() to handle EVENT_TYPE_INV_PPR_REQ
events. The new function logs the invalid PPR request and when the RX
bit is cleared, sends CMD_COMPLETE_PPR response.
Reported-by: Gaultier Delbarre <Gaultier.Delbarre@amd.com>
Co-developed-by: Wei Huang <wei.huang2@amd.com>
Signed-off-by: Wei Huang <wei.huang2@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
---
drivers/iommu/amd/amd_iommu_types.h | 1 +
drivers/iommu/amd/iommu.c | 38 ++++++++++++++++++++++++-----
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
index a7aa9411b2e9..500952e752b4 100644
--- a/drivers/iommu/amd/amd_iommu_types.h
+++ b/drivers/iommu/amd/amd_iommu_types.h
@@ -159,6 +159,7 @@
#define EVENT_FLAGS_SHIFT 0x10
#define EVENT_FLAG_RW 0x020
#define EVENT_FLAG_I 0x008
+#define EVENT_FLAG_PPR_RX 0x001
/* feature control bits */
#define CONTROL_IOMMU_EN 0
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 563f9c2672d5..4372d3908e67 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -905,10 +905,40 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu,
pci_dev_put(pdev);
}
+static void amd_iommu_report_ppr_err(struct amd_iommu *iommu, volatile u32 *event,
+ u16 devid, u64 address, int flags)
+{
+ struct pci_dev *pdev;
+ struct device *dev = iommu->iommu.dev;
+ u32 pasid = PPR_PASID(*((u64 *)event));
+ int tag = event[1] & 0x03FF;
+
+ dev_err(dev, "Event logged [INVALID_PPR_REQUEST device=%04x:%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x tag=0x%03x]\n",
+ iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
+ pasid, address, flags, tag);
+
+ /* Skip COMPLETE_PPR_REQUEST response if RX=1 */
+ if (flags & EVENT_FLAG_PPR_RX)
+ return;
+
+ pdev = pci_get_domain_bus_and_slot(iommu->pci_seg->id, PCI_BUS_NUM(devid),
+ devid & 0xff);
+ if (!pdev)
+ return;
+
+ if (!dev_iommu_priv_get(&pdev->dev)) {
+ pci_dev_put(pdev);
+ return;
+ }
+
+ amd_iommu_complete_ppr(&pdev->dev, pasid, IOMMU_PAGE_RESP_FAILURE, tag);
+ pci_dev_put(pdev);
+}
+
static void iommu_print_event(struct amd_iommu *iommu, void *__evt)
{
struct device *dev = iommu->iommu.dev;
- int type, devid, flags, tag;
+ int type, devid, flags;
volatile u32 *event = __evt;
int count = 0;
u64 address, ctrl;
@@ -982,11 +1012,7 @@ static void iommu_print_event(struct amd_iommu *iommu, void *__evt)
amd_iommu_report_rmp_hw_error(iommu, event);
break;
case EVENT_TYPE_INV_PPR_REQ:
- pasid = PPR_PASID(*((u64 *)__evt));
- tag = event[1] & 0x03FF;
- dev_err(dev, "Event logged [INVALID_PPR_REQUEST device=%04x:%02x:%02x.%x pasid=0x%05x address=0x%llx flags=0x%04x tag=0x%03x]\n",
- iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid), PCI_FUNC(devid),
- pasid, address, flags, tag);
+ amd_iommu_report_ppr_err(iommu, event, devid, address, flags);
break;
default:
dev_err(dev, "Event logged [UNKNOWN event[0]=0x%08x event[1]=0x%08x event[2]=0x%08x event[3]=0x%08x\n",
--
2.31.1
next prev parent reply other threads:[~2026-07-27 5:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 5:39 [PATCH 0/5] iommu/amd: PRI related cleanup and fixes Vasant Hegde
2026-07-27 5:39 ` [PATCH 1/5] iommu/amd: Fix incorrect device ID in invalid PASID error message Vasant Hegde
2026-07-27 5:39 ` [PATCH 2/5] iommu/amd: Introduce PPR_TAG_LAST_PAGE() macro Vasant Hegde
2026-07-27 5:39 ` Vasant Hegde [this message]
2026-07-28 6:32 ` [PATCH 3/5] iommu/amd: Fix missing CMD_COMPLETE_PPR response for invalid PPR requests Ankit Soni
2026-07-30 11:32 ` Vasant Hegde
2026-07-27 5:39 ` [PATCH 4/5] iommu/amd: Rate limit INVALID_PPR_REQUEST error logging Vasant Hegde
2026-07-27 5:39 ` [PATCH 5/5] iommu/amd: Fix GN bit setting in COMPLETE_PPR_REQUEST command Vasant Hegde
2026-07-30 14:44 ` [PATCH 0/5] iommu/amd: PRI related cleanup and fixes Ankit Soni
2026-08-10 7:55 ` Jörg Rödel
2026-08-11 4:13 ` Vasant Hegde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260727053907.7622-4-vasant.hegde@amd.com \
--to=vasant.hegde@amd.com \
--cc=Gaultier.Delbarre@amd.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=wei.huang2@amd.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.