Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.193.71 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796378677; b=e4aW01JPHSC59jPRcVf+oVpIY0MZIV1XreU9BfkeN0sCq6JFarzZjDSZb7Tu2zZuBbG+ ba7bYOVLW+jwmEkPBAd5wg/D/DVqpX4q0ma3SnP8jt5BnMktoFsJ8EYFclLcgNtplW30L fYYB/BxXamLZowiMx6K07A5B5umX3M8g0/sHe6uVUIOoD52RoY1wpZD3Y0lMbwHcDuClY oLeXXM318QBWu9bacCozqTpas2e+TWj21q9OSVBU+ehQhH4NB5s7ipy5yi+35CyVk50eW Y7k7QxT2VNiRzNj04YXAmeu8OSUwAC1Iq/yqVov/guv+9dXM8sbq3ldq5NQ1XejHyOg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796378677; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=QZDBX2GDNF1LL9F7cVoaH5ZJnyYnTo3Md6NNCUW+zfY=; b=U6K/o4MkZFnbbRe/sioQHY4mJsKCWY1pIedc9vyMRs5MxdGg3P92Jsy4xn9wL6GrRw7E tgmvmoFPjRExNjZR6smUiBRNVgCZI9GqjPqK5QIreP3s9oskzBfSHOVPTbvGuDs3k+HGy Er5jdV4xc8tLdntNzwyEb2NUQ+qKkZGKVLTW0H6WI0v5ARtBxwgHGWM9N2ecjWnHHpZ8x DT2DD2eDnsCqKmonu74sV/9bV23FIPfQ2XBjmzu7mH/2BUMixsw3kvCh51Ur05HRQzF9J BfAEvkmlnETLFsRdtpro4+JEGW06HA8LzsTyJ0kSzxDgv12L2iYP2uQc2jPlUYPq6cA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=tmYwAO9v; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.193.71 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010071.outbound.protection.outlook.com [52.101.193.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40AB5606A32F for ; Fri, 4 Dec 2026 10:04:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 40AB5606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=tmYwAO9v ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F/ZHwoIExPF5fzEIVWOZqMIqtWqWbKXBei7rHZ+hkr7KSyZGu9JbB2tuE1E7Fzkq1XlvjFhXmLCr5gVtTY2FiV3ZzJ5pu9q/VKoTAxbXMF6kKuwrp0TfJ8PTbwOcxUF4fn+JVcCuQmqadXEDIM5TlUKmmTDfRr/G6QCK2+zg20ekTCcNoCI0jhBQrbqtksHAmR/7AjhLYFd9mYHXmibvaNOiGmT9k6CWOMC0IzoV3zsTxe/UcVrFUCx3KeIJJ/sP8W5CZGSEI0HabeSAgnTXR+kwK3JLYmZBUMLyMnGrtYEBnoAFXGP+vTbdX0o+To+XBBOesH5tdZvEfabUGzXUUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QZDBX2GDNF1LL9F7cVoaH5ZJnyYnTo3Md6NNCUW+zfY=; b=NvpJt+xLvqdpYsL41WsZyaH4ZfNRjXw8tH/TWntvSq6oCXj/IhPjWunU6J2M3bShys9tZBvuarScT8Pfbv06KR6C9lKro38rGz/mear6/NQNcjP47vRk6xcNdHhRsCCfspOmTVp1HQPNNt5Qmdf2tP4aeNcL/TjQa6nZjS9CcdGMLhPVb4UH9HpUwzfjIHEMn2fTmMYGE/UgCo4klNzMVx0qntMqGVUo/fgVkqjnQn/aajLes7USsW95luiE73afIiz9toIYWLrMREz3yk5mydw0qkdlZL0OV5Kw/ltjqXdQa7m5ij0EMkJpwJ0oKuWrS+vRhU7+OX7/fLxav3ac/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=8bytes.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QZDBX2GDNF1LL9F7cVoaH5ZJnyYnTo3Md6NNCUW+zfY=; b=tmYwAO9v/9Dg4Tch+VNfPrRmdreSnkZL6P0J2mzih1DHmruwzU23nLC/KsBzeolAsnN3mKRmWI+4P6v4gkuH6aLZXHeP8ScmQTmY2loDAowQAITXsuo8ApEfJrNs3WirhZoMBbFjHluRRubXaph5vT7bqCk6/2nesqzMiR/3fCE= Received: from MW4PR04CA0100.namprd04.prod.outlook.com (2603:10b6:303:83::15) by CY8PR12MB7219.namprd12.prod.outlook.com (2603:10b6:930:59::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 10:04:31 +0000 Received: from SJ5PEPF000001CD.namprd05.prod.outlook.com (2603:10b6:303:83:cafe::4c) by MW4PR04CA0100.outlook.office365.com (2603:10b6:303:83::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.13 via Frontend Transport; Fri, 4 Dec 2026 10:04:31 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by SJ5PEPF000001CD.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Fri, 4 Dec 2026 10:04:31 +0000 Received: from kali.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 04:04:29 -0600 From: Vasant Hegde To: CC: Subject: [PATCH 28/38] iommu/amd: Complete a PPR from a device the IOMMU did not probe Date: Fri, 4 Dec 2026 09:56:26 +0000 Message-ID: <20261204095636.335222-29-vasant.hegde@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261204095636.335222-1-vasant.hegde@amd.com> References: <20261204095636.335222-1-vasant.hegde@amd.com> X-Mailing-List: iommu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CD:EE_|CY8PR12MB7219:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ce97604-a1de-4b04-18d0-08df51edfd86 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|1800799024|82310400026|376014|22082099003|18002099003|10067099003|56012099006|261028144727099003|261102123227099003|261021123027099003|261022105027099003|261022075727099003|261022113327099003|261026140227099003|261021121427099003|261026121527099003|261009223027099003|11063799006|6133799003; X-Microsoft-Antispam-Message-Info: Y9c5EZGR4emBJvms534pH/NU88wmVYk9fDMYCoRZQvHvkZsRuonoSlOqo5aG0IbDCAn8W6U3eIwv320uJwu7Fzlf3AlLcjlDRtETsvB7rlEqwvkL9GRB9QY2g3rkGZiuYvwTqwoLJfmCLlrXtvfCQiZhxXkMv8/aVxuaNoPTMeOWKKNKPSt74e9egAyv2m++YJIvTgagx+aSXEcMPylhyUQn9eqyFZ/hEzkvfucJKqnYEjx246JZlTmnW3iLAeRPWJbLowUF4JLrTRJLcZRO6c/q7rxKgRzN7VyWDdCVQNDdIboRqlnLkdKaUIEMoPc3mgqgK32amOT0vMkVPLIhFCUIpIxEoU3xCMN3Zc6vG8pLQHVmtfwIu0HrkQznF+DOuZulF4YzN67dGFI2e8dw2YJN4HsAgBPfvzvzBM8DqP46A3Nna9zZFdE6Tk1rlP0qrt6mxHhUDwSZJDUtTCNED7DCt0heKCqWT2LvAwuYbVEvM7A++cStGfAYAAkPJ8FMVqWXzW6QT9Ja9P84Vg5tnP0BuPdkwzHMwHmXHqyvB3QGWHfzhz9Oo81FTKF754EcE4i844Tsui9ySfPGP2RIfuDGV9FwIZKOVP3H4I1MAESUsZsQn+pM59kRuCyVHz7jrhhtpfh5liP14Mgpv3l0dV724w+q7whbf0gHH378A59P6UHhc3ZhtePQKl6A/NBxlyiXkGk4MHOdSFr8Hk1cEA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(23010399003)(1800799024)(82310400026)(376014)(22082099003)(18002099003)(10067099003)(56012099006)(261028144727099003)(261102123227099003)(261021123027099003)(261022105027099003)(261022075727099003)(261022113327099003)(261026140227099003)(261021121427099003)(261026121527099003)(261009223027099003)(11063799006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MZQ1f93V2cgxMlmWJgq2Jghk1xEzNzVp9JDLJ84gnPku+Qo9cw+zMaqvqF4Pv7Mv3cVxIvjRlBSNv8EaFca6yiBQwqXXjuLqbbRQNZUgwIy6GDXcnwtG+Ns5GW2IyZOjtA7d4otRmJ0ypJoivRBNKzurGcnQv8c7jqCd/PzHVzzMGk1SockIOdb4lJrqGNjOXOnfl7RPn9gPZM5rhLg8D5QfC2cIAblhRuTgVef15D/Slkiz6E9f25BlaKuucBEN2J6BJKt2+MNaFaoFEht2FSgDII+ZkHjzCgsRcEQ7jg7t6L+U8zDEt4vTgvLt9cF0TFiA9MP4tarPZADV62q7HrdnuQOV/dj5X93o2wZP4rGJTjEnSox/TxbcC8IgEXY8KPpn8rARvRnFcbmDEvPe4zZARwM249Ughf07QUMATOIIRp3xuV7c5C0IuwpTvJWN X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 10:04:31.1698 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ce97604-a1de-4b04-18d0-08df51edfd86 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001CD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7219 iommu_call_iopf_notifier() reads dev_data->max_pasids after looking up the PCI device. dev_iommu_priv_get() is NULL when probe failed, and the abort path then calls amd_iommu_complete_ppr(), which reads dev_data->devid and the device's IOMMU. A kdump kernel reuses the previous device table, so a device that failed probe can still have PPR set. The invalid-PPR event path has the same dependency. COMPLETE_PPR needs the IOMMU that owns the log and the DeviceID from the entry. amd_iommu_complete_ppr() takes those directly. Report the fault only when the device was probed. Otherwise complete the last page of the group from that DeviceID. The invalid-PPR event path completes the same way and no longer looks the device up. Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu.h | 4 ++-- drivers/iommu/amd/iommu.c | 27 +++++---------------------- drivers/iommu/amd/ppr.c | 27 +++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h index 44aebf1e6aee..b13eaa7620da 100644 --- a/drivers/iommu/amd/amd_iommu.h +++ b/drivers/iommu/amd/amd_iommu.h @@ -83,8 +83,8 @@ int __init amd_iommu_alloc_ppr_log(struct amd_iommu *iommu); void __init amd_iommu_free_ppr_log(struct amd_iommu *iommu); void amd_iommu_enable_ppr_log(struct amd_iommu *iommu); void amd_iommu_poll_ppr_log(struct amd_iommu *iommu); -int amd_iommu_complete_ppr(struct device *dev, u32 pasid, int status, int tag, - bool gn); +int amd_iommu_complete_ppr(struct amd_iommu *iommu, u16 devid, u32 pasid, + int status, int tag, bool gn); /* * This function flushes all internal caches of diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index a6ed81c9725e..9b82fe5c56b1 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -877,7 +877,6 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu, 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; @@ -892,20 +891,9 @@ static void amd_iommu_report_ppr_err(struct amd_iommu *iommu, volatile u32 *even 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; - } - gn = (flags & EVENT_FLAG_PPR_GN); - - amd_iommu_complete_ppr(&pdev->dev, pasid, IOMMU_PAGE_RESP_FAILURE, tag, gn); - pci_dev_put(pdev); + amd_iommu_complete_ppr(iommu, devid, pasid, IOMMU_PAGE_RESP_FAILURE, + tag, gn); } static void iommu_print_event(struct amd_iommu *iommu, void *__evt) @@ -1867,17 +1855,12 @@ static void dev_flush_pasid_all(struct iommu_dev_data *dev_data, amd_iommu_dev_flush_pasid_pages(dev_data, pasid, 0, U64_MAX); } -int amd_iommu_complete_ppr(struct device *dev, u32 pasid, int status, - int tag, bool gn) +int amd_iommu_complete_ppr(struct amd_iommu *iommu, u16 devid, u32 pasid, + int status, int tag, bool gn) { - struct iommu_dev_data *dev_data; - struct amd_iommu *iommu; struct iommu_cmd cmd; - dev_data = dev_iommu_priv_get(dev); - iommu = get_amd_iommu_from_dev(dev); - - build_complete_ppr(&cmd, dev_data->devid, pasid, status, tag, gn); + build_complete_ppr(&cmd, devid, pasid, status, tag, gn); return iommu_queue_command(iommu, &cmd); } diff --git a/drivers/iommu/amd/ppr.c b/drivers/iommu/amd/ppr.c index 1181dc31795f..7d660a81df3a 100644 --- a/drivers/iommu/amd/ppr.c +++ b/drivers/iommu/amd/ppr.c @@ -116,10 +116,27 @@ static void iommu_call_iopf_notifier(struct amd_iommu *iommu, u64 *raw) return; } + /* + * Probe never attached this device, or it is no longer on the + * bus. A kdump kernel can reuse a DTE that still has PPR set. + * The log entry carries the DeviceID, so complete the group + * here and do not touch dev_data. + */ pdev = pci_get_domain_bus_and_slot(iommu->pci_seg->id, PCI_BUS_NUM(devid), devid & 0xff); - if (!pdev) + dev_data = pdev ? dev_iommu_priv_get(&pdev->dev) : NULL; + if (!dev_data) { + pr_info_ratelimited("PPR for unprobed device: 0x%x\n", devid); + + if (PPR_TAG_LAST_PAGE(raw[0])) { + amd_iommu_complete_ppr(iommu, devid, PPR_PASID(raw[0]), + IOMMU_PAGE_RESP_FAILURE, + PPR_TAG(raw[0]), + PPR_FLAGS(raw[0]) & PPR_FLAG_GN); + } + pci_dev_put(pdev); return; + } if (!ppr_is_valid(iommu, raw)) goto out; @@ -136,7 +153,6 @@ static void iommu_call_iopf_notifier(struct amd_iommu *iommu, u64 *raw) * PASID zero is used for requests from the I/O device without * a PASID */ - dev_data = dev_iommu_priv_get(&pdev->dev); if (event.fault.prm.pasid == 0 || event.fault.prm.pasid >= dev_data->max_pasids) { pr_info_ratelimited("Invalid PASID : 0x%x, device : 0x%x\n", @@ -159,7 +175,7 @@ static void iommu_call_iopf_notifier(struct amd_iommu *iommu, u64 *raw) out: /* Nobody cared, abort */ - amd_iommu_complete_ppr(&pdev->dev, PPR_PASID(raw[0]), + amd_iommu_complete_ppr(iommu, devid, PPR_PASID(raw[0]), IOMMU_PAGE_RESP_FAILURE, PPR_TAG(raw[0]), PPR_FLAGS(raw[0]) & PPR_FLAG_GN); pci_dev_put(pdev); @@ -245,9 +261,12 @@ void amd_iommu_iopf_uninit(struct amd_iommu *iommu) void amd_iommu_page_response(struct device *dev, struct iopf_fault *evt, struct iommu_page_response *resp) { + struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev); bool gn = evt->fault.prm.flags & IOMMU_FAULT_PAGE_REQUEST_PASID_VALID; - amd_iommu_complete_ppr(dev, resp->pasid, resp->code, resp->grpid, gn); + amd_iommu_complete_ppr(get_amd_iommu_from_dev_data(dev_data), + dev_data->devid, resp->pasid, resp->code, + resp->grpid, gn); } int amd_iommu_iopf_add_device(struct amd_iommu *iommu, -- 2.31.1