[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 2/3] arm/mpu: Introduce `v8r_el1_msa` device tree property for domains


  • To: "Orzel, Michal" <Michal.Orzel@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Wed, 13 May 2026 08:54:17 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=amd.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=OcXmkXA27Cys9Y9PmY4NkZ7gwXBuk62oSprMZNpmrCA=; b=bOX/+mDZWxLQzQw02n+dUBE46w+NbniejqyP5klOttWzxhPC1w9GNj1MRIHbMYVjtHdxIXkC9ET22DnCQffyAJos2I7Hj0/foco/lnqZF7mFufxqk5NqTqwH8Vxj1RSRaT8bzMzHLdNyGri4vJvhMGg/cBnZnJuN155M2PZeYe6kMBuQYRRUoP7Pu095XGVztQqcDV9YgM4kYG/uxwz8NlCtEwCtFI+PnNKeSwIKbGORuMKmlJInLLYb6XyUBbTMinHOhX+S+7CmgsMulPuJxAKlvdYgZvofevaif8J7zf+/A8ScVnUoVCQOdhmZbSydmv+B1EUmCxXxfYLZbRT16w==
  • 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=OcXmkXA27Cys9Y9PmY4NkZ7gwXBuk62oSprMZNpmrCA=; b=E8gfyHFAVgo2IvZtpOaQEQVKUroKdj63yzceDgrgV2l80QMT8ShsaCDnqz18pzmQDiFiNseilfMP9QVfrtmGJctdr6dhMraooySQOL35N8FnFmMbOZ/Npfk9GhCTytbs78yrYVXHqrzW6gCGYbB8RQ84BVB5DSZT+XvkLYE+ipMVIFHCgf0+cPSeip4aap5Q+cA9MPAcsnRf0GI0rSTyMcm/ddVgKoYZC5DgSQSuOZ/yRbT8m6jR1X9f+rPjUJ8USiv4g5luio7vnSqR5GvGpN8EyNV2Rl4HaZgly3b+/0tRW9hZP5yYB1PtW4YcvSKlSW3PcOrcpxq76Pjyrv3+3g==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=v+78jAezfQLD74UQ+QHwyEY5qUUZ+IKF07GzwvKpb/xxmcu4MMFbeWRowkVH9camtzRig2RiwACILA7iIQNZ8YvRfIj83t3kXkriskvYHlJsg/OoCAEji+K1ir2VZR9Y0uQ8FK1HDfdfthLya0wYG77HsEaabiubSJ3cbQ6k401M5I21Jpdy+MFQolz5tiUvhviq8fxe0Z20jDSeGPEmQtKPa3WTGE9LzV6t1uvkJxBvLb4R4g2vA/AsQSm9u7ILtsuEJmN5wsCAITWTfYPyPa17t44+unxYeyNeInXAHsfWueXskvKPWst4RWgmHCPkcmMvD0NwG3LSz2TDSgRATg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZdqSaIkuJ4BYdVMYWAxPA/cZNbVDA6Zw70oTHIZ+H52U6Gcq0sm4kcbZ3D3Iuv8P0+uv6mqErI6m0/Yh8B70L3g4Px67Q0AXK+zXlZkCKNHb+zfWY8ZNZ2wZJ7p80zFocxDgQdlZBP2EUvtP+W1OmnJVUB5EVhddwzN5U4WcomC04so/M3QnNeaoGdBGPps2i3kcy6L8S+qx2buYxYFlz7cpcWzcVS9ZjNfzMSOK5myqhWSebabLgGQXw9moEFev+gbj1suuZ8R+NC+S17QRRYNjnu8d+/o3m9QxW53TLMYc1u3rDWeRBkCE4mTbVwgiiGZKc4HNKZk3pPIvr5Etxg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Harry Ramsey <Harry.Ramsey@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 13 May 2026 08:55:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHc4jjk+ii595NFpkWdCINvGnB407YLkW2AgAAWJQA=
  • Thread-topic: [PATCH v6 2/3] arm/mpu: Introduce `v8r_el1_msa` device tree property for domains

Hi Michal,

thanks for your review

>> 
>> +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");
> I know it's present in the code for SCI, but it's not really necessary to do 
> the
> DT parsing twice (once for boot, second for string given that
> dt_property_read_string returns -EINVAL if no property found).
> 
> You could move this bool check ...
> 
>> +
>> +    if ( !IS_ENABLED(CONFIG_MPU) )
>> +    {
>> +        d_cfg->arch.v8r_el1_msa = XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_NONE;
>> +
>> +        if ( !property_present )
> ... here.
> 
>> +            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;
> This does not look very clean. How about:
> 
> static int __init
> domu_dt_v8r_el1_msa_parse(const struct dt_device_node *node,
>                          struct xen_domctl_createdomain *d_cfg,
>                          unsigned int flags)
> {
>    const char *value;
>    int ret;
> 
>    if ( !IS_ENABLED(CONFIG_MPU) )
>    {
>        d_cfg->arch.v8r_el1_msa = XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_NONE;
> 
>        if ( !dt_property_read_bool(node, "v8r_el1_msa") )
>            return 0;
> 
>        printk(XENLOG_ERR
>               "v8r_el1_msa not supported on this build for domain %s\n",
>               dt_node_full_name(node));
>        return -EINVAL;
>    }
> 
>    ret = dt_property_read_string(node, "v8r_el1_msa", &value);
>    /* property absent: PMSA is the default */
>    if ( ret == -EINVAL )
>        value = "mpu";
>    else if ( ret )
>        return ret;
> 
>    if ( !strcmp(value, "mpu") )
>    {
>        if ( !(flags & CDF_staticmem) || !(flags & CDF_directmap) )
>        {
>            printk(XENLOG_ERR
>                   "v8r_el1_msa=mpu requires static-mem and direct-map for
> domain %s\n",
>                   dt_node_full_name(node));
>            return -EINVAL;
>        }
>        d_cfg->arch.v8r_el1_msa = XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_PMSA;
>        return 0;
>    }
> 
>    if ( !strcmp(value, "mmu") )
>    {
>        if ( !has_v8r_vmsa_support() )
>        {
>            printk(XENLOG_ERR
>                   "v8r_el1_msa=mmu unsupported by platform for domain %s\n",
>                   dt_node_full_name(node));
>            return -EINVAL;
>        }
>        d_cfg->arch.v8r_el1_msa = XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_VMSA;
>        return 0;
>    }
> 
>    printk(XENLOG_ERR "v8r_el1_msa value '%s' not valid for domain %s\n",
>           value, dt_node_full_name(node));
>    return -EINVAL;
> }

ack

> 
> 
>> +}
>> +
>> 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 <asm/cpuerrata.h>
>> #include <asm/cpufeature.h>
>> #include <asm/current.h>
>> +#include <asm/domain_build.h>
> You don't seem to use anything from this header.

Yep my bad, leftover

> 
>> #include <asm/event.h>
>> #include <asm/gic.h>
>> #include <asm/guest_atomics.h>
>> @@ -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;
> That is not a useful assignment.

yeah it was only to shorten the line

> 
>> +
>> +    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;
> Arm32 and Arm64 are mutually exclusive, so this line is unreachable.
> How about:
>  static bool v8r_el1_msa_domain_sanitise_config(
>      const struct xen_domctl_createdomain *config)
>  {
>      switch ( config->arch.v8r_el1_msa )
>      {
>      case XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_NONE:
>          return !IS_ENABLED(CONFIG_MPU);
> 
>      case XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_PMSA:
>          return IS_ENABLED(CONFIG_MPU);
> 
>      case XEN_DOMCTL_CONFIG_ARM_V8R_EL1_MSA_VMSA:
>          return IS_ENABLED(CONFIG_MPU) && IS_ENABLED(CONFIG_ARM_64);
> 
>      default:
>          return false;
>      }
>  }

ack

>> 
>> 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
> You could do: && CONFIG_ARM64 and then ...
> 
>> +/* 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 <asm/mpu.h>
>> #include <asm/sysregs.h>
>> #include <asm/system.h>
>> +#include <public/arch-arm.h>
>> +#include <public/domctl.h>
> You don't seem to add anything from these headers.

Yep, leftover

> 
>> 
>> #define GENERATE_WRITE_PR_REG_CASE(num, pr)               \
>>     case num:                                             \
>> @@ -38,6 +40,11 @@
>>         break;                                            \
>>     }
>> 
>> +bool has_v8r_vmsa_support(void)
>> +{
>> +    return false;
>> +}
> ... and then you could get rid of this stub

ack

>> +
>> /*
>>  * 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 <asm/mpu.h>
>> #include <asm/sysregs.h>
>> #include <asm/system.h>
>> +#include <public/arch-arm.h>
>> +#include <public/domctl.h>
> You don't seem to add anything from these headers.

Yep, leftover

Will respin with the fixes soon.

Cheers,
Luca




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.