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.193.50 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796033580; b=RbON4nf8MAkwl0YDzEV6yLv20RcqLnn1HoY42iVPmxuotO2POIZ8iGkkTAD4jQqU5mRH nnvViRnaQ7WFQ9mIpbe8sbFT7dbj/P+DvhUFIuC2x+LXGMfzXEAE81xJlaBV45fJknSr8 qbUN/iZFb3sCNc1oxmpwt7wLR8tJUNgs3RsYokAU8dFFl6baPLWw+EqbHLZbHmSLq+YYR JBM/Lt1vMPNa7Rm50Qiipjwz8CMdvVaM1a6hmB9jYo0DEck6fZkEAbUXPNu5nuFdnsibz mCzuR5Vo2mWomVq3tepZMZxkDNJCsBPfXn6+yO+s+D06Htdd5s+k6l0i4h2oV6B8xpg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796033580; 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: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=7wGgHWe1G5KYQqgO59D2L7UAHj+X3mampBiAjTkJxR4=; b=vQSNXpLMw9CaPYSj+BqTcqnhhliFz0uugZ5DOgDivpt5VyydFQV0vQlHmLFrtyJ5qpg2 nsf5vvEnZZwZZgVuZziN75VlAAU+c8/NiC/h1Ba1BB1jHNGVHcEA9ZvLBorp2pL+ggzRY gd7ASjKDR7zGbd73zCxnl24htsFOK9NP/XOGYmfwOz8k05lTqHjt+FyZBJMa5XeDuqDrd Em4f7Sg2hZWXncTWopshSYWmuQq2K9xgCbWIMlTc3t/FwGn3UwkNm5ufh9pfQrNUXYGIo YwPaHrY0dUaAUjKAzFOELb64wrkvAHy14cMwiPINUXok0JtbEuX6VIW0VmqHDFC3CkQ== 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="z/EWdXkj"; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.193.50 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010050.outbound.protection.outlook.com [52.101.193.50]) (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 C4EE1606A325 for ; Mon, 30 Nov 2026 10:12:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C4EE1606A325 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=z/EWdXkj ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fU047MSJ6MW7W5bL1EdMw3zFPCJWunDjUwW2YAP5KRmDiD2oDbbNztJ/2R8BOLP8+9tG/7BYcdaXf68UdQAumM9XQ8dcDotcelMW03A4buqPlvNgz99RdPw46oMTlects5xpyVH2H0TOBrGaBjZ8ocfRiyrwQ47+UrXb6zKSGodUL+tNwAabNbnGNdZ+zIamuK4YL9l2G+lC85FkQMgfSI3GLrQ2VIk7lIvVO33wMv38W/5zOgDFfNjciLZpLN7HG1XywPWgyHmjIwgGh3Q4g7yu1/5i/iCOASgJmqV2gOsl/uISOxO3d10jsW5IE6CcxLXklMZ9YFT2cBRLzHpAVQ== 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=7wGgHWe1G5KYQqgO59D2L7UAHj+X3mampBiAjTkJxR4=; b=Lh3KbnkJ66J8xPA3x9D0IQuyQFqvHnynZVagDK8iPmqC0sgXoByhGZ78rORYOPUXFNgBkIsy7NST7mgZzAIQesc2MIj2ZPF4N/Y00NFULGoajyJmOyZhTVW9DWVscBR3HJuMaKysvDjKXSLSTyoj6ZoZjVfOfG5iiDBrWMbBUWo00h+2fXQFWtcdHVNgUc/kzu853id6+EINT9km2/p61XcOChzKKXjl3L5chRKj3AwBygMopegE6YCZhE+jyoutJEkzM+UYVcIvCGELafaje5xdZBGMjWj1vgtVaTuGvZ9CZXjOB474QJzhcglGQb6LSojpmaLHpXjYnA2BaZ3xdA== 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=7wGgHWe1G5KYQqgO59D2L7UAHj+X3mampBiAjTkJxR4=; b=z/EWdXkjXAZV2VqqzNpwc2B5CUYVY94Dzp4doIyPpxvS1yRzSmyFzcfdZ/X8sWLpm9r5AtdUldDvXr3pC5ZE/Wm3HD1rN8PRgzSPzeV9QJ/QFH4dR1z3Ugn0z83BiJ1cXtuD9QxdGpDV4U+OcpJuJlR9G1TVPldMlWf8HMtWHj0= Received: from PH0PR07CA0065.namprd07.prod.outlook.com (2603:10b6:510:f::10) by LY0PR12MB967422.namprd12.prod.outlook.com (2603:10b6:408:3bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.11; Mon, 30 Nov 2026 10:12:55 +0000 Received: from SN1PEPF000397AF.namprd05.prod.outlook.com (2603:10b6:510:f:cafe::13) by PH0PR07CA0065.outlook.office365.com (2603:10b6:510:f::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Mon, 30 Nov 2026 10:12:55 +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 SN1PEPF000397AF.mail.protection.outlook.com (10.167.248.53) 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:12:54 +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:12:49 -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 0/6] amd_iommu: Add support for multiple AMD vIOMMUs Date: Mon, 30 Nov 2026 15:42:31 +0530 Message-ID: <20261130101237.1416-1-sarunkod@amd.com> X-Mailer: git-send-email 2.34.1 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: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397AF:EE_|LY0PR12MB967422:EE_ X-MS-Office365-Filtering-Correlation-Id: 67485806-0530-4184-8e0d-08df4eca7ff8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700016|1800799024|23010399003|11063799006|6133799003|261009223027099003|18002099003|13003099007|921020|10067099003|56012099006|261102123227099003|261028144727099003|261026121527099003|261026140227099003|261021123027099003|261021121427099003|261022105027099003|261022075727099003; X-Microsoft-Antispam-Message-Info: QtRNk+7yTvQvHDG/UwbKb1Z71IYYo2wdeOKjlq0qrlfyC0+2Xo0WXzFh6n0YD5JQh739GeNcU1DlVP9mcgctpwjQOdi+NWlfZ/So+GfDSVhePKbW9e5GWFXceS32Cgvk67AJWf2tBF8NYHTsozVkv0u+EzTBFYfTueskcnumHFlDh5tcp3ttW5m+dhnewJr98ETn/htwe23NscBhTKeyqyMkMd0PR6YXl1VrXIO05H66pFv62mgWNuH3bDXA30VTWUaZewTexDHR4DX+AIlvy65zE3N8pjXV1dbtHhZW80OxfbfFxLTSpZN2+je5Sr8mE+1rrwvd7NpDR8QHTtzkToKaJFUmX2T+6zEkpDQPpjkS5NHsaPivFgwnStbsHjVVdaoGi1+0VG5PnGCirXuIPD+IeXXq9gP1wT1v2F9Nn64yseI4CuUwTeaEDlMcKUw0huGXTu7ct/s20nXEA1wvP3OzZz7jQKJwlki46vulUzK21KIr7vgVgBI39nzUAFK44ZWr5sZ7dr18DY38vhJ1vz75/pwU/ROo8B5cMOsZn/RLf3dDuHLEHCau8ABV7oUoA10DuGcRAXtoDo7MchA55A/73zqlnVvNmABmp+dqeo0E2yX7TjOGd7DxQLVW/3LvjFwOmhOyIYFtTt6oe8sHLlxhS6Qb/Aw0VgLpdn7EYnGbGBsUPfotWhY9jp6ZPxyAFVzmQjz0HNv8RBjRdP+1SA== 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)(376014)(7416014)(82310400026)(36860700016)(1800799024)(23010399003)(11063799006)(6133799003)(261009223027099003)(18002099003)(13003099007)(921020)(10067099003)(56012099006)(261102123227099003)(261028144727099003)(261026121527099003)(261026140227099003)(261021123027099003)(261021121427099003)(261022105027099003)(261022075727099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B97FXkwfCTGUswLqU2WFBLEFcZg9axhThU1O+bDkBkDDLxdJdOpe8oUmQM5LnkHSN8eg2CKGfcSXaUlZxQYYVf/1wjScNJR13SqjDezUy1yAz8v1S4LJ6fVwn9MaGtbhD6zQ7Nr7+NZ11DC1QbRLgwNvzdKF/eyoqORt4qBSgD3JcINwPlbLucD+x8cjAx3iFGKi/P8NcuhtV/zRCY/AF7rpniIOhbcz6uWx4M6lo4Fb8SRUKT0SWsoRdFzuNGatM5ulT1H8mSqxaNFkuQmRaMQtSDDeeJ7Kg45wHHs2p8Drw7KSKwkwLLlZBIRJWgJCSBHxhnBwOKhHsi4b2SHihKZgfbmlDKNtQeMSo0eXAwinFzDPHBG2mYNgHnCFc7Ops5BAgmSl0zNKRYXSELJAP98ji3FwppqvVB8U48DYXxQKb65NFyl7F8u1/sqDzu7X X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 10:12:54.6585 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67485806-0530-4184-8e0d-08df4eca7ff8 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: SN1PEPF000397AF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LY0PR12MB967422 Overview -------- This series lets a guest have more than one AMD vIOMMU. Each vIOMMU takes care of the devices under its own PCIe root bus (pcie.0 or a pxb-pcie). It builds on the root-bus series [1], which allows an AMD vIOMMU to sit on a root bus other than pcie.0. Motivation ---------- With the upcoming hardware-accelerated vIOMMU, each guest vIOMMU is tied to one host IOMMU through that host IOMMU's VFMMIO region. Because of this, VFIO devices that sit behind different host IOMMUs cannot share a single guest vIOMMU. If a guest gets passthrough devices from more than one host IOMMU, it needs one vIOMMU for each of them. Solution -------- 1. Track all vIOMMUs in a list in the PC machine, in creation order. 2. Build one IVHD per AMD vIOMMU. Its device entries are the devices under that vIOMMU's root bus; a child bus served by another vIOMMU is skipped, so IVHDs never overlap. 3. Give each vIOMMU its own 16 KiB MMIO window starting at 0xfed80000, indexed by creation order. At most 8 vIOMMUs are allowed, so the windows stay below smram-open-high at 0xfeda0000. 4. Track the IOMMU that the IOAPIC is bound to, and register the KVM IEC notifier on every vIOMMU instead of only the first one. 5. Allow multiple AMD vIOMMUs in pc_iommu_pre_plug(). They cannot be mixed with Intel or virtio IOMMUs. Every amd-iommu in a multi-vIOMMU configuration must use 'pci-id' to name its AMDVI-PCI device, and each must be on a different root bus. Command-line ------------ qemu-system-x86_64 \ -enable-kvm -m 10G -smp 8 \ -netdev user,id=USER0,hostfwd=tcp::3333-:22 \ -netdev user,id=USER1 \ -cpu EPYC-Genoa,x2apic=on,kvm-msi-ext-dest-id=on,+kvm-pv-unhalt,kvm-pv-tlb-flush,kvm-pv-ipi,kvm-pv-sched-yield \ -machine q35,kernel_irqchip=split \ -global kvm-pit.lost_tick_policy=discard \ -nographic \ -kernel \ -initrd \ -blockdev node-name=drive0,driver=qcow2,file.driver=file,file.filename= \ -device virtio-blk-pci,num-queues=8,drive=drive0 \ -device pxb-pcie,id=pcie.1,bus=pcie.0,bus_nr=0x40 \ -device pcie-root-port,id=rp1.1,bus=pcie.1,chassis=1,slot=1 \ -device pcie-root-port,id=rp1.2,bus=pcie.1,chassis=2,slot=1 \ -device AMDVI-PCI,id=iommupci0,bus=rp1.1 \ -device amd-iommu,intremap=on,dma-remap=on,intremap=off,xtsup=off,pci-id=iommupci0 \ -device virtio-net-pci,id=vnet0,iommu_platform=on,disable-legacy=on,romfile=,netdev=USER0,bus=rp1.2 \ -device pxb-pcie,id=pcie.2,bus=pcie.0,bus_nr=0x50 \ -device pcie-root-port,id=rp2.1,bus=pcie.2,chassis=3,slot=1 \ -device pcie-root-port,id=rp2.2,bus=pcie.2,chassis=4,slot=1 \ -device AMDVI-PCI,id=iommupci1,bus=rp2.1 \ -device amd-iommu,intremap=on,dma-remap=on,intremap=off,xtsup=off,pci-id=iommupci1 \ -device virtio-net-pci,id=vnet1,iommu_platform=on,disable-legacy=on,romfile=,netdev=USER1,bus=rp2.2 Examples -------- Example1, For below PCI configuration AMD IOMMU 1 will serve all the devices under pxb-pci1 and AMD IOMMU 2 will serve all the devices under pxb-pci2. pcie.0 -+- pxb-pci1 -+- pcie-root-port1.1 --- AMD IOMMU 1 | +- pcie-root-port2.1 --- Device1 | \- pcie-root-port3.1 --- Device2 \- pxb-pci2 -+- pcie-root-port2.1 --- AMD IOMMU 2 +- pcie-root-port2.2 --- Device3 \- pcie-root-port2.3 --- Device4 Example2, For below PCI configuration, AMD IOMMU 3 will only serve Device5 and Device6 and devices under pxb-pci buses will be served by IOMMUs of respective buses. pcie.0 -+- pxb-pci1 -+- pcie-root-port1.1 --- AMD IOMMU 1 | +- pcie-root-port2.1 --- Device1 | \- pcie-root-port3.1 --- Device2 +- pxb-pci2 -+- pcie-root-port2.1 --- AMD IOMMU 2 | +- pcie-root-port2.2 --- Device3 | \- pcie-root-port2.3 --- Device4 +--- AMD IOMMU 3 +--- Device5 \--- Device6 Example3, The below PCI configuration is invalid since both IOMMUs share same root bus i.e. pxb-pci1. [A] pcie.0 -+- pxb-pci1 -+- pcie-root-port1 --- AMD IOMMU 1 +- pcie-root-port2 --- AMD IOMMU 2 +- pcie-root-port3 --- Device2 \- pcie-root-port4 --- Device3 [B] amd-iommu devices with and without 'pci-id' mixed. [C] More than 8 amd-iommu devices. [D] amd-iommu mixed with intel-iommu or virtio-iommu. --- Patches are based on top of 9cda597a1a39 and patch [1] [1] https://lore.kernel.org/all/20261116134209.30331-1-sarunkod@amd.com/ --- Sairaj Kodilkar (6): hw/i386: Track the IOMMU to which IOAPIC is attached i386/kvm: x86_iommu: Introduce per-iommu notify_list_inited flag acpi-build: i386/pc: Track vIOMMUs in a list amd_iommu: acpi-build: Add support for multiple AMD-IOMMUs amd_iommu: Introduce AMDIVRSInfo for shared IVRS construction x86-iommu: Allow multiple AMD vIOMMU devices hw/i386/acpi-build.c | 209 ++++++++++++++++++++---------------- hw/i386/amd_iommu-stub.c | 26 ----- hw/i386/amd_iommu.c | 76 ++++++++++--- hw/i386/amd_iommu.h | 15 ++- hw/i386/intel_iommu.c | 1 + hw/i386/meson.build | 3 +- hw/i386/pc.c | 36 +++++-- hw/i386/x86-iommu-stub.c | 5 - hw/i386/x86-iommu.c | 16 +-- hw/intc/ioapic.c | 18 ++-- include/hw/i386/pc.h | 9 +- include/hw/i386/x86-iommu.h | 8 +- include/hw/i386/x86.h | 4 + target/i386/kvm/kvm.c | 19 ++-- 14 files changed, 252 insertions(+), 193 deletions(-) delete mode 100644 hw/i386/amd_iommu-stub.c -- 2.34.1