[RFC PATCH 4/7] target/arm/cpu: Add FEAT_MEC object properties

Gustavo Romero posted 7 patches 2 weeks, 4 days ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>
[RFC PATCH 4/7] target/arm/cpu: Add FEAT_MEC object properties
Posted by Gustavo Romero 2 weeks, 4 days ago
Add 'mec' and 'mec-page' object properties to the Arm CPU object that
allows setting at machine level the memories used by FEAT_MEC.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
---
 target/arm/cpu.c | 20 ++++++++++++++++++++
 target/arm/cpu.h |  4 ++++
 2 files changed, 24 insertions(+)

diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 7e3e84b4bb..98bb559eb2 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1542,6 +1542,21 @@ static void arm_cpu_post_init(Object *obj)
                                      OBJ_PROP_LINK_STRONG);
         }
     }
+
+    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) &&
+        cpu_isar_feature(aa64_mec, cpu)) {
+
+        object_property_add_link(obj, "mec", TYPE_MEMORY_REGION,
+                                 (Object **)&cpu->mec,
+                                 qdev_prop_allow_set_link_before_realize,
+                                 OBJ_PROP_LINK_STRONG);
+
+        object_property_add_link(obj, "mec-page",
+                                 TYPE_MEMORY_REGION,
+                                 (Object **)&cpu->mec_page,
+                                 qdev_prop_allow_set_link_before_realize,
+                                 OBJ_PROP_LINK_STRONG);
+   }
 #endif
     qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property);
 }
@@ -2169,6 +2184,11 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
         }
     }
 
+    if (cpu->mec != NULL) {
+        cpu_address_space_init(cs, ARMASIdx_MEC, "cpu-tuple-memory", cpu->mec);
+        cpu_address_space_init(cs, ARMASIdx_MEC_PAGE, "cpu-pseudo-encrypted-page", cpu->mec_page);
+    }
+
     /* No core_count specified, default to smp_cpus. */
     if (cpu->core_count == -1) {
         cpu->core_count = smp_cpus;
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index ebf4e4e01c..a91db25d68 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -977,6 +977,10 @@ struct ArchCPU {
     MemoryRegion *tag_memory;
     MemoryRegion *secure_tag_memory;
 
+    /* MemoryRegion use by FEAT_MEC. */
+    MemoryRegion *mec;
+    MemoryRegion *mec_page;
+
     /* For v8M, pointer to the IDAU interface provided by board/SoC */
     Object *idau;
 
-- 
2.34.1
Re: [RFC PATCH 4/7] target/arm/cpu: Add FEAT_MEC object properties
Posted by Richard Henderson 1 week, 3 days ago
On 3/19/26 12:23, Gustavo Romero wrote:
> Add 'mec' and 'mec-page' object properties to the Arm CPU object that
> allows setting at machine level the memories used by FEAT_MEC.
> 
> Signed-off-by: Gustavo Romero<gustavo.romero@linaro.org>
> ---
>   target/arm/cpu.c | 20 ++++++++++++++++++++
>   target/arm/cpu.h |  4 ++++
>   2 files changed, 24 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~