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 <[email protected]>
---
 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


Reply via email to