From nobody Thu Mar 28 19:49:39 2024 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; dmarc=fail(p=quarantine dis=quarantine) header.from=epam.com ARC-Seal: i=1; a=rsa-sha256; t=1641900428; cv=none; d=zohomail.com; s=zohoarc; b=MLm88pOaUpIUuwm0scxmNvlNtGxQQ1YXARBcLeErjvzU4I9xkWEM8DZ9WSeCriYjbxvsWBPdm5n8TUXYxiokHIYzVNlndqc928Zxp8zSJeoDhTql6rWAxN3bzSDFNSXNnkf6kARK5rxW/786tPccS/Ov3TRV/Rd9g60P80IcCxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641900428; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=23NoJg+R89kxrynpjpFuKFaJMooSqFt4LeukXuorNY0=; b=KrOvvmiuymD0Hv/7eQ4TiAHSYr0ncOsqZx0cCgaF1OF4mfJEntkgBTjZbbLz88KPBYD4K6E3YYsUOipoPyS842GCEpbmSpinH3lRUxQSYLxa7rQXExw6WhmZErJ2TB+FHp6KyQgcuOM1MhBoO763VlHT42KI15S19ye3LNE7gWA= ARC-Authentication-Results: i=1; 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; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1641900428041815.8760142565887; Tue, 11 Jan 2022 03:27:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.255689.438195 (Exim 4.92) (envelope-from ) id 1n7FIJ-00082q-In; Tue, 11 Jan 2022 11:26:27 +0000 Received: by outflank-mailman (output) from mailman id 255689.438195; Tue, 11 Jan 2022 11:26:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7FIJ-00082j-Ex; Tue, 11 Jan 2022 11:26:27 +0000 Received: by outflank-mailman (input) for mailman id 255689; Tue, 11 Jan 2022 11:26:26 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n7FII-00082d-AB for xen-devel@lists.xenproject.org; Tue, 11 Jan 2022 11:26:26 +0000 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4c9b9ffb-72d1-11ec-9ce5-af14b9085ebd; Tue, 11 Jan 2022 12:26:23 +0100 (CET) Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 4EA38182890; Tue, 11 Jan 2022 06:26:19 -0500 (EST) (envelope-from sakib@darkstar.site) Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 46EAF18288F; Tue, 11 Jan 2022 06:26:19 -0500 (EST) (envelope-from sakib@darkstar.site) Received: from localhost (unknown [95.67.114.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id B5BC018288E; Tue, 11 Jan 2022 06:26:16 -0500 (EST) (envelope-from sakib@darkstar.site) 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" X-Inumbo-ID: 4c9b9ffb-72d1-11ec-9ce5-af14b9085ebd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; s=sasl; bh=C2gvrDaIP/qIIMWdeVG2fXwCMoogfeMZMUj8caL6/l8=; b=pjEl bL8/+TTOrtN6Z/BNTTAXrVoMJ2SHbD+3yy6vPTqn3V7EobzOGPaT7Q2UlvGUxb6p z5cIfStOZdcLKDZd/QXw/v/7/KkksghjeRv3BNH0SU2JxDU9ksgHBUeZussX+tgy 8uPeYsHVC+v1sbVs3vJnaUrENeEb/N04xeb22Lw= From: Sergiy Kibrik To: xen-devel@lists.xenproject.org Cc: Sergiy Kibrik , Stefano Stabellini , Julien Grall , Oleksandr Tyshchenko , Andrii Anisov Subject: [XEN PATCH v3] xen/arm: introduce dummy iommu node for dom0 Date: Tue, 11 Jan 2022 11:26:11 +0000 Message-Id: <20220111112611.90508-1-Sergiy_Kibrik@epam.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Pobox-Relay-ID: 4AA3904A-72D1-11EC-ADAA-C85A9F429DF0-90055647!pb-smtp20.pobox.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @pobox.com) X-ZM-MESSAGEID: 1641900430513100001 Content-Type: text/plain; charset="utf-8" Currently no IOMMU properties are exposed to dom0, thus kernel by default assumes no protection and enables swiotlb-xen, which leads to costly and unnecessary buffers bouncing. To let kernel know which device is behing IOMMU and hence needs no swiotlb services we introduce dummy xen-iommu node in FDT and link protected device nodes to it, using here device tree iommu bindings. Signed-off-by: Sergiy Kibrik Reviewed-by: Rahul Singh Reviewed-by: Stefano Stabellini --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Oleksandr Tyshchenko Cc: Andrii Anisov Changelog: v3: rebased over staging & remove redundand phandle_iommu attribute, discus= sion: https://lists.xenproject.org/archives/html/xen-devel/2021-12/msg01753.html v2: re-use common iommu dt bindings to let guests know which devices are pr= otected: https://lists.xenproject.org/archives/html/xen-devel/2021-10/msg00073.html xen/arch/arm/domain_build.c | 42 +++++++++++++++++++++++++++ xen/include/public/device_tree_defs.h | 1 + 2 files changed, 43 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 6931c022a2..b82ba72fac 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -845,6 +845,12 @@ static int __init write_properties(struct domain *d, s= truct kernel_info *kinfo, } } =20 + if ( iommu_node && is_iommu_enabled(d) && dt_device_is_protected(node)= ) + { + res =3D fdt_property_cell(kinfo->fdt, "iommus", GUEST_PHANDLE_IOMM= U); + if ( res ) + return res; + } return 0; } =20 @@ -1479,6 +1485,38 @@ static int __init make_cpus_node(const struct domain= *d, void *fdt) return res; } =20 +static int __init make_iommu_node(const struct domain *d, + const struct kernel_info *kinfo) +{ + const char compat[] =3D "xen,iommu-el2-v1"; + int res; + + if ( !is_iommu_enabled(d) ) + return 0; + + dt_dprintk("Create iommu node\n"); + + res =3D fdt_begin_node(kinfo->fdt, "xen-iommu"); + if ( res ) + return res; + + res =3D fdt_property(kinfo->fdt, "compatible", compat, sizeof(compat)); + if ( res ) + return res; + + res =3D fdt_property_cell(kinfo->fdt, "#iommu-cells", 0); + if ( res ) + return res; + + res =3D fdt_property_cell(kinfo->fdt, "phandle", GUEST_PHANDLE_IOMMU); + + res =3D fdt_end_node(kinfo->fdt); + if ( res ) + return res; + + return res; +} + static int __init make_gic_node(const struct domain *d, void *fdt, const struct dt_device_node *node) { @@ -2127,6 +2165,10 @@ static int __init handle_node(struct domain *d, stru= ct kernel_info *kinfo, if ( res ) return res; =20 + res =3D make_iommu_node(d, kinfo); + if ( res ) + return res; + res =3D make_memory_node(d, kinfo->fdt, addrcells, sizecells, &kin= fo->mem); if ( res ) return res; diff --git a/xen/include/public/device_tree_defs.h b/xen/include/public/dev= ice_tree_defs.h index 209d43de3f..df58944bd0 100644 --- a/xen/include/public/device_tree_defs.h +++ b/xen/include/public/device_tree_defs.h @@ -7,6 +7,7 @@ * onwards. Reserve a high value for the GIC phandle. */ #define GUEST_PHANDLE_GIC (65000) +#define GUEST_PHANDLE_IOMMU (GUEST_PHANDLE_GIC + 1) =20 #define GUEST_ROOT_ADDRESS_CELLS 2 #define GUEST_ROOT_SIZE_CELLS 2 --=20 2.25.1