All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Vallejo <alejandro.vallejo@cloud.com>
To: xen-devel@lists.xenproject.org
Cc: Alejandro Vallejo <alejandro.vallejo@cloud.com>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: [RFC PATCH 15/25] xen/arm: Replace hand-crafted xen_arch_domainconfig with autogenerated one
Date: Fri, 15 Nov 2024 11:51:44 +0000	[thread overview]
Message-ID: <20241115115200.2824-16-alejandro.vallejo@cloud.com> (raw)
In-Reply-To: <20241115115200.2824-1-alejandro.vallejo@cloud.com>

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
---
 .../extra/arch-arm/domainconfig.toml          | 83 +++++++++++++++++++
 xen/arch/arm/domain.c                         |  4 +-
 xen/arch/arm/tee/tee.c                        |  1 +
 xen/include/public/arch-arm.h                 | 36 --------
 xen/include/public/autogen/arch_arm.h         | 59 +++++++++++++
 5 files changed, 145 insertions(+), 38 deletions(-)
 create mode 100644 tools/rust/xenbindgen/extra/arch-arm/domainconfig.toml
 create mode 100644 xen/include/public/autogen/arch_arm.h

diff --git a/tools/rust/xenbindgen/extra/arch-arm/domainconfig.toml b/tools/rust/xenbindgen/extra/arch-arm/domainconfig.toml
new file mode 100644
index 000000000000..d32963445765
--- /dev/null
+++ b/tools/rust/xenbindgen/extra/arch-arm/domainconfig.toml
@@ -0,0 +1,83 @@
+[[enums]]
+name = "xen_domctl_config_gic"
+description = "Content of the `gic_version` field of the domainconfig struct."
+typ = { tag = "u8" }
+
+[[enums.variants]]
+name = "native"
+description = "Emulate the underlying GIC present in the current host."
+value = 0
+
+[[enums.variants]]
+name = "v2"
+description = "Emulate a GICv2."
+value = 1
+
+[[enums.variants]]
+name = "v3"
+description = "Emulate a GICv3."
+value = 2
+
+################################################################################
+
+[[enums]]
+name = "xen_domctl_config_tee"
+description = "TEE mediator exposed to the guest"
+typ = { tag = "u16" }
+
+[[enums.variants]]
+name = "none"
+description = "No mediator. Guest can't communicate with the TEE."
+value = 0
+
+[[enums.variants]]
+name = "optee"
+description = "Expose an OP-TEE mediator."
+value = 1
+
+[[enums.variants]]
+name = "ffa"
+description = "Expose an FF-A mediator."
+value = 2
+
+################################################################################
+
+[[structs]]
+name = "xen_arch_domainconfig"
+description = "arm-specific domain settings."
+
+[[structs.fields]]
+name = "gic_version"
+description = """IN/OUT: GIC version exposed to the guest.
+
+When `native` on input the output value holds the automatically chosen version."""
+typ = { tag = "enum", args = "xen_domctl_config_gic" }
+
+[[structs.fields]]
+name = "sve_vl"
+description = "IN: SVE vector length (divided by 128) exposed to the guest."
+typ = { tag = "u8" }
+
+[[structs.fields]]
+name = "tee_type"
+description = "IN: TEE mediator exposed to the guest."
+typ = { tag = "enum", args = "xen_domctl_config_tee" }
+
+[[structs.fields]]
+name = "nr_spis"
+description = "IN: Number of SPIs exposed to the guest."
+typ = { tag = "u32" }
+
+[[structs.fields]]
+name = "clock_frequency"
+description = """OUT
+Based on the property clock-frequency in the DT timer node.
+The property may be present when the bootloader/firmware doesn't
+set correctly CNTFRQ which hold the timer frequency.
+
+As it's not possible to trap this register, we have to replicate
+the value in the guest DT.
+
+= 0 => property not present
+> 0 => Value of the property"""
+typ = { tag = "u32" }
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 54e849b02f9e..57ed11598754 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -639,10 +639,10 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
     }
 
     /* The P2M table must always be shared between the CPU and the IOMMU */
-    if ( config->iommu_opts & XEN_DOMCTL_IOMMU_no_sharept )
+    if ( config->iommu_opts & XEN_DOMCTL_IOMMU_OPTS_NO_SHAREPT )
     {
         dprintk(XENLOG_INFO,
-                "Unsupported iommu option: XEN_DOMCTL_IOMMU_no_sharept\n");
+                "Unsupported iommu option: XEN_DOMCTL_IOMMU_OPTS_NO_SHAREPT\n");
         return -EINVAL;
     }
 
diff --git a/xen/arch/arm/tee/tee.c b/xen/arch/arm/tee/tee.c
index 3f65e45a7892..c5f7629a227a 100644
--- a/xen/arch/arm/tee/tee.c
+++ b/xen/arch/arm/tee/tee.c
@@ -21,6 +21,7 @@
 #include <xen/types.h>
 
 #include <asm/tee/tee.h>
+#include <public/autogen/arch_arm.h>
 
 extern const struct tee_mediator_desc _steemediator[], _eteemediator[];
 static const struct tee_mediator_desc __read_mostly *cur_mediator;
diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index e2412a17474e..42ce9e64ed00 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -315,42 +315,6 @@ struct vcpu_guest_context {
 typedef struct vcpu_guest_context vcpu_guest_context_t;
 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
-/*
- * struct xen_arch_domainconfig's ABI is covered by
- * XEN_DOMCTL_INTERFACE_VERSION.
- */
-#define XEN_DOMCTL_CONFIG_GIC_NATIVE    0
-#define XEN_DOMCTL_CONFIG_GIC_V2        1
-#define XEN_DOMCTL_CONFIG_GIC_V3        2
-
-#define XEN_DOMCTL_CONFIG_TEE_NONE      0
-#define XEN_DOMCTL_CONFIG_TEE_OPTEE     1
-#define XEN_DOMCTL_CONFIG_TEE_FFA       2
-
-struct xen_arch_domainconfig {
-    /* IN/OUT */
-    uint8_t gic_version;
-    /* IN - Contains SVE vector length divided by 128 */
-    uint8_t sve_vl;
-    /* IN */
-    uint16_t tee_type;
-    /* IN */
-    uint32_t nr_spis;
-    /*
-     * OUT
-     * Based on the property clock-frequency in the DT timer node.
-     * The property may be present when the bootloader/firmware doesn't
-     * set correctly CNTFRQ which hold the timer frequency.
-     *
-     * As it's not possible to trap this register, we have to replicate
-     * the value in the guest DT.
-     *
-     * = 0 => property not present
-     * > 0 => Value of the property
-     *
-     */
-    uint32_t clock_frequency;
-};
 #endif /* __XEN__ || __XEN_TOOLS__ */
 
 struct arch_vcpu_info {
diff --git a/xen/include/public/autogen/arch_arm.h b/xen/include/public/autogen/arch_arm.h
new file mode 100644
index 000000000000..d19f639671e0
--- /dev/null
+++ b/xen/include/public/autogen/arch_arm.h
@@ -0,0 +1,59 @@
+/*
+ * arch-arm
+ *
+ * AUTOGENERATED. DO NOT MODIFY
+ */
+#ifndef __XEN_AUTOGEN_ARCH_ARM_H
+#define __XEN_AUTOGEN_ARCH_ARM_H
+
+/* Content of the `gic_version` field of the domainconfig struct. */
+enum xen_domctl_config_gic {
+    /* Emulate the underlying GIC present in the current host. */
+    XEN_DOMCTL_CONFIG_GIC_NATIVE = 0,
+    /* Emulate a GICv2. */
+    XEN_DOMCTL_CONFIG_GIC_V2 = 1,
+    /* Emulate a GICv3. */
+    XEN_DOMCTL_CONFIG_GIC_V3 = 2,
+};
+
+/* TEE mediator exposed to the guest */
+enum xen_domctl_config_tee {
+    /* No mediator. Guest can't communicate with the TEE. */
+    XEN_DOMCTL_CONFIG_TEE_NONE = 0,
+    /* Expose an OP-TEE mediator. */
+    XEN_DOMCTL_CONFIG_TEE_OPTEE = 1,
+    /* Expose an FF-A mediator. */
+    XEN_DOMCTL_CONFIG_TEE_FFA = 2,
+};
+
+/* arm-specific domain settings. */
+struct xen_arch_domainconfig {
+    /*
+     * IN/OUT: GIC version exposed to the guest.
+     *
+     * When `native` on input the output value holds the automatically chosen version.
+     */
+    uint8_t gic_version /* See xen_domctl_config_gic */;
+    /* IN: SVE vector length (divided by 128) exposed to the guest. */
+    uint8_t sve_vl;
+    /* IN: TEE mediator exposed to the guest. */
+    uint16_t tee_type /* See xen_domctl_config_tee */;
+    /* IN: Number of SPIs exposed to the guest. */
+    uint32_t nr_spis;
+    /*
+     * OUT
+     * Based on the property clock-frequency in the DT timer node.
+     * The property may be present when the bootloader/firmware doesn't
+     * set correctly CNTFRQ which hold the timer frequency.
+     *
+     * As it's not possible to trap this register, we have to replicate
+     * the value in the guest DT.
+     *
+     * = 0 => property not present
+     * > 0 => Value of the property
+     */
+    uint32_t clock_frequency;
+};
+
+#endif /* __XEN_AUTOGEN_ARCH_ARM_H */
+
-- 
2.47.0



  parent reply	other threads:[~2024-11-15 11:53 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-15 11:51 [RFC PATCH 00/25] Introduce xenbindgen to autogen hypercall structs Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 01/25] xen/domctl: Refine grant_opts into max_grant_version Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 02/25] xen/domctl: Replace altp2m_opts with altp2m_mode Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 03/25] tools/xenbindgen: Introduce a Xen hypercall IDL generator Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 04/25] tools/xenbindgen: Add a TOML spec reader Alejandro Vallejo
2024-11-25 15:13   ` Teddy Astie
2024-11-25 16:51     ` Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 05/25] tools/xenbindgen: Add basic plumbing for the C backend Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 06/25] tools/xenbindgen: Add xenbindgen's Cargo.lock file Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 07/25] tools/xenbindgen: Add support for structs in TOML specs Alejandro Vallejo
2024-11-25 12:39   ` Teddy Astie
2024-11-25 17:07     ` Alejandro Vallejo
2024-11-25 15:03   ` Teddy Astie
2024-11-25 17:16     ` Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 08/25] tools/xenbindgen: Add support for enums " Alejandro Vallejo
2024-11-25 16:39   ` Teddy Astie
2024-11-25 17:18     ` Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 09/25] tools/xenbindgen: Add support for bitmaps " Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 10/25] tools/xenbindgen: Add support for includes in the " Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 11/25] tools/xenbindgen: Validate ABI rules at generation time Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 12/25] xen: Replace sysctl/readconsole with autogenerated version Alejandro Vallejo
2024-11-25 12:05   ` Jan Beulich
2024-11-25 18:51     ` Alejandro Vallejo
2024-11-26  9:40       ` Jan Beulich
2024-11-26 12:27         ` Alejandro Vallejo
2024-11-26 13:20           ` Jan Beulich
2024-11-26 14:36             ` Alejandro Vallejo
2024-11-26 16:30               ` Jan Beulich
2024-11-26 14:39             ` Teddy Astie
2024-11-26 16:28               ` Jan Beulich
2024-11-15 11:51 ` [RFC PATCH 13/25] xen: Replace hand-crafted altp2m_mode descriptions with autogenerated ones Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 14/25] xen: Replace common bitmaps in domctl.createdomain with autogenerated versions Alejandro Vallejo
2024-11-15 11:51 ` Alejandro Vallejo [this message]
2024-11-15 11:51 ` [RFC PATCH 16/25] xen/x86: Replace hand-crafted xen_arch_domainconfig with autogenerated one Alejandro Vallejo
2024-11-25 12:09   ` Jan Beulich
2024-11-25 18:53     ` Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 17/25] xen/ppc: Replace empty " Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 18/25] xen/riscv: " Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 19/25] xen: Replace hand-crafted domctl/createdomain with autogenerated version Alejandro Vallejo
2024-12-04 14:48   ` Teddy Astie
2024-11-15 11:51 ` [RFC PATCH 20/25] tools/xen-sys: Create a crate with autogenerated Rust constructs Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 21/25] tools/xenbindgen: Add Rust backend to xenbindgen Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 22/25] tools/xen-sys: Add autogenerated Rust files Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 23/25] licence: Add Unicode-DFS-2016 to the list of licences Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 24/25] tools/rust: Add deny.toml Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 25/25] ci: Add a CI checker for Rust-related helpful properties Alejandro Vallejo
2024-11-21 17:46 ` [RFC PATCH 00/25] Introduce xenbindgen to autogen hypercall structs Anthony PERARD
2024-11-22 10:52   ` Teddy Astie
2024-11-22 13:26     ` Alejandro Vallejo
2024-11-22 13:12   ` Alejandro Vallejo
2024-11-22 16:34     ` Anthony PERARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241115115200.2824-16-alejandro.vallejo@cloud.com \
    --to=alejandro.vallejo@cloud.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bertrand.marquis@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.