via the grant mechanism by this domain. The default value is settable via
L<xl.conf(5)>.
+=item B<max_grant_version=NUMBER>
+
+Specify the maximum grant table version the domain is allowed to use. The
+default value is settable via L<xl.conf(5)>.
+
=item B<nomigrate=BOOLEAN>
Disable migration of this domain. This enables certain other features
Default: value of Xen command line B<gnttab_max_maptrack_frames>
parameter (or its default value if unspecified).
+=item B<max_grant_version=NUMBER>
+
+Sets the default value for the C<max_grant_version> domain config value.
+
+Default: maximum grant version supported by the hypervisor.
+
=item B<vif.default.script="PATH">
Configures the default hotplug script used by virtual network devices.
* 1 grant frame is enough: we don't need many grants.
* Mini-OS doesn't like less than 4, though, so use 4.
* 128 maptrack frames: 256 entries per frame, enough for 32768 domains.
+ * Currently Mini-OS only supports grant v1.
*/
.max_grant_frames = 4,
.max_maptrack_frames = 128,
+ .grant_opts = 1,
};
xs_fd = open("/dev/xen/xenbus_backend", O_RDWR);
*/
#define LIBXL_HAVE_PHYSINFO_CAP_GNTTAB 1
+/*
+ * LIBXL_HAVE_MAX_GRANT_VERSION indicates libxl_domain_build_info has a
+ * max_grant_version field for setting the max grant table version per
+ * domain.
+ */
+#define LIBXL_HAVE_MAX_GRANT_VERSION 1
+
/*
* libxl ABI compatibility
*
libxl_defbool_setdefault(&b_info->nested_hvm, false);
}
+ if (b_info->max_grant_version == LIBXL_MAX_GRANT_DEFAULT) {
+ libxl_physinfo info;
+
+ rc = libxl_get_physinfo(CTX, &info);
+ if (rc) {
+ LOG(ERROR, "failed to get hypervisor info");
+ return rc;
+ }
+
+ if (info.cap_gnttab_v2)
+ b_info->max_grant_version = 2;
+ else if (info.cap_gnttab_v1)
+ b_info->max_grant_version = 1;
+ 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;
+ }
+
return 0;
}
.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 = b_info->max_grant_version,
.vmtrace_size = ROUNDUP(b_info->vmtrace_buf_kb << 10, XC_PAGE_SHIFT),
};
dm_config->b_info.max_grant_frames = guest_config->b_info.max_grant_frames;
dm_config->b_info.max_maptrack_frames = guest_config->b_info.max_maptrack_frames;
+ dm_config->b_info.max_grant_version = guest_config->b_info.max_grant_version;
dm_config->b_info.u.pv.features = "";
("max_grant_frames", uint32, {'init_val': 'LIBXL_MAX_GRANT_DEFAULT'}),
("max_maptrack_frames", uint32, {'init_val': 'LIBXL_MAX_GRANT_DEFAULT'}),
+ ("max_grant_version", integer, {'init_val': 'LIBXL_MAX_GRANT_DEFAULT'}),
("device_model_version", libxl_device_model_version),
("device_model_stubdomain", libxl_defbool),
max_evtchn_port: int;
max_grant_frames: int;
max_maptrack_frames: int;
+ max_grant_version: int;
arch: arch_domainconfig;
}
max_evtchn_port: int;
max_grant_frames: int;
max_maptrack_frames: int;
+ max_grant_version: int;
arch: arch_domainconfig;
}
#define VAL_MAX_EVTCHN_PORT Field(config, 5)
#define VAL_MAX_GRANT_FRAMES Field(config, 6)
#define VAL_MAX_MAPTRACK_FRAMES Field(config, 7)
-#define VAL_ARCH Field(config, 8)
+#define VAL_MAX_GRANT_VERSION Field(config, 8)
+#define VAL_ARCH Field(config, 9)
uint32_t domid = Int_val(wanted_domid);
int result;
.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 = Int_val(VAL_MAX_GRANT_VERSION),
};
domain_handle_of_uuid_string(cfg.handle, String_val(VAL_HANDLE));
}
#undef VAL_ARCH
+#undef VAL_MAX_GRANT_VERSION
#undef VAL_MAX_MAPTRACK_FRAMES
#undef VAL_MAX_GRANT_FRAMES
#undef VAL_MAX_EVTCHN_PORT
bool timestamps = 0;
int max_grant_frames = -1;
int max_maptrack_frames = -1;
+int max_grant_version = LIBXL_MAX_GRANT_DEFAULT;
libxl_domid domid_policy = INVALID_DOMID;
xentoollog_level minmsglevel = minmsglevel_default;
else if (e != ESRCH)
exit(1);
+ e = xlu_cfg_get_bounded_long (config, "max_grant_version", 0,
+ INT_MAX, &l, 1);
+ if (!e)
+ max_grant_version = l;
+ else if (e != ESRCH)
+ exit(1);
+
libxl_cpu_bitmap_alloc(ctx, &global_vm_affinity_mask, 0);
libxl_cpu_bitmap_alloc(ctx, &global_hvm_affinity_mask, 0);
libxl_cpu_bitmap_alloc(ctx, &global_pv_affinity_mask, 0);
extern char *blkdev_start;
extern int max_grant_frames;
extern int max_maptrack_frames;
+extern int max_grant_version;
extern libxl_bitmap global_vm_affinity_mask;
extern libxl_bitmap global_hvm_affinity_mask;
extern libxl_bitmap global_pv_affinity_mask;
else
exit(1);
+ e = xlu_cfg_get_bounded_long (config, "max_grant_version", 0,
+ INT_MAX, &l, 1);
+ if (e == ESRCH) /* not specified */
+ b_info->max_grant_version = max_grant_version;
+ else if (!e)
+ b_info->max_grant_version = l;
+ else
+ exit(1);
+
libxl_defbool_set(&b_info->claim_mode, claim_mode);
if (xlu_cfg_get_string (config, "on_poweroff", &buf, 0))
.max_evtchn_port = -1,
.max_grant_frames = -1,
.max_maptrack_frames = -1,
+ .grant_opts = opt_gnttab_max_version,
};
if ( !dt_device_is_compatible(node, "xen,domain") )
.max_evtchn_port = -1,
.max_grant_frames = gnttab_dom0_frames(),
.max_maptrack_frames = -1,
+ .grant_opts = opt_gnttab_max_version,
};
/* The vGIC for DOM0 is exactly emulating the hardware GIC */
.max_evtchn_port = -1,
.max_grant_frames = -1,
.max_maptrack_frames = -1,
+ .grant_opts = opt_gnttab_max_version,
.max_vcpus = dom0_max_vcpus(),
.arch = {
.misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0,
return -EINVAL;
}
+ if ( config->grant_opts & ~XEN_DOMCTL_GRANT_version_mask )
+ {
+ dprintk(XENLOG_INFO, "Unknown grant options %#x\n", config->grant_opts);
+ return -EINVAL;
+ }
+
if ( config->max_vcpus < 1 )
{
dprintk(XENLOG_INFO, "No vCPUS\n");
init_status |= INIT_evtchn;
if ( (err = grant_table_init(d, config->max_grant_frames,
- config->max_maptrack_frames)) != 0 )
+ config->max_maptrack_frames,
+ config->grant_opts)) != 0 )
goto fail;
init_status |= INIT_gnttab;
percpu_rwlock_t lock;
/* Lock protecting the maptrack limit */
spinlock_t maptrack_lock;
+ unsigned int max_version;
/*
* Defaults to v1. May be changed with GNTTABOP_set_version. All other
* values are invalid.
}
int grant_table_init(struct domain *d, int max_grant_frames,
- int max_maptrack_frames)
+ int max_maptrack_frames, unsigned int options)
{
struct grant_table *gt;
+ unsigned int max_grant_version = options & XEN_DOMCTL_GRANT_version_mask;
int ret = -ENOMEM;
+ if ( !max_grant_version )
+ {
+ dprintk(XENLOG_INFO, "%pd: invalid grant table version 0 requested\n",
+ d);
+ return -EINVAL;
+ }
+ if ( max_grant_version > opt_gnttab_max_version )
+ {
+ dprintk(XENLOG_INFO,
+ "%pd: requested grant version (%u) greater than supported (%u)\n",
+ d, max_grant_version, opt_gnttab_max_version);
+ return -EINVAL;
+ }
+
/* Default to maximum value if no value was specified */
if ( max_grant_frames < 0 )
max_grant_frames = opt_max_grant_frames;
gt->gt_version = 1;
gt->max_grant_frames = max_grant_frames;
gt->max_maptrack_frames = max_maptrack_frames;
+ gt->max_version = max_grant_version;
/* Install the structure early to simplify the error path. */
gt->domain = d;
goto out;
res = -ENOSYS;
- if ( op.version == 2 && opt_gnttab_max_version == 1 )
+ if ( op.version == 2 && gt->max_version == 1 )
goto out; /* Behave as before set_version was introduced. */
res = 0;
int32_t max_grant_frames;
int32_t max_maptrack_frames;
+/* Grant version, use low 4 bits. */
+#define XEN_DOMCTL_GRANT_version_mask 0xf
+
+ uint32_t grant_opts;
+
/* Per-vCPU buffer size in bytes. 0 to disable. */
uint32_t vmtrace_size;
/* Create/destroy per-domain grant table context. */
int grant_table_init(struct domain *d, int max_grant_frames,
- int max_maptrack_frames);
+ int max_maptrack_frames, unsigned int options);
void grant_table_destroy(
struct domain *d);
void grant_table_init_vcpu(struct vcpu *v);
static inline int grant_table_init(struct domain *d,
int max_grant_frames,
- int max_maptrack_frames)
+ int max_maptrack_frames,
+ unsigned int options)
{
+ if ( options )
+ return -EINVAL;
+
return 0;
}