@@ -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;
}
@@ -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;
@@ -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;
@@ -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
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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;
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(-)