From nobody Sun Mar 9 21:55:36 2025 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; 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=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1741334357497310.3620217611093; Thu, 6 Mar 2025 23:59:17 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.904638.1312494 (Exim 4.92) (envelope-from ) id 1tqSbW-0006Js-6Y; Fri, 07 Mar 2025 07:58:46 +0000 Received: by outflank-mailman (output) from mailman id 904638.1312494; Fri, 07 Mar 2025 07:58:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tqSbW-0006Jo-30; Fri, 07 Mar 2025 07:58:46 +0000 Received: by outflank-mailman (input) for mailman id 904638; Fri, 07 Mar 2025 07:58:44 +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 1tqSbU-00065D-MB for xen-devel@lists.xenproject.org; Fri, 07 Mar 2025 07:58:44 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id fcfa1e47-fb29-11ef-9ab5-95dc52dad729; Fri, 07 Mar 2025 08:58:43 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2C09022C7; Thu, 6 Mar 2025 23:58:55 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3EFD93F673; Thu, 6 Mar 2025 23:58:41 -0800 (PST) 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: fcfa1e47-fb29-11ef-9ab5-95dc52dad729 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v4 1/2] xen/passthrough: Provide stub functions when !HAS_PASSTHROUGH Date: Fri, 7 Mar 2025 07:58:17 +0000 Message-Id: <20250307075818.740649-2-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250307075818.740649-1-luca.fancellu@arm.com> References: <20250307075818.740649-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1741334359453019000 Content-Type: text/plain; charset="utf-8" When Xen is built without HAS_PASSTHROUGH, there are some parts in arm where iommu_* functions are called in the codebase, but their implementation is under xen/drivers/passthrough that is not built. So provide some stub for these functions in order to build Xen when !HAS_PASSTHROUGH, which is the case for example on systems with MPU support. For gnttab_need_iommu_mapping() in the Arm part, modify the macro to use IS_ENABLED for the HAS_PASSTHROUGH Kconfig. Fixes: 0388a5979b21 ("xen/arm: mpu: Introduce choice between MMU and MPU") Signed-off-by: Luca Fancellu Acked-by: Julien Grall --- v4 changes: - re-introduced stub for iommu_use_hap_pt, Stefano suggested it is ok to have it in iommu.h. - Reworded comment in iommu_domain_init from Jan suggestion v3 Changes: - removed stub for iommu_use_hap_pt, another solution will be done for the instance in common arm code. - Moved a comment close to the macro it was referred to - add comment to iommu_domain_init() stub - modified commit message - Add fixes tag v2 Changes: - modify gnttab_need_iommu_mapping to use IS_ENABLED - removed macro that didn't allow some of the parameter to be evaluated - Changed commit message --- --- xen/arch/arm/include/asm/grant_table.h | 5 +-- xen/include/xen/iommu.h | 50 +++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/include/asm/grant_table.h b/xen/arch/arm/include/= asm/grant_table.h index d3c518a926b9..c5d87b60c4df 100644 --- a/xen/arch/arm/include/asm/grant_table.h +++ b/xen/arch/arm/include/asm/grant_table.h @@ -73,8 +73,9 @@ int replace_grant_host_mapping(uint64_t gpaddr, mfn_t fra= me, #define gnttab_status_gfn(d, t, i) \ page_get_xenheap_gfn(gnttab_status_page(t, i)) =20 -#define gnttab_need_iommu_mapping(d) \ - (is_domain_direct_mapped(d) && is_iommu_enabled(d)) +#define gnttab_need_iommu_mapping(d) \ + (IS_ENABLED(CONFIG_HAS_PASSTHROUGH) && is_domain_direct_mapped(d) && \ + is_iommu_enabled(d)) =20 #endif /* __ASM_GRANT_TABLE_H__ */ /* diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 77a514019cc6..5ac038521e23 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -110,6 +110,8 @@ extern int8_t iommu_hwdom_reserved; =20 extern unsigned int iommu_dev_iotlb_timeout; =20 +#ifdef CONFIG_HAS_PASSTHROUGH + int iommu_setup(void); int iommu_hardware_setup(void); =20 @@ -122,6 +124,28 @@ int arch_iommu_domain_init(struct domain *d); void arch_iommu_check_autotranslated_hwdom(struct domain *d); void arch_iommu_hwdom_init(struct domain *d); =20 +#else + +static inline int iommu_setup(void) +{ + return -ENODEV; +} + +static inline int iommu_domain_init(struct domain *d, unsigned int opts) +{ + /* + * Return as the real iommu_domain_init() would: Success when + * !is_iommu_enabled(), following from !iommu_enabled when !HAS_PASSTH= ROUGH + */ + return 0; +} + +static inline void iommu_hwdom_init(struct domain *d) {} + +static inline void iommu_domain_destroy(struct domain *d) {} + +#endif /* HAS_PASSTHROUGH */ + /* * The following flags are passed to map (applicable ones also to unmap) * operations, while some are passed back by lookup operations. @@ -209,6 +233,8 @@ struct msi_msg; #ifdef CONFIG_HAS_DEVICE_TREE #include =20 +#ifdef CONFIG_HAS_PASSTHROUGH + int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev); int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev); int iommu_dt_domain_init(struct domain *d); @@ -238,6 +264,26 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, stru= ct domain *d, */ int iommu_remove_dt_device(struct dt_device_node *np); =20 +#else + +static inline int iommu_assign_dt_device(struct domain *d, + struct dt_device_node *dev) +{ + return -EINVAL; +} + +static inline int iommu_add_dt_device(struct dt_device_node *np) +{ + return 1; +} + +static inline int iommu_release_dt_devices(struct domain *d) +{ + return 0; +} + +#endif /* HAS_PASSTHROUGH */ + #endif /* HAS_DEVICE_TREE */ =20 struct page_info; @@ -383,17 +429,19 @@ struct domain_iommu { #define iommu_set_feature(d, f) set_bit(f, dom_iommu(d)->features) #define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features) =20 +#ifdef CONFIG_HAS_PASSTHROUGH /* Are we using the domain P2M table as its IOMMU pagetable? */ #define iommu_use_hap_pt(d) (IS_ENABLED(CONFIG_HVM) && \ dom_iommu(d)->hap_pt_share) =20 /* Does the IOMMU pagetable need to be kept synchronized with the P2M */ -#ifdef CONFIG_HAS_PASSTHROUGH #define need_iommu_pt_sync(d) (dom_iommu(d)->need_sync) =20 int iommu_do_domctl(struct xen_domctl *domctl, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl); #else +#define iommu_use_hap_pt(d) ({ (void)(d); false; }) + #define need_iommu_pt_sync(d) ({ (void)(d); false; }) =20 static inline int iommu_do_domctl(struct xen_domctl *domctl, struct domain= *d, --=20 2.34.1 From nobody Sun Mar 9 21:55:36 2025 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; 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=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1741334379129629.9804972053181; Thu, 6 Mar 2025 23:59:39 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.904639.1312504 (Exim 4.92) (envelope-from ) id 1tqSbc-0006c0-F2; Fri, 07 Mar 2025 07:58:52 +0000 Received: by outflank-mailman (output) from mailman id 904639.1312504; Fri, 07 Mar 2025 07:58:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tqSbc-0006bo-Bv; Fri, 07 Mar 2025 07:58:52 +0000 Received: by outflank-mailman (input) for mailman id 904639; Fri, 07 Mar 2025 07:58:50 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tqSba-0006aB-LE for xen-devel@lists.xenproject.org; Fri, 07 Mar 2025 07:58:50 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id fdbd3535-fb29-11ef-9898-31a8f345e629; Fri, 07 Mar 2025 08:58:44 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 70A0822C8; Thu, 6 Mar 2025 23:58:56 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C1CA73F673; Thu, 6 Mar 2025 23:58:42 -0800 (PST) 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: fdbd3535-fb29-11ef-9898-31a8f345e629 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v4 2/2] xen/arm: Restrict Kconfig configuration for LLC coloring Date: Fri, 7 Mar 2025 07:58:18 +0000 Message-Id: <20250307075818.740649-3-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250307075818.740649-1-luca.fancellu@arm.com> References: <20250307075818.740649-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1741334381318019000 Content-Type: text/plain; charset="utf-8" Xen LLC coloring feature can be used only on the MMU subsystem, move the code that selects it from ARM_64 to MMU and add the ARM_64 dependency. Signed-off-by: Luca Fancellu Reviewed-by: Michal Orzel --- v4 changes: - clarified that it's the Xen feature LLC coloring that is not applicable to the MPU subsystem, not the generic cache coloring method. - Add R-by Michal v3 changes: - Dropped comment on top of boot_fdt_info() v2 changes: - dropped part of the v1 code, now this one is simpler, I will discuss better how to design a common boot flow for MPU and implement on another patch. --- --- xen/arch/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index a26d3e11827c..ffdff1f0a36c 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -8,7 +8,6 @@ config ARM_64 depends on !ARM_32 select 64BIT select HAS_FAST_MULTIPLY - select HAS_LLC_COLORING if !NUMA =20 config ARM def_bool y @@ -76,6 +75,7 @@ choice =20 config MMU bool "MMU" + select HAS_LLC_COLORING if !NUMA && ARM_64 select HAS_PMAP select HAS_VMAP select HAS_PASSTHROUGH --=20 2.34.1