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

[RFC PATCH v1 04/26] xen/arm/cca: add Realm domain and vCPU state


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Koichiro Den <den@xxxxxxxxxxxxx>
  • Date: Fri, 15 May 2026 13:07:50 +0900
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none
  • 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=GHrMD1ZRwMJqiJUr8zXCjReMk57kt2vx8gsp61dgHdY=; b=BMTlo11NVJUJKLoF1fFHOT3BLVHDvz3jz97w0j7z0YCY43sWy5nixffvvuSF+SB7+WXYojmREaiVfkdD61l1RHLiaMK1yCJUwUw4lJEz3Knfpir53zi1+yOTILlwhJYACcSQ6vaa83dFs1/V4HXZkzJWjh4GSHN46DXf26GFAvf5WcsJzh5PKJpDdNkxpeudCCL8yqMua5pi7aYUNUrSvmrqPGPNSXfjDHvhIq5SYcMrSWR1Sl5y9XcQCWAbGa1/FzDVEmQd9FRWMMybrJn2AV+sHvq3EY1X5RtbIO+niEU/LL64RBpEsToBBA78JVJDfXZgrUDW+eBl5ShY5ILaPQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mTaEbr6yRRq0aXvYCtBaJkIVY2thhsVNnScppWcep2Ie5zC1kfPd8tlk6tGy7CWhO+IhekcDDt8uQAXlrijDTlXfBAn8UUgd5lUhoO12WbRd/GxjBJzrxt7vBBeI2uN7if99lpT3ycYfJSjm2hOZe/GIjDLvS7Ilh9IA7bqbxUJM79xmMfnzpFcXb0SOTZCdQhxup9sDubjwm/GE7kNVHyT+0uD6QRPBkqTw13CNFRbrHa4DSqLJjuXdSp97Ic6SeEr4bCmunjFV3zida/bm/QSHeQOMsB3IVDg8RZRSr/vlI8yGE4Dkq5ZLRmU8t1k7wS8eaJ5SHeBpxaWMon8coA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 15 May 2026 04:08:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Add the per-domain and per-vCPU state needed before Realm objects are
created: Realm state, RMI feature snapshots, REC bookkeeping and RecRun
lifetime.

Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
---
 xen/arch/arm/cca/Makefile         |  1 +
 xen/arch/arm/cca/state.c          | 68 +++++++++++++++++++++++++++++++
 xen/arch/arm/domain.c             | 14 +++++++
 xen/arch/arm/include/asm/cca.h    | 42 +++++++++++++++++++
 xen/arch/arm/include/asm/domain.h | 16 ++++++++
 5 files changed, 141 insertions(+)
 create mode 100644 xen/arch/arm/cca/state.c
 create mode 100644 xen/arch/arm/include/asm/cca.h

diff --git a/xen/arch/arm/cca/Makefile b/xen/arch/arm/cca/Makefile
index 9c351f901dfd..aaa04e3b914b 100644
--- a/xen/arch/arm/cca/Makefile
+++ b/xen/arch/arm/cca/Makefile
@@ -1 +1,2 @@
 obj-y += rmi.o
+obj-y += state.o
diff --git a/xen/arch/arm/cca/state.c b/xen/arch/arm/cca/state.c
new file mode 100644
index 000000000000..a47d9cd7b6fd
--- /dev/null
+++ b/xen/arch/arm/cca/state.c
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/sched.h>
+
+#include <asm/cca.h>
+
+#include "rmi.h"
+
+static void arm_cca_reset_domain_state(struct domain *d)
+{
+    d->arch.cca.realm_active = false;
+    d->arch.cca.rd = INVALID_PADDR;
+    d->arch.cca.rmi_features0 = 0;
+    d->arch.cca.rmi_features1 = 0;
+}
+
+static void arm_cca_reset_vcpu_state(struct vcpu *v)
+{
+    v->arch.cca.rec = INVALID_PADDR;
+    v->arch.cca.run = NULL;
+    v->arch.cca.run_pa = INVALID_PADDR;
+}
+
+void arm_cca_domain_init(struct domain *d)
+{
+    arm_cca_reset_domain_state(d);
+}
+
+void arm_cca_domain_destroy(struct domain *d)
+{
+    arm_cca_reset_domain_state(d);
+}
+
+void arm_cca_vcpu_init(struct vcpu *v)
+{
+    arm_cca_reset_vcpu_state(v);
+}
+
+void arm_cca_vcpu_destroy(struct vcpu *v)
+{
+    if ( v->arch.cca.run )
+        arm_cca_free_rec_run(v->arch.cca.run);
+
+    arm_cca_reset_vcpu_state(v);
+}
+
+void *arm_cca_alloc_rec_run(void)
+{
+    void *run;
+
+    BUILD_BUG_ON(sizeof(struct arm_cca_rmi_rec_run) !=
+                 ARM_CCA_RMI_REC_RUN_SIZE);
+
+    run = alloc_xenheap_page();
+    if ( run == NULL )
+        return NULL;
+
+    clear_page(run);
+
+    return run;
+}
+
+void arm_cca_free_rec_run(void *run)
+{
+    free_xenheap_page(run);
+}
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 26380a807cad..4b6115491c59 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -482,6 +482,10 @@ int arch_vcpu_create(struct vcpu *v)
     v->arch.saved_context.sp = (register_t)v->arch.cpu_info;
     v->arch.saved_context.pc = (register_t)continue_new_vcpu;
 
+#ifdef CONFIG_ARM_CCA
+    arm_cca_vcpu_init(v);
+#endif
+
     /* Idle VCPUs don't need the rest of this setup */
     if ( is_idle_vcpu(v) )
         return rc;
@@ -526,6 +530,9 @@ fail:
 
 void arch_vcpu_destroy(struct vcpu *v)
 {
+#ifdef CONFIG_ARM_CCA
+    arm_cca_vcpu_destroy(v);
+#endif
     if ( is_sve_domain(v->domain) )
         sve_context_free(v);
     vcpu_timer_destroy(v);
@@ -642,6 +649,10 @@ int arch_domain_create(struct domain *d,
 
     BUILD_BUG_ON(GUEST_MAX_VCPUS < MAX_VIRT_CPUS);
 
+#ifdef CONFIG_ARM_CCA
+    arm_cca_domain_init(d);
+#endif
+
 #ifdef CONFIG_IOREQ_SERVER
     ioreq_domain_init(d);
 #endif
@@ -786,6 +797,9 @@ void arch_domain_destroy(struct domain *d)
 {
     resume_ctx_reset(&d->arch.resume_ctx);
 
+#ifdef CONFIG_ARM_CCA
+    arm_cca_domain_destroy(d);
+#endif
     tee_free_domain_ctx(d);
     /* IOMMU page table is shared with P2M, always call
      * iommu_domain_destroy() before p2m_final_teardown().
diff --git a/xen/arch/arm/include/asm/cca.h b/xen/arch/arm/include/asm/cca.h
new file mode 100644
index 000000000000..1be43327119e
--- /dev/null
+++ b/xen/arch/arm/include/asm/cca.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef ARM_CCA_H
+#define ARM_CCA_H
+
+#include <xen/types.h>
+
+/*
+ * Keep the public ARM CCA arch header independent from the internal RMI ABI
+ * definitions that live under arch/arm/cca/.
+ *
+ * DEN0137 2.0-bet1 - B3.99 RecAuxCount caps the implementation-defined
+ * number of REC auxiliary granules.  REC_CREATE gets them through SRO
+ * donation.
+ */
+#define ARM_CCA_MAX_REC_AUX 16U
+
+struct domain;
+struct vcpu;
+
+struct arm_cca_domain_state {
+    bool realm_active;
+    paddr_t rd;
+    unsigned long rmi_features0;
+    unsigned long rmi_features1;
+};
+
+struct arm_cca_vcpu_state {
+    paddr_t rec;
+    void *run;
+    paddr_t run_pa;
+};
+
+void arm_cca_domain_init(struct domain *d);
+void arm_cca_domain_destroy(struct domain *d);
+
+void arm_cca_vcpu_init(struct vcpu *v);
+void arm_cca_vcpu_destroy(struct vcpu *v);
+
+void *arm_cca_alloc_rec_run(void);
+void arm_cca_free_rec_run(void *run);
+
+#endif /* ARM_CCA_H */
diff --git a/xen/arch/arm/include/asm/domain.h 
b/xen/arch/arm/include/asm/domain.h
index 46a5cdc0c800..25230c18d16b 100644
--- a/xen/arch/arm/include/asm/domain.h
+++ b/xen/arch/arm/include/asm/domain.h
@@ -3,6 +3,7 @@
 
 #include <xen/cache.h>
 #include <xen/timer.h>
+#include <asm/cca.h>
 #include <asm/page.h>
 #include <asm/p2m.h>
 #include <asm/suspend.h>
@@ -96,6 +97,9 @@ struct arch_domain
     /* ARM SCI driver's specific data */
     void *sci_data;
 #endif
+#ifdef CONFIG_ARM_CCA
+    struct arm_cca_domain_state cca;
+#endif
 
     struct resume_info resume_ctx;
 }  __cacheline_aligned;
@@ -207,6 +211,10 @@ struct arch_vcpu
     /* Timer registers  */
     register_t cntkctl;
 
+#ifdef CONFIG_ARM_CCA
+    struct arm_cca_vcpu_state cca;
+#endif
+
     struct vtimer phys_timer;
     struct vtimer virt_timer;
     bool   vtimer_initialized;
@@ -224,6 +232,14 @@ struct arch_vcpu
 void vcpu_show_registers(struct vcpu *v);
 void vcpu_switch_to_aarch64_mode(struct vcpu *v);
 
+#ifdef CONFIG_ARM_CCA
+#define is_domain_realm(d) ((d)->arch.cca.realm_active)
+#define is_vcpu_realm(v) is_domain_realm((v)->domain)
+#else
+#define is_domain_realm(d) ({ (void)(d); false; })
+#define is_vcpu_realm(v) ({ (void)(v); false; })
+#endif
+
 /*
  * Due to the restriction of GICv3, the number of vCPUs in AFF0 is
  * limited to 16, thus only the first 4 bits of AFF0 are legal. We will
-- 
2.51.0




 


Rackspace

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