@@ -96,7 +96,7 @@ static int build(xc_interface *xch)
*/
.max_grant_frames = 4,
.max_maptrack_frames = 128,
- .grant_opts = XEN_DOMCTL_GRANT_version(1),
+ .max_grant_version = 1,
};
xs_fd = open("/dev/xen/xenbus_backend", O_RDWR);
@@ -476,10 +476,6 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
else
/* No grant table support reported */
b_info->max_grant_version = 0;
- } else if (b_info->max_grant_version & ~XEN_DOMCTL_GRANT_version_mask) {
- LOG(ERROR, "max grant version %d out of range",
- b_info->max_grant_version);
- return -ERROR_INVAL;
}
/* Assume that providing a bootloader user implies enabling restrict. */
@@ -646,7 +642,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
.max_evtchn_port = b_info->event_channels,
.max_grant_frames = b_info->max_grant_frames,
.max_maptrack_frames = b_info->max_maptrack_frames,
- .grant_opts = XEN_DOMCTL_GRANT_version(b_info->max_grant_version),
+ .max_grant_version = b_info->max_grant_version,
.vmtrace_size = ROUNDUP(b_info->vmtrace_buf_kb << 10, XC_PAGE_SHIFT),
.cpupool_id = info->poolid,
};
@@ -223,8 +223,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
.max_evtchn_port = Int_val(VAL_MAX_EVTCHN_PORT),
.max_grant_frames = Int_val(VAL_MAX_GRANT_FRAMES),
.max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES),
- .grant_opts =
- XEN_DOMCTL_GRANT_version(Int_val(VAL_MAX_GRANT_VERSION)),
+ .max_grant_version = Int_val(VAL_MAX_GRANT_VERSION),
.altp2m_opts = Int32_val(VAL_ALTP2M_OPTS),
.vmtrace_size = vmtrace_size,
.cpupool_id = Int32_val(VAL_CPUPOOL_ID),
@@ -167,7 +167,7 @@ static PyObject *pyxc_domain_create(XcObject *self,
#else
#error Architecture not supported
#endif
- config.grant_opts = XEN_DOMCTL_GRANT_version(max_grant_version);
+ config.max_grant_version = max_grant_version;
if ( (ret = xc_domain_create(self->xc_handle, &dom, &config)) < 0 )
return pyxc_error_to_exception(self->xc_handle);
@@ -24,7 +24,7 @@ static struct xen_domctl_createdomain create = {
.flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap,
.max_vcpus = 1,
.max_grant_frames = 1,
- .grant_opts = XEN_DOMCTL_GRANT_version(1),
+ .max_grant_version = 1,
.arch = {
#if defined(__x86_64__) || defined(__i386__)
@@ -137,7 +137,7 @@ static void test_domain_configurations(void)
.create = {
.max_vcpus = 2,
.max_grant_frames = 40,
- .grant_opts = XEN_DOMCTL_GRANT_version(1),
+ .max_grant_version = 1,
},
},
{
@@ -146,7 +146,7 @@ static void test_domain_configurations(void)
.flags = XEN_DOMCTL_CDF_hvm,
.max_vcpus = 2,
.max_grant_frames = 40,
- .grant_opts = XEN_DOMCTL_GRANT_version(1),
+ .max_grant_version = 1,
.arch = {
.emulation_flags = XEN_X86_EMU_LAPIC,
},
@@ -159,7 +159,7 @@ static void test_domain_configurations(void)
.flags = XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap,
.max_vcpus = 2,
.max_grant_frames = 40,
- .grant_opts = XEN_DOMCTL_GRANT_version(1),
+ .max_grant_version = 1,
},
},
#endif
@@ -457,7 +457,7 @@ static void test_guests(void)
struct xen_domctl_createdomain c = {
.max_vcpus = 1,
.max_grant_frames = 1,
- .grant_opts = XEN_DOMCTL_GRANT_version(1),
+ .max_grant_version = 1,
};
printf("Testing PV guest\n");
@@ -470,7 +470,7 @@ static void test_guests(void)
.flags = XEN_DOMCTL_CDF_hvm,
.max_vcpus = 1,
.max_grant_frames = 1,
- .grant_opts = XEN_DOMCTL_GRANT_version(1),
+ .max_grant_version = 1,
.arch = {
.emulation_flags = XEN_X86_EMU_LAPIC,
},
@@ -877,7 +877,7 @@ void __init create_domUs(void)
.max_evtchn_port = 1023,
.max_grant_frames = -1,
.max_maptrack_frames = -1,
- .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version),
+ .max_grant_version = opt_gnttab_max_version,
};
unsigned int flags = 0U;
uint32_t val;
@@ -959,7 +959,7 @@ void __init create_domUs(void)
}
if ( dt_property_read_u32(node, "max_grant_version", &val) )
- d_cfg.grant_opts = XEN_DOMCTL_GRANT_version(val);
+ d_cfg.max_grant_version = val;
if ( dt_property_read_u32(node, "max_grant_frames", &val) )
{
@@ -2194,7 +2194,7 @@ void __init create_dom0(void)
.max_evtchn_port = -1,
.max_grant_frames = gnttab_dom0_frames(),
.max_maptrack_frames = -1,
- .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version),
+ .max_grant_version = opt_gnttab_max_version,
};
int rc;
@@ -964,7 +964,7 @@ static struct domain *__init create_dom0(const module_t *image,
.max_evtchn_port = -1,
.max_grant_frames = -1,
.max_maptrack_frames = -1,
- .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version),
+ .max_grant_version = opt_gnttab_max_version,
.max_vcpus = dom0_max_vcpus(),
.arch = {
.misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0,
@@ -579,9 +579,9 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config)
return -EINVAL;
}
- if ( config->grant_opts & ~XEN_DOMCTL_GRANT_version_mask )
+ if ( config->rsvd0[0] | config->rsvd0[1] | config->rsvd0[2] )
{
- dprintk(XENLOG_INFO, "Unknown grant options %#x\n", config->grant_opts);
+ dprintk(XENLOG_INFO, "Rubble in rsvd0 padding\n");
return -EINVAL;
}
@@ -788,7 +788,7 @@ struct domain *domain_create(domid_t domid,
if ( (err = grant_table_init(d, config->max_grant_frames,
config->max_maptrack_frames,
- config->grant_opts)) != 0 )
+ config->max_grant_version)) != 0 )
goto fail;
init_status |= INIT_gnttab;
@@ -1963,10 +1963,9 @@ active_alloc_failed:
}
int grant_table_init(struct domain *d, int max_grant_frames,
- int max_maptrack_frames, unsigned int options)
+ int max_maptrack_frames, uint8_t max_grant_version)
{
struct grant_table *gt;
- unsigned int max_grant_version = options & XEN_DOMCTL_GRANT_version_mask;
int ret = -ENOMEM;
if ( !max_grant_version )
@@ -90,11 +90,18 @@ struct xen_domctl_createdomain {
int32_t max_grant_frames;
int32_t max_maptrack_frames;
-/* Grant version, use low 4 bits. */
-#define XEN_DOMCTL_GRANT_version_mask 0xf
-#define XEN_DOMCTL_GRANT_version(v) ((v) & XEN_DOMCTL_GRANT_version_mask)
+ /*
+ * Maximum grant table version the domain can be configured with.
+ *
+ * Domains always start with v1 (if CONFIG_GRANT_TABLE) and can be bumped
+ * to use up to `max_grant_version` via GNTTABOP_set_version.
+ *
+ * Must be zero iff !CONFIG_GRANT_TABLE.
+ */
+ uint8_t max_grant_version;
- uint32_t grant_opts;
+ /* Unused. Reserved to zero. */
+ uint8_t rsvd0[3];
/*
* Enable altp2m mixed mode.
@@ -40,7 +40,7 @@ extern unsigned int opt_max_grant_frames;
/* Create/destroy per-domain grant table context. */
int grant_table_init(struct domain *d, int max_grant_frames,
- int max_maptrack_frames, unsigned int options);
+ int max_maptrack_frames, uint8_t max_grant_version);
void grant_table_destroy(
struct domain *d);
void grant_table_init_vcpu(struct vcpu *v);
@@ -73,9 +73,9 @@ int gnttab_acquire_resource(
static inline int grant_table_init(struct domain *d,
int max_grant_frames,
int max_maptrack_frames,
- unsigned int options)
+ uint8_t max_grant_version)
{
- if ( options )
+ if ( max_grant_version )
return -EINVAL;
return 0;
grant_opts is overoptimizing for space packing in a hypercall that doesn't warrant the effort. Tweak the ABI without breaking it in order to remove the bitfield by extending it to 8 bits. Xen only supports little-endian systems, so the transformation from uint32_t to uint8_t followed by 3 octets worth of padding is not an ABI breakage. No functional change Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com> --- tools/helpers/init-xenstore-domain.c | 2 +- tools/libs/light/libxl_create.c | 6 +----- tools/ocaml/libs/xc/xenctrl_stubs.c | 3 +-- tools/python/xen/lowlevel/xc/xc.c | 2 +- tools/tests/paging-mempool/test-paging-mempool.c | 2 +- tools/tests/resource/test-resource.c | 6 +++--- tools/tests/tsx/test-tsx.c | 4 ++-- xen/arch/arm/dom0less-build.c | 4 ++-- xen/arch/arm/domain_build.c | 2 +- xen/arch/x86/setup.c | 2 +- xen/common/domain.c | 6 +++--- xen/common/grant_table.c | 3 +-- xen/include/public/domctl.h | 15 +++++++++++---- xen/include/xen/grant_table.h | 6 +++--- 14 files changed, 32 insertions(+), 31 deletions(-)