From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.45 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796033807; b=MMjeZAHm78n+Kojp5wPlsq/QyrrefC7/ZcZ9SsSV38NAobgN0S56uaUXoUzfR67k6HKg lKpsKkqZ8V3mIvoPmqyfao3mXrOkIFKsw2kVSz6hxDjwK1qzOoUvVRkbTyA/Ieo6DRIWx EbeyEbZ/1iWBv5XTFR2gWQ9m9kHaqra4IFBBMMbi1BG1mrM8TZk4Unukh/+U0XILHMcwV 9vjzH6Xrr9LFemsr6/ho/OoAX88CVq76AGOqk0AnjPdjbmzJLjqaV9mgYQ1xJNyaR1exL BfUajms0tKT2RGhGlHHO22xJru4HEAlpzn5RT3kfnRyB+zzz4n0WoT5cLnTUdpOjVGg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796033807; 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=OlBFdDGXcyFIyg/Jf4gsxQod0WBla8ZFja7L8qvRBIo=; b=hv3ulyEDuKzdz4BBefGQ7fmK6Gwenpd6sJ969AlkdUkLqQA5j2laFB2MBNRHB+dIUXOI KaoGNGcM7ufwT+sw/oCFfj5pqb/07QMSWdASLKftUCi0u2eqGkFB1OOfkfSO21toElQhA 6rstN4+DpyZqcSRmQWZt6jJQCK25CxoWtresWFoTDsuJkAQb0ncRipJLGqYpHsLkcLY8T 8d8JkrRzShXZohN83V+XYzMZ8HH2Paot9UlOMNvsT8RvIULgqZGrCFTVYZZPgEvMfocZh Nwv40Pbb19QO3xxUzKq9/LTs2Q1hCdfWdQ3/jtzVGjFzFgH0u9yWCDp/OugzaVcYgvA== 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=a7x31X3g; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.45 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010045.outbound.protection.outlook.com [52.101.61.45]) (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 EF408606A334 for ; Mon, 30 Nov 2026 10:16:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EF408606A334 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=a7x31X3g ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lQq04qsILTZZ79SvsvIOicnxu3asZ9/4ZGVxzh1Lq7zNM0mUKHxxummpmM9N+lv5bdIx99i84Iz5UIsTe24J2+OJ8CJFk3l/ZY9JYBSx5o24pPJssBKnzH6XEW6t1EiPio5CmkjR99M6BSLbrydE+nwzqAnb+5Gu5ZIeJljtRPwcboDW9PvWWahjhTLM2m8N0ZuSDOK4RhgmXiG0vaBLpHcR+xWLOR+gIihnzSSrGpguUhquP3/Fa6z8EuFAvX7cgZYr7l1mByLyflXg8/FPwY33zo2AnFEBbewaA6EE063tOiqMdQ/P5Z29UZGuyyNliLY9cljb3719Bgb+SjNWLw== 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=OlBFdDGXcyFIyg/Jf4gsxQod0WBla8ZFja7L8qvRBIo=; b=KfXLIfuuch/wS4GfEJ71QDjyxm1VIbcP/XuAVICke+YsInF7B08B69PiptMCQb0RFSYZKb4z7hR6yEsqYjAfZYhc+6Z7T+gL+6g/mROTPKjQ/uFTVpXEp/XtkwsWrb/mIfFdvSiPrAt7TewEApJShlxyI6VJthfxfriMZdSeBbdlcmx9SAMHvY9ejuk9X1CVmkHg474xLb7rvp6E/83yZKJ2ggiIsIYC6ajJUh11igEOa0QL5bNdjUENbLicORRfEA2aV0YarKx7/nD7Mo4vQ62KMETTgCpfBml01eX0ENS97ZxbLiZnJ5tAGwquttvL7ZXqd6pRsSIxmcVDleBudg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=bull.com 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=OlBFdDGXcyFIyg/Jf4gsxQod0WBla8ZFja7L8qvRBIo=; b=a7x31X3g97phBkmvPNoslKACrH660zEWSAoIROOvSmbRzL8sn6ohKXlDAQy7WzwsBZAE8LfvDMNe+1pQA8p95w2BAnTNTEC7+NaD9zIRxRDvzoiWrFrLJNP2Jqtys3JQb/rt/K7lqJi1bvEHRlQctjnzmTOLybweHQ7xaYQvdAo= Received: from SJ0PR05CA0074.namprd05.prod.outlook.com (2603:10b6:a03:332::19) by SA0PR12MB4382.namprd12.prod.outlook.com (2603:10b6:806:9a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Mon, 30 Nov 2026 10:16:43 +0000 Received: from SJ1PEPF00002322.namprd03.prod.outlook.com (2603:10b6:a03:332:cafe::8d) by SJ0PR05CA0074.outlook.office365.com (2603:10b6:a03:332::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.4 via Frontend Transport; Mon, 30 Nov 2026 10:16:43 +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 SJ1PEPF00002322.mail.protection.outlook.com (10.167.242.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Mon, 30 Nov 2026 10:16:43 +0000 Received: from BLR-L1-SARUNKOD.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; Mon, 30 Nov 2026 04:16:38 -0600 From: Sairaj Kodilkar To: =?UTF-8?q?Cl=C3=A9ment=20Mathieu--Drif?= , "Michael S. Tsirkin" , Alejandro Jimenez , Ani Sinha , "Igor Mammedov" , Jason Wang , "Marcelo Tosatti" , Paolo Bonzini , "Richard Henderson" , Sairaj Kodilkar , Yi Liu , , CC: , Subject: [PATCH 2/6] i386/kvm: x86_iommu: Introduce per-iommu notify_list_inited flag Date: Mon, 30 Nov 2026 15:42:33 +0530 Message-ID: <20261130101237.1416-3-sarunkod@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261130101237.1416-1-sarunkod@amd.com> References: <20261130101237.1416-1-sarunkod@amd.com> X-Mailing-List: kvm@vger.kernel.org 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: SJ1PEPF00002322:EE_|SA0PR12MB4382:EE_ X-MS-Office365-Filtering-Correlation-Id: 1866c580-102b-456b-8fd4-08df4ecb085a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|1800799024|82310400026|7416014|376014|921020|10067099003|56012099006|261028144727099003|261026140227099003|261026121527099003|261021123027099003|261021121427099003|261022105027099003|261102123227099003|261009223027099003|22082099003|18002099003|11063799006; X-Microsoft-Antispam-Message-Info: X9Fh6d8w8xPNpVy1hvEzAviRPaIkVLQuL3vYnCrhKSPn1QRW0C1cqGgiCfasnG8n/Gc6KLC3sZH+K30yyEJo8ov8ReF417r/I/gqGuUXvaHbDTFCFkR8R9iNcu/yPC91qrTlIbihdzuMwzECuvs4UtisYIMifunXAxo/imBCeAaLjnlKsnXT67+pTran5T0g/rqKA37rxH3HIu6n7srm012xohTBV3Q1XyEow/TVNZ00UWp2ubBlwP+joNa8LGLHKz9yTj0qirizuobLG9KLgn6o0SgzdwRAp5wsWedWvEjNhSsnCWFcrvrUilBeRuAwTy7DrwH+E8FhodA3diSU5HcJmLlUzcp0rdgb8hDrWMlLYtursEIARDT5PWyJkOdw/fJ+t6T2EZRtQaEq8XmopRZDpxbVNc8waURUa4UZI3dqBqeNP4K2ZbRK1Whhjv9f+2Mq9x44iCIuxkOLgaDh4fPRfTrrI1iCVfM2CJ8kpMFh99ydXoIYuqXfsbdG5ME6x0P4w2VRentAFobeACjNL+alMCCBt1DEXRQxpECtd59oQFw06Pgyv7+vtetp/siB7cNPMX923xji5d2ADZUh07bsz9/WQhe1/defY7UTqnToZ6MOL9A5cIesxIxYyDkqLj4MagGyVXYxE6OiRJWePrqQEvdBeARXKPnVA/IqIbS1PSXJnhh7JI7eE1VJiznNwlWknOruBcBqmRSANbCN0Xwkv/cxUCGRGQL1SYidJPHqMewhkXR3t4H4LyZtvJcB 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)(7416014)(376014)(921020)(10067099003)(56012099006)(261028144727099003)(261026140227099003)(261026121527099003)(261021123027099003)(261021121427099003)(261022105027099003)(261102123227099003)(261009223027099003)(22082099003)(18002099003)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gvB+yPyF36mFuBzXEyKCqidNFL1vSc2YNT9IBX/dk5wI/lCk+rbmdMP62JyMl8VgeZ6IUEvZOqG8a6wLiPGJo7SUVjenJkeg4ATiftxncOgEF+4LqKhzbdN1roORWNOOxvXiBRKF417Ya2Aq4rbGLuZY5hk+Ctex0yH7JyoecIo6PVCsdBRgOFLm721L0rVOQSm47DNjgcCJkhEixgOuSZXjUJA7Jj8LqbZSm34M5IuicI2AcVLYQQ5y9YH4V0tnhDuzACe4KsB9AdWOUaJzkY97n3puMVJxQnwP3Kjbq5a6S3m0/9V1QzZ+qz7GkDs7OxJT5hE/nJvkpN3uHcMvCVanw/YpBId/4tMKMYVjwVtfwCpc6K8nHNpMw52Y1zWgFV1HUM318EzGSi1USHjwOIgUlwhXR3sgPkdv90Zo1S9WFtOswYicVEQFXfbvJVbL X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 10:16:43.4098 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1866c580-102b-456b-8fd4-08df4ecb085a 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: SJ1PEPF00002322.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4382 When interrupt remapping is enabled with a split irqchip, KVM MSI routes carry the result of IOMMU interrupt remapping. Whenever the guest invalidates the interrupt remapping cache of an IOMMU, the IEC notifier kvm_update_msi_routes_all() rebuilds these routes. kvm_arch_add_msi_route_post() registers that notifier on the first MSI route update, and a static notify_list_inited flag blocks any further registration. With multiple vIOMMUs, only one IOMMU gets the notifier. Invalidations on the other IOMMUs leave KVM with stale MSI routes, so interrupts of devices behind those IOMMUs keep using the old remapping entries. Move the flag into X86IOMMUState, so the notifier is registered once on each IOMMU, when that IOMMU sees its first MSI route. Signed-off-by: Sairaj Kodilkar --- include/hw/i386/x86-iommu.h | 1 + target/i386/kvm/kvm.c | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/hw/i386/x86-iommu.h b/include/hw/i386/x86-iommu.h index eb575271e9d7..32cae9facfcd 100644 --- a/include/hw/i386/x86-iommu.h +++ b/include/hw/i386/x86-iommu.h @@ -65,6 +65,7 @@ struct X86IOMMUState { bool dt_supported; /* Whether vIOMMU supports DT */ bool dma_translation; /* Whether vIOMMU supports DMA translation */ QLIST_HEAD(, IEC_Notifier) iec_notifiers; /* IEC notify list */ + bool notify_list_inited; /* Whether IEC notifier is initiated*/ }; bool x86_iommu_ir_supported(X86IOMMUState *s); diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 9bedf1fe680b..6714c51d406e 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6873,7 +6873,6 @@ void kvm_update_msi_routes_all(void *private, bool global, int kvm_arch_add_msi_route_post(struct kvm_irq_routing_entry *route, int vector, PCIDevice *dev) { - static bool notify_list_inited = false; MSIRouteEntry *entry; X86IOMMUState *iommu = NULL; @@ -6892,16 +6891,14 @@ int kvm_arch_add_msi_route_post(struct kvm_irq_routing_entry *route, trace_kvm_x86_add_msi_route(route->gsi); - if (!notify_list_inited) { + iommu = x86_iommu_device_get(dev); + if (iommu && !iommu->notify_list_inited) { /* For the first time we do add route, add ourselves into * IOMMU's IEC notify list if needed. */ - iommu = x86_iommu_device_get(dev); - if (iommu) { - x86_iommu_iec_register_notifier(iommu, - kvm_update_msi_routes_all, - NULL); - notify_list_inited = true; - } + x86_iommu_iec_register_notifier(iommu, + kvm_update_msi_routes_all, + NULL); + iommu->notify_list_inited = true; } return 0; } -- 2.34.1