From nobody Sun Apr 5 18:25:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass(p=quarantine dis=none) header.from=epam.com ARC-Seal: i=2; a=rsa-sha256; t=1774306305; cv=pass; d=zohomail.com; s=zohoarc; b=OBAgQdAZu+DNE6ELQofXHigoqHvl439RxJHfJtUpRzcxCmiH+n7RKZg6upCNG9Y1hhVPvKihupd7fCmGWwpIz7ieOW+rNjlY8YJEhZLNO2XMm2GLfsw5Ei3a67GGXha/OJHA+GS9dQimqyFqeypZvT0wOm5wEfJmiGFMd+aMR+M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774306305; h=Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DEMMv+I/i7mhnlNLSk+XpMQHRds2QOl4rUVk74Q98VM=; b=YBFRCjoeGfxLr6mUtB6GQzkhXr2mNNyeIMfns0qLJsFbIxbmCpiyDxB3HkbrZK+ofGO8oAfOQ0rLroKzIt6OLD3lmZVxkIh85PT666c1hEIzVBsVivteAnxzpAFFzTJ+5u2dd/5La8g/lSvTEC1SjWj4xxWWxApwOCRRYDHO3gs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=epam.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 177430630527097.94348950728522; Mon, 23 Mar 2026 15:51:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1259642.1553013 (Exim 4.92) (envelope-from ) id 1w4o7K-0008G5-4J; Mon, 23 Mar 2026 22:51:26 +0000 Received: by outflank-mailman (output) from mailman id 1259642.1553013; Mon, 23 Mar 2026 22:51:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w4o7J-0008F6-Su; Mon, 23 Mar 2026 22:51:25 +0000 Received: by outflank-mailman (input) for mailman id 1259642; Mon, 23 Mar 2026 22:51:24 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w4o7I-0007zp-M0 for xen-devel@lists.xenproject.org; Mon, 23 Mar 2026 22:51:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w4o7I-0000sX-1v for xen-devel@lists.xenproject.org; Mon, 23 Mar 2026 23:51:24 +0100 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69c1c360-5cb7-0a2a0a5109dd-0a2a4502e3b2-46 for ; Mon, 23 Mar 2026 23:51:24 +0100 Received: from [52.101.70.72] (helo=AS8PR04CU009.outbound.protection.outlook.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.55.2) (envelope-from ) id 69c1c3eb-63bb-0a2a45020019-34654648d8b3-5 for ; Mon, 23 Mar 2026 23:51:23 +0100 Received: from VI1PR03MB5088.eurprd03.prod.outlook.com (2603:10a6:803:c2::20) by AS8PR03MB7653.eurprd03.prod.outlook.com (2603:10a6:20b:34b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.31; Mon, 23 Mar 2026 22:51:22 +0000 Received: from VI1PR03MB5088.eurprd03.prod.outlook.com ([fe80::8471:b7dd:8a1c:c30]) by VI1PR03MB5088.eurprd03.prod.outlook.com ([fe80::8471:b7dd:8a1c:c30%6]) with mapi id 15.20.9723.022; Mon, 23 Mar 2026 22:51:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jaktPiHjUt4H4J36NekumW1ENJMAU5BYR0g2yx9GcZXBlWFiVbtRILTytKJMnJQQoeHtybJ/3mau2a4qGaAngdUzjY3RmHpPeWquujhEj2zT3TY8qEsm6lrrvp2oSP+ogeAbDjBAId+k5l7K8zTyZBC1cBR7Kr2yS6wMIWntC2R1uiObt6ZLRBR8DcwQYoClB6/4FBHNH1EcBKT0cRuGgEk8thV12E6cPdp5FqEeasrxAJpA95GbKVXkdfFOikhOfCYgsZJtYbVZCWf8XOCzuxMVhceNW8QKCvkGKQmIT2Kz0w1mfZlyBH22wlQRzQzh+TvO9uVvYPdWjX9YtVJcBw== 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=DEMMv+I/i7mhnlNLSk+XpMQHRds2QOl4rUVk74Q98VM=; b=kIYds4L++6iyZmJZ3LZWWijs/kCLc4kcF4bAOvy+WBx6QF9o7wYP6dv1Mtx/drL72F+O7jkS8VUYJoaVY7WipbSL2+Gd9NKPv9r3ut0obh/+pxS246e08vWjGld62bZfiDZwhMcx26ptfB8I52d/lcVUjOoxOnKcAnSSinqX2bXwRHPldPoMHEC7Fpg2gmkasn8+Z2Fl1fhoQ6a+JTqU/q9DhHSkFlrnZEYxvS7niv5b0CU0NaniKQhPzP9s1ewR9QXMG/b37ldRe/r5zav7u/sftwgfN+Lt4Bv5D7Liy3mx1eqt6gH6YEuemG8ksCFa8rLYYbBja6wdG0Q2jZqUgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DEMMv+I/i7mhnlNLSk+XpMQHRds2QOl4rUVk74Q98VM=; b=rFiHiIn3B8NwtXLNDIajEldn72h1WqdlMdjaWwNKcasuXz1PeewllcQfLsRJaspuOMa3WUEyvJa+4qce3kiE/7q2btBroovH+SpUjYLnNiBIo+1ybEqqayEV0KN0AYIlBF++5W0l2zwt6b7O7qlRR3D8bcBwR0yMQBr9U2tL4oIF42o+e3uwdu4V2+0NxLv8fpt3qkM+Z/bgm1kFlxJXcGXzS4OVTjDgjDEtwcBO+FnJVSoK9f5iAf4KUQT0SoKB4X/aSn8j2lS3ko49ET0GP5i6F2zTcXjSRl4xv7LmVBCve0KOffJZIwv3M398eDIjVBn2fnWOlzxf0dba3decCQ== From: Milan Djokic To: "xen-devel@lists.xenproject.org" CC: Rahul Singh , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Jan Beulich , =?utf-8?B?Um9nZXIgUGF1IE1vbm7DqQ==?= , Milan Djokic Subject: [PATCH v2 05/23] xen/arm: vsmmuv3: Add dummy support for virtual SMMUv3 for guests Thread-Topic: [PATCH v2 05/23] xen/arm: vsmmuv3: Add dummy support for virtual SMMUv3 for guests Thread-Index: AQHcuxeRCCj9GQWOb0eOqcgO/HbEPA== Date: Mon, 23 Mar 2026 22:51:22 +0000 Message-ID: <718e92355669dac42c682544c451e7cb417b4b1f.1774305918.git.milan_djokic@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI1PR03MB5088:EE_|AS8PR03MB7653:EE_ x-ms-office365-filtering-correlation-id: 4c240261-9cd4-4029-d2af-08de892eb473 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|366016|376014|1800799024|38070700021|22082099003|18002099003|56012099003; x-microsoft-antispam-message-info: trjDEhyEVEDx3Yw536NCR2A71C6k0ucEuMOSmb9VEED/6ndw6Z+A4SKY3203RU+nDT66KBQxKQRUg8y0J2kTb1CaXc4hYDDx0ZuFFRUY3WbwyN5+yyT/76iHQlEoyn2RgH/gxxoccCuqFc2ahOjN1m6rZGc0/s0OGyGloO3qUvCMnpi36fCUvEfGIlDotO9cEfkkm/7ftvpmxRt1G7LIb9OzMJy4Hpo804IjxhSiyy9N98LYzmprjy1K8IqxNuKPPV4HuF/CYysfKKW/1jMHWHOPMQTzqfeevBsaddG2/+3KP7aP/540Hnu4CKUYiaX1RjScB3lzfiP+dJOSnt5dwwOylTqHbSjYfLCfQiyYgM/8AATxRa4o/OfdOWP6yTdo6e3QKTshtjr7+U62LSJa94PREgjK3iHGRF+9O9yWiyulYwM1QE7JuBLI4S3/T7L5Q0SlH1O+2Xg/QFT7VEcpBZVzI6yJp+72vbqiPRVATckG533RDeFrSckEiXO7+IhAljqnj/V8r60VacNQZ5BSGH65mgMvr3wMLQB7BHphbJoYtHn1GyZJmaCbUqG4T8nYvyk6DYT4SDOLx3Hnpp121fOnCsGN7X3BdF0DdinR+V57UjmNtvIxyxdZsmkk+4hMWzJF4QAWsjmIl+IyY/BqO/xWsRlK1mjf4UNaXncsZtFf/x06dKuqWAs8yjxQlAu917WUAQDt5jSXszvVJC3XSR0oJsOJhbCYI91yeDVD5sVAyT5bIT8P+EXjQCknMpkbVNdk1Nwkt+dzZHCA/yoWE6kEfoyCO6ZRZXknz4SNGi8= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB5088.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024)(38070700021)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?B?UGRqdzgwbyt2aTNJL3BxQWRicitzeGExQW5vUzRzVVFaZXVKRXBUeUpSZUhP?= =?utf-8?B?ajhmaE1qbVBvNWYydmwvS0Y4ZVRRd01VL1BRSFRzK1U1bDMybjY0QUVDRC9u?= =?utf-8?B?cE1VejdJZ2tEYlFKUUhRcERUclEzaDJiMVY2WlNVWlA1SUVMWWV3UWc2dER3?= =?utf-8?B?c3E4aHFDV1NRbFU1OVZkV0NWajNrOGE3b3BuS1pGcXhRRHNTbks5UnlLOHpt?= =?utf-8?B?K1cvT0FldnFMWTE3Y1RqWXc5WFpmRnpyRDlDU2x0ZU9jT3NkMTAyZ2Y4VUF3?= =?utf-8?B?UlRUdUQ1ZkJQaFd4WDdGYms3bTVRYlpWMERuTVM3TjFNQ25mUDB4MDluQmpD?= =?utf-8?B?eTF1TkIwTHdHbm56bU5RaERoZHZFek43UEFuQ1dVajVDUkJCelJLUHg4OVdW?= =?utf-8?B?azU2U3FHWTYxL1IwcmM3aVkyYlN2Qjl3ako1WmI0VGhFT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wSkcxazdLTXBjNVY3ejQrb0ozNzc5N0xOSEgrOWk5UTVQ?= =?utf-8?B?RDROSEtxYVBDcEM0ZzBqOW9DekFreDNwN0l2V1VCcmg4cldLZHgrbTYwbGZP?= =?utf-8?Q?xr86lR2ciTWV5Xs4=3D?= Content-Type: text/plain; charset="utf-8" Content-ID: <4B55E1E338263649B0FCEF92512AFBDE@eurprd03.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB5088.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c240261-9cd4-4029-d2af-08de892eb473 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2026 22:51:22.1814 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LLjQFLFtQkJ+gQOPb9PmZmWcfSEAJg1511nXQuTPZQYrwHp7XLR3CefraQ3cH6peZ4fV2o7fpMvkmbgR5ZK7zA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7653 X-purgate-ID: tlsNG-720697/1774306284-42298DB8-47118C21/0/0 X-purgate-type: clean X-purgate-size: 16972 X-ZohoMail-DKIM: pass (identity @epam.com) X-ZM-MESSAGEID: 1774306306084158500 From: Rahul Singh domain_viommu_init() will be called during domain creation and will add the dummy trap handler for virtual IOMMUs for guests. A host IOMMU list will be created when host IOMMU devices are probed and this list will be used to create the IOMMU device tree node for dom0. For dom0, 1-1 mapping will be established between vIOMMU in dom0 and=C2=A0physical IOMMU. For domUs, the 1-N mapping will be established between domU and physical IOMMUs. A new area has been reserved in the arm guest physical map at which the emulated vIOMMU node is created in the device tree. Also set the vIOMMU type to vSMMUv3 to enable vIOMMU framework to call vSMMUv3 domain creation/destroy functions. Signed-off-by: Rahul Singh Signed-off-by: Milan Djokic --- xen/arch/arm/domain.c | 3 +- xen/arch/arm/include/asm/domain.h | 4 + xen/arch/arm/include/asm/viommu.h | 20 ++++ xen/drivers/passthrough/Kconfig | 8 ++ xen/drivers/passthrough/arm/Makefile | 1 + xen/drivers/passthrough/arm/smmu-v3.c | 7 ++ xen/drivers/passthrough/arm/viommu.c | 30 ++++++ xen/drivers/passthrough/arm/vsmmu-v3.c | 124 +++++++++++++++++++++++++ xen/drivers/passthrough/arm/vsmmu-v3.h | 20 ++++ xen/include/public/arch-arm.h | 7 +- 10 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 xen/drivers/passthrough/arm/vsmmu-v3.c create mode 100644 xen/drivers/passthrough/arm/vsmmu-v3.h diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 37511c9323..badfdbfc63 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -635,7 +635,8 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) return -EINVAL; } =20 - if ( config->arch.viommu_type !=3D XEN_DOMCTL_CONFIG_VIOMMU_NONE ) + if ( config->arch.viommu_type !=3D XEN_DOMCTL_CONFIG_VIOMMU_NONE && + config->arch.viommu_type !=3D viommu_get_type() ) { dprintk(XENLOG_INFO, "vIOMMU type requested not supported by the platform or Xe= n\n"); diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index 758ad807e4..35ff5c81bd 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -126,6 +126,10 @@ struct arch_domain void *sci_data; #endif =20 +#ifdef CONFIG_VIRTUAL_IOMMU + struct list_head viommu_list; /* List of virtual IOMMUs */ +#endif + } __cacheline_aligned; =20 struct arch_vcpu diff --git a/xen/arch/arm/include/asm/viommu.h b/xen/arch/arm/include/asm/v= iommu.h index 7cd3818a12..4785877e2a 100644 --- a/xen/arch/arm/include/asm/viommu.h +++ b/xen/arch/arm/include/asm/viommu.h @@ -5,9 +5,21 @@ #ifdef CONFIG_VIRTUAL_IOMMU =20 #include +#include #include #include =20 +extern struct list_head host_iommu_list; + +/* data structure for each hardware IOMMU */ +struct host_iommu { + struct list_head entry; + const struct dt_device_node *dt_node; + paddr_t addr; + paddr_t size; + uint32_t irq; +}; + struct viommu_ops { /* * Called during domain construction if toolstack requests to enable @@ -35,6 +47,8 @@ struct viommu_desc { int domain_viommu_init(struct domain *d, uint16_t viommu_type); int viommu_relinquish_resources(struct domain *d); uint16_t viommu_get_type(void); +void add_to_host_iommu_list(paddr_t addr, paddr_t size, + const struct dt_device_node *node); =20 #else =20 @@ -56,6 +70,12 @@ static inline int viommu_relinquish_resources(struct dom= ain *d) return 0; } =20 +static inline void add_to_host_iommu_list(paddr_t addr, paddr_t size, + const struct dt_device_node *nod= e) +{ + return; +} + #endif /* CONFIG_VIRTUAL_IOMMU */ =20 #endif /* __ARCH_ARM_VIOMMU_H__ */ diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kcon= fig index 487331607c..54a72303d8 100644 --- a/xen/drivers/passthrough/Kconfig +++ b/xen/drivers/passthrough/Kconfig @@ -40,6 +40,14 @@ config VIRTUAL_IOMMU help Support virtual IOMMU infrastructure to implement vIOMMU. =20 +config VIRTUAL_ARM_SMMU_V3 + bool "ARM Ltd. Virtual SMMUv3 Support (UNSUPPORTED)" if UNSUPPORTED + depends on ARM_SMMU_V3 && VIRTUAL_IOMMU + help + Support for implementations of the virtual ARM System MMU architecture + version 3. Virtual SMMUv3 is unsupported feature and should not be used + in production. + endif =20 config AMD_IOMMU diff --git a/xen/drivers/passthrough/arm/Makefile b/xen/drivers/passthrough= /arm/Makefile index 4cc54f3f4d..e758a9d6aa 100644 --- a/xen/drivers/passthrough/arm/Makefile +++ b/xen/drivers/passthrough/arm/Makefile @@ -3,3 +3,4 @@ obj-$(CONFIG_ARM_SMMU) +=3D smmu.o obj-$(CONFIG_IPMMU_VMSA) +=3D ipmmu-vmsa.o obj-$(CONFIG_ARM_SMMU_V3) +=3D smmu-v3.o obj-$(CONFIG_VIRTUAL_IOMMU) +=3D viommu.o +obj-$(CONFIG_VIRTUAL_ARM_SMMU_V3) +=3D vsmmu-v3.o diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthroug= h/arm/smmu-v3.c index 19e55b6c9b..87612df21d 100644 --- a/xen/drivers/passthrough/arm/smmu-v3.c +++ b/xen/drivers/passthrough/arm/smmu-v3.c @@ -93,6 +93,7 @@ #include =20 #include "smmu-v3.h" +#include "vsmmu-v3.h" =20 #define ARM_SMMU_VTCR_SH_IS 3 #define ARM_SMMU_VTCR_RGN_WBWA 1 @@ -2727,6 +2728,9 @@ static int __init arm_smmu_device_probe(struct platfo= rm_device *pdev) list_add(&smmu->devices, &arm_smmu_devices); spin_unlock(&arm_smmu_devices_lock); =20 + /* Add to host IOMMU list to initialize vIOMMU for dom0 */ + add_to_host_iommu_list(ioaddr, iosize, dev_to_dt(pdev)); + return 0; =20 =20 @@ -3058,6 +3062,9 @@ static __init int arm_smmu_dt_init(struct dt_device_n= ode *dev, =20 platform_features &=3D smmu->features; =20 + /* Set vIOMMU type to SMMUv3 */ + vsmmuv3_set_type(); + return 0; } =20 diff --git a/xen/drivers/passthrough/arm/viommu.c b/xen/drivers/passthrough= /arm/viommu.c index 7ab6061e34..53ae46349a 100644 --- a/xen/drivers/passthrough/arm/viommu.c +++ b/xen/drivers/passthrough/arm/viommu.c @@ -2,12 +2,42 @@ =20 #include #include +#include #include =20 #include =20 +/* List of all host IOMMUs */ +LIST_HEAD(host_iommu_list); + const struct viommu_desc __read_mostly *cur_viommu; =20 +/* Common function for adding to host_iommu_list */ +void add_to_host_iommu_list(paddr_t addr, paddr_t size, + const struct dt_device_node *node) +{ + struct host_iommu *iommu_data; + + iommu_data =3D xzalloc(struct host_iommu); + if ( !iommu_data ) + panic("vIOMMU: Cannot allocate memory for host IOMMU data\n"); + + iommu_data->addr =3D addr; + iommu_data->size =3D size; + iommu_data->dt_node =3D node; + iommu_data->irq =3D platform_get_irq(node, 0); + if ( iommu_data->irq < 0 ) + { + gdprintk(XENLOG_ERR, + "vIOMMU: Cannot find a valid IOMMU irq\n"); + return; + } + + printk("vIOMMU: Found IOMMU @0x%"PRIx64"\n", addr); + + list_add_tail(&iommu_data->entry, &host_iommu_list); +} + int domain_viommu_init(struct domain *d, uint16_t viommu_type) { if ( viommu_type =3D=3D XEN_DOMCTL_CONFIG_VIOMMU_NONE ) diff --git a/xen/drivers/passthrough/arm/vsmmu-v3.c b/xen/drivers/passthrou= gh/arm/vsmmu-v3.c new file mode 100644 index 0000000000..6b4009e5ef --- /dev/null +++ b/xen/drivers/passthrough/arm/vsmmu-v3.c @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ + +#include +#include +#include +#include + +/* Struct to hold the vIOMMU ops and vIOMMU type */ +extern const struct viommu_desc __read_mostly *cur_viommu; + +struct virt_smmu { + struct domain *d; + struct list_head viommu_list; +}; + +static int vsmmuv3_mmio_write(struct vcpu *v, mmio_info_t *info, + register_t r, void *priv) +{ + return IO_HANDLED; +} + +static int vsmmuv3_mmio_read(struct vcpu *v, mmio_info_t *info, + register_t *r, void *priv) +{ + return IO_HANDLED; +} + +static const struct mmio_handler_ops vsmmuv3_mmio_handler =3D { + .read =3D vsmmuv3_mmio_read, + .write =3D vsmmuv3_mmio_write, +}; + +static int vsmmuv3_init_single(struct domain *d, paddr_t addr, paddr_t siz= e) +{ + struct virt_smmu *smmu; + + smmu =3D xzalloc(struct virt_smmu); + if ( !smmu ) + return -ENOMEM; + + smmu->d =3D d; + + register_mmio_handler(d, &vsmmuv3_mmio_handler, addr, size, smmu); + + /* Register the vIOMMU to be able to clean it up later. */ + list_add_tail(&smmu->viommu_list, &d->arch.viommu_list); + + return 0; +} + +int domain_vsmmuv3_init(struct domain *d) +{ + int ret; + INIT_LIST_HEAD(&d->arch.viommu_list); + + if ( is_hardware_domain(d) ) + { + struct host_iommu *hw_iommu; + + list_for_each_entry(hw_iommu, &host_iommu_list, entry) + { + ret =3D vsmmuv3_init_single(d, hw_iommu->addr, hw_iommu->size); + if ( ret ) + return ret; + } + } + else + { + ret =3D vsmmuv3_init_single(d, GUEST_VSMMUV3_BASE, GUEST_VSMMUV3_S= IZE); + if ( ret ) + return ret; + } + + return 0; +} + +int vsmmuv3_relinquish_resources(struct domain *d) +{ + struct virt_smmu *pos, *temp; + + /* Cope with unitialized vIOMMU */ + if ( list_head_is_null(&d->arch.viommu_list) ) + return 0; + + list_for_each_entry_safe(pos, temp, &d->arch.viommu_list, viommu_list ) + { + list_del(&pos->viommu_list); + xfree(pos); + } + + return 0; +} + +static const struct viommu_ops vsmmuv3_ops =3D { + .domain_init =3D domain_vsmmuv3_init, + .relinquish_resources =3D vsmmuv3_relinquish_resources, +}; + +static const struct viommu_desc vsmmuv3_desc =3D { + .ops =3D &vsmmuv3_ops, + .viommu_type =3D XEN_DOMCTL_CONFIG_VIOMMU_SMMUV3, +}; + +void __init vsmmuv3_set_type(void) +{ + const struct viommu_desc *desc =3D &vsmmuv3_desc; + + if ( cur_viommu && (cur_viommu !=3D desc) ) + { + printk("WARNING: Cannot set vIOMMU, already set to a different val= ue\n"); + return; + } + + cur_viommu =3D desc; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/drivers/passthrough/arm/vsmmu-v3.h b/xen/drivers/passthrou= gh/arm/vsmmu-v3.h new file mode 100644 index 0000000000..e11f85b431 --- /dev/null +++ b/xen/drivers/passthrough/arm/vsmmu-v3.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ +#ifndef __ARCH_ARM_VSMMU_V3_H__ +#define __ARCH_ARM_VSMMU_V3_H__ + +#include + +#ifdef CONFIG_VIRTUAL_ARM_SMMU_V3 + +void vsmmuv3_set_type(void); + +#else + +static inline void vsmmuv3_set_type(void) +{ + return; +} + +#endif /* CONFIG_VIRTUAL_ARM_SMMU_V3 */ + +#endif /* __ARCH_ARM_VSMMU_V3_H__ */ diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index b1db2bf19d..9371c163c4 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -330,7 +330,8 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); #define XEN_DOMCTL_CONFIG_ARM_SCI_NONE 0 #define XEN_DOMCTL_CONFIG_ARM_SCI_SCMI_SMC 1 =20 -#define XEN_DOMCTL_CONFIG_VIOMMU_NONE 0 +#define XEN_DOMCTL_CONFIG_VIOMMU_NONE 0 +#define XEN_DOMCTL_CONFIG_VIOMMU_SMMUV3 1 =20 struct xen_arch_domainconfig { /* IN/OUT */ @@ -455,6 +456,10 @@ typedef uint64_t xen_callback_t; #define GUEST_GICV3_GICR0_BASE xen_mk_ullong(0x03020000) /* vCPU0..127= */ #define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) =20 +/* vsmmuv3 ITS mappings */ +#define GUEST_VSMMUV3_BASE xen_mk_ullong(0x04040000) +#define GUEST_VSMMUV3_SIZE xen_mk_ullong(0x00040000) + /* * 256 MB is reserved for VPCI configuration space based on calculation * 256 buses x 32 devices x 8 functions x 4 KB =3D 256 MB --=20 2.43.0