Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3D76CD343F for ; Tue, 12 May 2026 17:58:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1307398.1579120 (Exim 4.92) (envelope-from ) id 1wMrMa-0003VD-Iy; Tue, 12 May 2026 17:57:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1307398.1579120; Tue, 12 May 2026 17:57:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMrMa-0003Tz-Fu; Tue, 12 May 2026 17:57:48 +0000 Received: by outflank-mailman (input) for mailman id 1307398; Tue, 12 May 2026 17:57:47 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMrMZ-0003OZ-45 for xen-devel@lists.xenproject.org; Tue, 12 May 2026 17:57:47 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wMrMW-009D7s-Vd for xen-devel@lists.xenproject.org; Tue, 12 May 2026 19:57:46 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a036a11-bab6-0a2a0a5309dd-0a2a4502963a-14 for ; Tue, 12 May 2026 19:57:46 +0200 Received: from [217.140.110.172] (helo=foss.arm.com) by tlsNG-720697.mxtls.expurgate.net with ESMTP (eXpurgate 4.56.1) (envelope-from ) id 6a036a19-af86-0a2a45020019-d98c6eacd7ce-1 for ; Tue, 12 May 2026 19:57:46 +0200 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 E6CC51684; Tue, 12 May 2026 10:57:39 -0700 (PDT) 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 A60AE3F85F; Tue, 12 May 2026 10:57:43 -0700 (PDT) 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=foss header.d=arm.com header.i="@arm.com" header.h="From:To:Cc:Subject:Date:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778608665; bh=pUlihSCtoluRvHSQDgApxcwFy6+3MCxnxU+k0Ku8GtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TBbSArrt/uJJn0ZPk8KH0Uc5HoDBRzJdPOfk8dunk+ud0bHsMl8NKbiZWoZgLAzT7 H1utUjad+9BZPz3jIv7WhTjgsdbkydUJkoqCHDyRc05g/kAu3vjp9V2ISgAS/aBdci WYTxFgBrnxLIPkUxhHhiVBRnDADroFY1jgRm7rGk= From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: Harry Ramsey , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v6 2/3] arm/mpu: Introduce `v8r_el1_msa` device tree property for domains Date: Tue, 12 May 2026 18:57:28 +0100 Message-Id: <20260512175729.1915120-3-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260512175729.1915120-1-luca.fancellu@arm.com> References: <20260512175729.1915120-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-720697/1778608666-A9B70161-2DB769CA/0/0 X-purgate-type: clean X-purgate-size: 12627 From: Harry Ramsey Add a new device tree property `v8r_el1_msa` to select the MSA (memory system architecture) at EL1 for Armv8-R architecture: MPU or MMU, the former is the default if the property is not passed. Implement the dom0less path to parse the new device tree property, add a new domctl hypercall input parameter `v8r_el1_msa` for arm and add the sanitisation in arch_sanitise_domain_config(), the parameter is intended to be used on CONFIG_MPU systems and returns an error if selected for MMU. While there, add explicit padding and check that it's zero during arch domain config sanitisation, given the breaking change, bump the XEN_DOMCTL_INTERFACE_VERSION. Signed-off-by: Harry Ramsey Signed-off-by: Luca Fancellu --- v6: - Add explicit padding to `struct xen_arch_domainconfig` and check it - Provide common v8r_el1_msa_domain_sanitise_config() for MMU/MPU - During domu_dt_v8r_el1_msa_parse() set PMSA when property not present - constify *node in domu_dt_v8r_el1_msa_parse() - Print full path of the node in domu_dt_v8r_el1_msa_parse() error msgs - typo fixing v5: - follow the way domu_dt_sci_parse and ARM_SCI is doing, but return error if property is present in MMU systems. - Align the commit message on the new changes - fix documentation - fix multiline comment - drop the explicit padding from struct xen_arch_domainconfig v4: - Rework the patch to have the v8r_el1_msa input parameter more enclosed in the Armv8-A (mmu)/Armv8-R (mpu) space. v3: - Improve commit message and device tree property description - Remove macro protection - Remove unused function is_mpu_domain - Code formatting --- docs/misc/arm/device-tree/booting.txt | 14 +++++ xen/arch/arm/dom0less-build.c | 74 +++++++++++++++++++++++++ xen/arch/arm/domain.c | 37 +++++++++++++ xen/arch/arm/include/asm/domain.h | 4 ++ xen/arch/arm/include/asm/domain_build.h | 10 ++++ xen/arch/arm/mpu/arm32/mm.c | 7 +++ xen/arch/arm/mpu/arm64/mm.c | 7 +++ xen/include/public/arch-arm.h | 7 +++ xen/include/public/domctl.h | 4 +- 9 files changed, 162 insertions(+), 2 deletions(-) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt index 977b4286082f..f73839df090b 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -322,6 +322,20 @@ with the following properties: Should be used together with scmi-smc-passthrough Xen command line option. +- v8r_el1_msa + + A string property specifying whether, on Armv8-R systems at EL1, a domain + should use PMSAv8 (MPU) or VMSAv8 (MMU). + + - "mmu" + Enables VMSAv8 at EL1. This requires hardware support and is only + optionally available on AArch64. Not supported on AArch32. + + - "mpu" + Enables PMSAv8 at EL1. This is the default behavior when the property is + not passed. This configuration requires static allocation (xen,static-mem) + and direct mapping (direct-map). + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk. diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 52cf788a45ea..fecdb33d3e3a 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -302,6 +302,77 @@ static int __init domu_dt_sci_parse(struct dt_device_node *node, return 0; } +static int __init +domu_dt_v8r_el1_msa_parse(const struct dt_device_node *node, + struct xen_domctl_createdomain *d_cfg, + unsigned int flags) +{ + bool property_present = dt_property_read_bool(node, "v8r_el1_msa"); + + if ( !IS_ENABLED(CONFIG_MPU) ) + { + d_cfg->arch.v8r_el1_msa = XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_NONE; + + if ( !property_present ) + return 0; + + printk(XENLOG_ERR + "Not supported 'v8r_el1_msa' DT property found for domain %s\n", + dt_node_full_name(node)); + return -EINVAL; + } + + if ( !property_present ) + d_cfg->arch.v8r_el1_msa = XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_PMSA; + else + { + const char *v8r_el1_msa; + int ret = dt_property_read_string(node, "v8r_el1_msa", &v8r_el1_msa); + + if ( ret ) + return ret; + + if ( !strcmp(v8r_el1_msa, "mpu") ) + d_cfg->arch.v8r_el1_msa = XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_PMSA; + else if ( !strcmp(v8r_el1_msa, "mmu") ) + d_cfg->arch.v8r_el1_msa = XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_VMSA; + else + { + printk(XENLOG_ERR + "v8r_el1_msa value (%s) not valid for domain %s\n", + v8r_el1_msa, dt_node_full_name(node)); + return -EINVAL; + } + } + + switch ( d_cfg->arch.v8r_el1_msa ) + { + case XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_PMSA: + if ( !(flags & CDF_staticmem) || !(flags & CDF_directmap) ) + { + printk(XENLOG_ERR + "PMSA is not valid for domain (%s) without static allocation and direct map (v8r_el1_msa)\n", + dt_node_full_name(node)); + return -EINVAL; + } + break; + + case XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_VMSA: + if ( !has_v8r_vmsa_support() ) + { + printk(XENLOG_ERR + "Platform doesn't support VMSA at EL1 (v8r_el1_msa)\n"); + return -EINVAL; + } + break; + + default: + return -EINVAL; + } + + return 0; +} + int __init arch_parse_dom0less_node(struct dt_device_node *node, struct boot_domain *bd) { @@ -315,6 +386,9 @@ int __init arch_parse_dom0less_node(struct dt_device_node *node, if ( domu_dt_sci_parse(node, d_cfg) ) panic("Error getting SCI configuration\n"); + if ( domu_dt_v8r_el1_msa_parse(node, d_cfg, flags) ) + panic("Error getting v8r_el1_msa configuration\n"); + if ( !dt_property_read_u32(node, "nr_spis", &d_cfg->arch.nr_spis) ) { int vpl011_virq = GUEST_VPL011_SPI; diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 26380a807cad..e579c3b1bb3c 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -538,6 +539,24 @@ void vcpu_switch_to_aarch64_mode(struct vcpu *v) v->arch.hcr_el2 |= HCR_RW; } +static bool v8r_el1_msa_domain_sanitise_config( + const struct xen_domctl_createdomain *config) +{ + uint8_t v8r_el1_msa = config->arch.v8r_el1_msa; + + if ( !IS_ENABLED(CONFIG_MPU) ) + return v8r_el1_msa == XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_NONE; + + if ( IS_ENABLED(CONFIG_ARM_32) ) + return v8r_el1_msa == XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_PMSA; + + if ( IS_ENABLED(CONFIG_ARM_64) ) + return (v8r_el1_msa == XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_PMSA) || + (v8r_el1_msa == XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_VMSA); + + return false; +} + int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) { unsigned int max_vcpus; @@ -554,6 +573,14 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } + /* Check config structure padding */ + if ( config->arch.pad ) + { + dprintk(XENLOG_INFO, + "Invalid domain configuration during domain creation\n"); + return -EINVAL; + } + /* Check feature flags */ if ( sve_vl_bits > 0 ) { @@ -630,6 +657,12 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } + if ( !v8r_el1_msa_domain_sanitise_config(config) ) + { + dprintk(XENLOG_INFO, "Unsupported v8r_el1_msa value\n"); + return -EINVAL; + } + return sci_domain_sanitise_config(config); } @@ -722,6 +755,10 @@ int arch_domain_create(struct domain *d, d->arch.sve_vl = config->arch.sve_vl; #endif +#ifdef CONFIG_MPU + d->arch.v8r_el1_msa = config->arch.v8r_el1_msa; +#endif + if ( (rc = sci_domain_init(d, config)) != 0 ) goto fail; diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index b24f02d269be..ac7300e41fcd 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -112,6 +112,10 @@ struct arch_domain #endif struct resume_info resume_ctx; + +#ifdef CONFIG_MPU + uint8_t v8r_el1_msa; +#endif } __cacheline_aligned; struct arch_vcpu diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include/asm/domain_build.h index 6674dac5e2f8..13e88fc0891b 100644 --- a/xen/arch/arm/include/asm/domain_build.h +++ b/xen/arch/arm/include/asm/domain_build.h @@ -19,6 +19,16 @@ int prepare_acpi(struct domain *d, struct kernel_info *kinfo); int add_ext_regions(unsigned long s_gfn, unsigned long e_gfn, void *data); +#ifdef CONFIG_MPU +/* Utility function to determine if an Armv8-R processor supports VMSA. */ +bool has_v8r_vmsa_support(void); +#else +static inline bool has_v8r_vmsa_support(void) +{ + return false; +} +#endif /* CONFIG_MPU */ + #endif /* diff --git a/xen/arch/arm/mpu/arm32/mm.c b/xen/arch/arm/mpu/arm32/mm.c index a4673c351141..702bea804acd 100644 --- a/xen/arch/arm/mpu/arm32/mm.c +++ b/xen/arch/arm/mpu/arm32/mm.c @@ -5,6 +5,8 @@ #include #include #include +#include +#include #define GENERATE_WRITE_PR_REG_CASE(num, pr) \ case num: \ @@ -38,6 +40,11 @@ break; \ } +bool has_v8r_vmsa_support(void) +{ + return false; +} + /* * Armv8-R supports direct access and indirect access to the MPU regions through * registers: diff --git a/xen/arch/arm/mpu/arm64/mm.c b/xen/arch/arm/mpu/arm64/mm.c index ed643cad4073..b8abcc6f7bc6 100644 --- a/xen/arch/arm/mpu/arm64/mm.c +++ b/xen/arch/arm/mpu/arm64/mm.c @@ -5,6 +5,8 @@ #include #include #include +#include +#include /* * The following are needed for the cases: GENERATE_WRITE_PR_REG_CASE @@ -32,6 +34,11 @@ break; \ } +bool has_v8r_vmsa_support(void) +{ + return system_cpuinfo.mm64.msa_frac == MM64_MSA_FRAC_VMSA_SUPPORT; +} + /* * Armv8-R supports direct access and indirect access to the MPU regions through * registers: diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index cd563cf70684..7d6f87e8b2b1 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -330,6 +330,10 @@ 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 +#define XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_NONE 0 +#define XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_PMSA 1 +#define XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_VMSA 2 + struct xen_arch_domainconfig { /* IN/OUT */ uint8_t gic_version; @@ -355,6 +359,9 @@ struct xen_arch_domainconfig { uint32_t clock_frequency; /* IN */ uint8_t arm_sci_type; + /* IN */ + uint8_t v8r_el1_msa; + uint16_t pad; }; #endif /* __XEN__ || __XEN_TOOLS__ */ diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 8f6708c0a7cd..23124547f347 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -30,9 +30,9 @@ * fields) don't require a change of the version. * Stable ops are NOT covered by XEN_DOMCTL_INTERFACE_VERSION! * - * Last version bump: Xen 4.19 + * Last version bump: Xen 4.22 */ -#define XEN_DOMCTL_INTERFACE_VERSION 0x00000017 +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000018 /* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. -- 2.34.1