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>,
"Juergen Gross" <jgross@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Daniel P. Smith" <dpsmith@apertussolutions.com>
Subject: [RFC PATCH 13/25] xen: Replace hand-crafted altp2m_mode descriptions with autogenerated ones
Date: Fri, 15 Nov 2024 11:51:42 +0000 [thread overview]
Message-ID: <20241115115200.2824-14-alejandro.vallejo@cloud.com> (raw)
In-Reply-To: <20241115115200.2824-1-alejandro.vallejo@cloud.com>
Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
---
tools/libs/light/libxl_create.c | 8 +++----
.../xenbindgen/extra/domctl/createdomain.toml | 24 +++++++++++++++++++
xen/arch/x86/hvm/hvm.c | 8 +++----
xen/include/public/autogen/domctl.h | 22 +++++++++++++++++
xen/include/public/domctl.h | 18 +++-----------
5 files changed, 57 insertions(+), 23 deletions(-)
create mode 100644 tools/rust/xenbindgen/extra/domctl/createdomain.toml
create mode 100644 xen/include/public/autogen/domctl.h
diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index 3ae922e8931b..791b0fac0601 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -676,19 +676,19 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
LOG(DETAIL, "altp2m: %s", libxl_altp2m_mode_to_string(b_info->altp2m));
switch(b_info->altp2m) {
case LIBXL_ALTP2M_MODE_MIXED:
- create.altp2m_mode = XEN_DOMCTL_ALTP2M_mixed;
+ create.altp2m_mode = XEN_DOMCTL_ALTP2M_MODE_MIXED;
break;
case LIBXL_ALTP2M_MODE_EXTERNAL:
- create.altp2m_mode = XEN_DOMCTL_ALTP2M_external;
+ create.altp2m_mode = XEN_DOMCTL_ALTP2M_MODE_EXTERNAL;
break;
case LIBXL_ALTP2M_MODE_LIMITED:
- create.altp2m_mode = XEN_DOMCTL_ALTP2M_limited;
+ create.altp2m_mode = XEN_DOMCTL_ALTP2M_MODE_LIMITED;
break;
case LIBXL_ALTP2M_MODE_DISABLED:
- create.altp2m_mode = XEN_DOMCTL_ALTP2M_disabled;
+ create.altp2m_mode = XEN_DOMCTL_ALTP2M_MODE_DISABLED;
break;
}
diff --git a/tools/rust/xenbindgen/extra/domctl/createdomain.toml b/tools/rust/xenbindgen/extra/domctl/createdomain.toml
new file mode 100644
index 000000000000..097dc202f352
--- /dev/null
+++ b/tools/rust/xenbindgen/extra/domctl/createdomain.toml
@@ -0,0 +1,24 @@
+[[enums]]
+name = "xen_domctl_altp2m_mode"
+description = "Content of the `altp2m_mode` field of the domain creation hypercall."
+typ = { tag = "u8" }
+
+[[enums.variants]]
+name = "disabled"
+description = "Keep altp2m disabled"
+value = 0
+
+[[enums.variants]]
+name = "mixed"
+description = "Use mixed-mode for the altp2m (not yet evaluated for safety)."
+value = 1
+
+[[enums.variants]]
+name = "external"
+description = "Use external mode for the altp2m."
+value = 2
+
+[[enums.variants]]
+name = "limited"
+description = "Use limited mode for the altp2m."
+value = 3
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index e30c3026479e..35caf6131190 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -661,19 +661,19 @@ int hvm_domain_initialise(struct domain *d,
/* Set altp2m based on domctl flags. */
switch ( config->altp2m_mode )
{
- case XEN_DOMCTL_ALTP2M_mixed:
+ case XEN_DOMCTL_ALTP2M_MODE_MIXED:
d->arch.hvm.params[HVM_PARAM_ALTP2M] = XEN_ALTP2M_mixed;
break;
- case XEN_DOMCTL_ALTP2M_external:
+ case XEN_DOMCTL_ALTP2M_MODE_EXTERNAL:
d->arch.hvm.params[HVM_PARAM_ALTP2M] = XEN_ALTP2M_external;
break;
- case XEN_DOMCTL_ALTP2M_limited:
+ case XEN_DOMCTL_ALTP2M_MODE_LIMITED:
d->arch.hvm.params[HVM_PARAM_ALTP2M] = XEN_ALTP2M_limited;
break;
- case XEN_DOMCTL_ALTP2M_disabled:
+ case XEN_DOMCTL_ALTP2M_MODE_DISABLED:
d->arch.hvm.params[HVM_PARAM_ALTP2M] = XEN_ALTP2M_disabled;
break;
}
diff --git a/xen/include/public/autogen/domctl.h b/xen/include/public/autogen/domctl.h
new file mode 100644
index 000000000000..00202f5e65b9
--- /dev/null
+++ b/xen/include/public/autogen/domctl.h
@@ -0,0 +1,22 @@
+/*
+ * domctl
+ *
+ * AUTOGENERATED. DO NOT MODIFY
+ */
+#ifndef __XEN_AUTOGEN_DOMCTL_H
+#define __XEN_AUTOGEN_DOMCTL_H
+
+/* Content of the `altp2m_mode` field of the domain creation hypercall. */
+enum xen_domctl_altp2m_mode {
+ /* Keep altp2m disabled */
+ XEN_DOMCTL_ALTP2M_MODE_DISABLED = 0,
+ /* Use mixed-mode for the altp2m (not yet evaluated for safety). */
+ XEN_DOMCTL_ALTP2M_MODE_MIXED = 1,
+ /* Use external mode for the altp2m. */
+ XEN_DOMCTL_ALTP2M_MODE_EXTERNAL = 2,
+ /* Use limited mode for the altp2m. */
+ XEN_DOMCTL_ALTP2M_MODE_LIMITED = 3,
+};
+
+#endif /* __XEN_AUTOGEN_DOMCTL_H */
+
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 95a3b6769f7f..95d62c859302 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -21,6 +21,8 @@
#include "hvm/save.h"
#include "memory.h"
+#include "autogen/domctl.h"
+
/*
* The interface version needs to be incremented by 1 in case the interface
* is modified in an incompatible way AND if the version hasn't been
@@ -103,21 +105,7 @@ struct xen_domctl_createdomain {
/* Unused. Reserved to zero. */
uint8_t rsvd0_a[3];
-/* Keep altp2m disabled */
-#define XEN_DOMCTL_ALTP2M_disabled (0U)
-/*
- * Enable altp2m mixed mode.
- *
- * Note that 'mixed' mode has not been evaluated for safety from a security
- * perspective. Before using this mode in a security-critical environment,
- * each subop should be evaluated for safety, with unsafe subops blacklisted in
- * XSM.
- */
-#define XEN_DOMCTL_ALTP2M_mixed (1U)
-/* Enable altp2m external mode. */
-#define XEN_DOMCTL_ALTP2M_external (2U)
-/* Enable altp2m limited mode. */
-#define XEN_DOMCTL_ALTP2M_limited (3U)
+ /* See xen_domctl_altp2m_mode */
uint8_t altp2m_mode;
/* Unused. Reserved to zero. */
--
2.47.0
next prev 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 ` Alejandro Vallejo [this message]
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 ` [RFC PATCH 15/25] xen/arm: Replace hand-crafted xen_arch_domainconfig with autogenerated one Alejandro Vallejo
2024-11-15 11:51 ` [RFC PATCH 16/25] xen/x86: " 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-14-alejandro.vallejo@cloud.com \
--to=alejandro.vallejo@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=dpsmith@apertussolutions.com \
--cc=jbeulich@suse.com \
--cc=jgross@suse.com \
--cc=julien@xen.org \
--cc=roger.pau@citrix.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.