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>,
	"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>,
	"Christian Lindig" <christian.lindig@citrix.com>,
	"David Scott" <dave@recoil.org>,
	"Bertrand Marquis" <bertrand.marquis@arm.com>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [RFC PATCH 02/25] xen/domctl: Replace altp2m_opts with altp2m_mode
Date: Fri, 15 Nov 2024 11:51:31 +0000	[thread overview]
Message-ID: <20241115115200.2824-3-alejandro.vallejo@cloud.com> (raw)
In-Reply-To: <20241115115200.2824-1-alejandro.vallejo@cloud.com>

No functional change, in the same direction as the previous grant_opts
to max_grant_version.

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
---
 tools/libs/light/libxl_create.c     | 11 ++++-------
 tools/ocaml/libs/xc/xenctrl.ml      |  2 +-
 tools/ocaml/libs/xc/xenctrl.mli     |  2 +-
 tools/ocaml/libs/xc/xenctrl_stubs.c |  6 +++---
 xen/arch/arm/domain.c               |  2 +-
 xen/arch/x86/domain.c               | 13 ++-----------
 xen/arch/x86/hvm/hvm.c              |  6 +++++-
 xen/common/domain.c                 |  3 ++-
 xen/include/public/domctl.h         | 12 +++++++-----
 9 files changed, 26 insertions(+), 31 deletions(-)

diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index 87594809abc8..3ae922e8931b 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -676,22 +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_opts |=
-                XEN_DOMCTL_ALTP2M_mode(XEN_DOMCTL_ALTP2M_mixed);
+            create.altp2m_mode = XEN_DOMCTL_ALTP2M_mixed;
             break;
 
         case LIBXL_ALTP2M_MODE_EXTERNAL:
-            create.altp2m_opts |=
-                XEN_DOMCTL_ALTP2M_mode(XEN_DOMCTL_ALTP2M_external);
+            create.altp2m_mode = XEN_DOMCTL_ALTP2M_external;
             break;
 
         case LIBXL_ALTP2M_MODE_LIMITED:
-            create.altp2m_opts |=
-                XEN_DOMCTL_ALTP2M_mode(XEN_DOMCTL_ALTP2M_limited);
+            create.altp2m_mode = XEN_DOMCTL_ALTP2M_limited;
             break;
 
         case LIBXL_ALTP2M_MODE_DISABLED:
-            /* Nothing to do - altp2m disabled is signaled as mode == 0. */
+            create.altp2m_mode = XEN_DOMCTL_ALTP2M_disabled;
             break;
         }
 
diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index 2690f9a92316..3c4c95d48319 100644
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -85,7 +85,7 @@ type domctl_create_config =
     max_grant_frames: int;
     max_maptrack_frames: int;
     max_grant_version: int;
-    altp2m_opts: int32;
+    altp2m_mode: int32;
     vmtrace_buf_kb: int32;
     cpupool_id: int32;
     arch: arch_domainconfig;
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index febbe1f6ae3f..74919a14bec4 100644
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -77,7 +77,7 @@ type domctl_create_config = {
   max_grant_frames: int;
   max_maptrack_frames: int;
   max_grant_version: int;
-  altp2m_opts: int32;
+  altp2m_mode: int32;
   vmtrace_buf_kb: int32;
   cpupool_id: int32;
   arch: arch_domainconfig;
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 67a690308f1a..b701f45daa8d 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -204,7 +204,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
 #define VAL_MAX_GRANT_FRAMES    Field(config, 6)
 #define VAL_MAX_MAPTRACK_FRAMES Field(config, 7)
 #define VAL_MAX_GRANT_VERSION   Field(config, 8)
-#define VAL_ALTP2M_OPTS         Field(config, 9)
+#define VAL_ALTP2M_MODE         Field(config, 9)
 #define VAL_VMTRACE_BUF_KB      Field(config, 10)
 #define VAL_CPUPOOL_ID          Field(config, 11)
 #define VAL_ARCH                Field(config, 12)
@@ -224,7 +224,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
 		.max_grant_frames = Int_val(VAL_MAX_GRANT_FRAMES),
 		.max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES),
 		.max_grant_version = Int_val(VAL_MAX_GRANT_VERSION),
-		.altp2m_opts = Int32_val(VAL_ALTP2M_OPTS),
+		.altp2m_mode = Int32_val(VAL_ALTP2M_MODE),
 		.vmtrace_size = vmtrace_size,
 		.cpupool_id = Int32_val(VAL_CPUPOOL_ID),
 	};
@@ -283,7 +283,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
 #undef VAL_ARCH
 #undef VAL_CPUPOOL_ID
 #undef VAL_VMTRACE_BUF_KB
-#undef VAL_ALTP2M_OPTS
+#undef VAL_ALTP2M_MODE
 #undef VAL_MAX_GRANT_VERSION
 #undef VAL_MAX_MAPTRACK_FRAMES
 #undef VAL_MAX_GRANT_FRAMES
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 3ba959f86633..c6c5a0d1af23 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -688,7 +688,7 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
         return -EINVAL;
     }
 
-    if ( config->altp2m_opts )
+    if ( config->altp2m_mode )
     {
         dprintk(XENLOG_INFO, "Altp2m not supported\n");
         return -EINVAL;
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 78a13e6812c9..1ef095f349f7 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -637,8 +637,6 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
     bool hap = config->flags & XEN_DOMCTL_CDF_hap;
     bool nested_virt = config->flags & XEN_DOMCTL_CDF_nested_virt;
     unsigned int max_vcpus;
-    unsigned int altp2m_mode = MASK_EXTR(config->altp2m_opts,
-                                         XEN_DOMCTL_ALTP2M_mode_mask);
 
     if ( hvm ? !hvm_enabled : !IS_ENABLED(CONFIG_PV) )
     {
@@ -717,21 +715,14 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
         return -EINVAL;
     }
 
-    if ( config->altp2m_opts & ~XEN_DOMCTL_ALTP2M_mode_mask )
-    {
-        dprintk(XENLOG_INFO, "Invalid altp2m options selected: %#x\n",
-                config->flags);
-        return -EINVAL;
-    }
-
-    if ( altp2m_mode && nested_virt )
+    if ( config->altp2m_mode && nested_virt )
     {
         dprintk(XENLOG_INFO,
                 "Nested virt and altp2m are not supported together\n");
         return -EINVAL;
     }
 
-    if ( altp2m_mode && !hap )
+    if ( config->altp2m_mode && !hap )
     {
         dprintk(XENLOG_INFO, "altp2m is only supported with HAP\n");
         return -EINVAL;
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 74e58c653e6f..e30c3026479e 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -659,7 +659,7 @@ int hvm_domain_initialise(struct domain *d,
     d->arch.hvm.params[HVM_PARAM_TRIPLE_FAULT_REASON] = SHUTDOWN_reboot;
 
     /* Set altp2m based on domctl flags. */
-    switch ( MASK_EXTR(config->altp2m_opts, XEN_DOMCTL_ALTP2M_mode_mask) )
+    switch ( config->altp2m_mode )
     {
     case XEN_DOMCTL_ALTP2M_mixed:
         d->arch.hvm.params[HVM_PARAM_ALTP2M] = XEN_ALTP2M_mixed;
@@ -672,6 +672,10 @@ int hvm_domain_initialise(struct domain *d,
     case XEN_DOMCTL_ALTP2M_limited:
         d->arch.hvm.params[HVM_PARAM_ALTP2M] = XEN_ALTP2M_limited;
         break;
+
+    case XEN_DOMCTL_ALTP2M_disabled:
+        d->arch.hvm.params[HVM_PARAM_ALTP2M] = XEN_ALTP2M_disabled;
+        break;
     }
 
     vpic_init(d);
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 86f0e99e0d4a..ad19ff1cef23 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -579,7 +579,8 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config)
         return -EINVAL;
     }
 
-    if ( config->rsvd0[0] | config->rsvd0[1] | config->rsvd0[2] )
+    if ( config->rsvd0_a[0] | config->rsvd0_a[1] | config->rsvd0_a[2] |
+         config->rsvd0_b[0] | config->rsvd0_b[1] | config->rsvd0_b[2] )
     {
         dprintk(XENLOG_INFO, "Rubble in rsvd0 padding\n");
         return -EINVAL;
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index e37d4337dcf9..95a3b6769f7f 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -101,8 +101,10 @@ struct xen_domctl_createdomain {
     uint8_t max_grant_version;
 
     /* Unused. Reserved to zero. */
-    uint8_t rsvd0[3];
+    uint8_t rsvd0_a[3];
 
+/* Keep altp2m disabled */
+#define XEN_DOMCTL_ALTP2M_disabled   (0U)
 /*
  * Enable altp2m mixed mode.
  *
@@ -116,10 +118,10 @@ struct xen_domctl_createdomain {
 #define XEN_DOMCTL_ALTP2M_external   (2U)
 /* Enable altp2m limited mode. */
 #define XEN_DOMCTL_ALTP2M_limited    (3U)
-/* Altp2m mode signaling uses bits [0, 1]. */
-#define XEN_DOMCTL_ALTP2M_mode_mask  (0x3U)
-#define XEN_DOMCTL_ALTP2M_mode(m)    ((m) & XEN_DOMCTL_ALTP2M_mode_mask)
-    uint32_t altp2m_opts;
+    uint8_t altp2m_mode;
+
+    /* Unused. Reserved to zero. */
+    uint8_t rsvd0_b[3];
 
     /* Per-vCPU buffer size in bytes.  0 to disable. */
     uint32_t vmtrace_size;
-- 
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 ` Alejandro Vallejo [this message]
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 ` [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-3-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=christian.lindig@citrix.com \
    --cc=dave@recoil.org \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --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.