[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 48/52] xen: add hypercall for setting parameters at runtime
Add a sysctl hypercall to support setting parameters similar to command line parameters, but at runtime. The parameters to set are specified as a string, just like the boot parameters. Cc: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx> Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Tim Deegan <tim@xxxxxxx> Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- tools/flask/policy/modules/dom0.te | 2 +- xen/common/sysctl.c | 29 +++++++++++++++++++++++++++++ xen/include/public/sysctl.h | 19 +++++++++++++++++++ xen/xsm/flask/hooks.c | 3 +++ xen/xsm/flask/policy/access_vectors | 2 ++ 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/tools/flask/policy/modules/dom0.te b/tools/flask/policy/modules/dom0.te index d0a4d91ac0..338caaf41e 100644 --- a/tools/flask/policy/modules/dom0.te +++ b/tools/flask/policy/modules/dom0.te @@ -16,7 +16,7 @@ allow dom0_t xen_t:xen { allow dom0_t xen_t:xen2 { resource_op psr_cmt_op psr_cat_op pmu_ctrl get_symbol get_cpu_levelling_caps get_cpu_featureset livepatch_op - gcov_op + gcov_op set_parameter }; # Allow dom0 to use all XENVER_ subops that have checks. diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index ae58a0f650..a3237fe9be 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -467,6 +467,35 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) copyback = 1; break; + case XEN_SYSCTL_set_parameter: + { + char *params; + + if ( op->u.set_parameter.size > XEN_SET_PARAMETER_MAX_SIZE ) + { + ret = -EINVAL; + break; + } + params = xmalloc_bytes(op->u.set_parameter.size + 1); + if ( !params ) + { + ret = -ENOMEM; + break; + } + if ( __copy_from_guest(params, op->u.set_parameter.params, + op->u.set_parameter.size) ) + ret = -EFAULT; + else + { + params[op->u.set_parameter.size] = 0; + ret = runtime_parse(params); + } + + xfree(params); + + break; + } + default: ret = arch_do_sysctl(op, u_sysctl); copyback = 0; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 9e51af61e1..43b18bdb9b 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -1096,6 +1096,23 @@ struct xen_sysctl_livepatch_op { typedef struct xen_sysctl_livepatch_op xen_sysctl_livepatch_op_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_livepatch_op_t); +/* + * XEN_SYSCTL_set_parameter + * + * Change hypervisor parameters at runtime. + * The input string is parsed similar to the boot parameters. + */ + +#define XEN_SET_PARAMETER_MAX_SIZE 1023 +struct xen_sysctl_set_parameter { + XEN_GUEST_HANDLE_64(char) params; /* IN: pointer to parameters. */ + uint16_t size; /* IN: size of parameters. Max. + XEN_SET_PARAMETER_MAX_SIZE. */ + uint16_t pad[3]; /* IN: MUST be zero. */ +}; +typedef struct xen_sysctl_set_parameter xen_sysctl_set_parameter_t; +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_set_parameter_t); + struct xen_sysctl { uint32_t cmd; #define XEN_SYSCTL_readconsole 1 @@ -1124,6 +1141,7 @@ struct xen_sysctl { #define XEN_SYSCTL_get_cpu_levelling_caps 25 #define XEN_SYSCTL_get_cpu_featureset 26 #define XEN_SYSCTL_livepatch_op 27 +#define XEN_SYSCTL_set_parameter 28 uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */ union { struct xen_sysctl_readconsole readconsole; @@ -1152,6 +1170,7 @@ struct xen_sysctl { struct xen_sysctl_cpu_levelling_caps cpu_levelling_caps; struct xen_sysctl_cpu_featureset cpu_featureset; struct xen_sysctl_livepatch_op livepatch; + struct xen_sysctl_set_parameter set_parameter; uint8_t pad[128]; } u; }; diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index fd84ac0f09..af709736ac 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -826,6 +826,9 @@ static int flask_sysctl(int cmd) return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN2, XEN2__GCOV_OP, NULL); + case XEN_SYSCTL_set_parameter: + return domain_has_xen(current->domain, XEN2__SET_PARAMETER); + default: return avc_unknown_permission("sysctl", cmd); } diff --git a/xen/xsm/flask/policy/access_vectors b/xen/xsm/flask/policy/access_vectors index 1f7eb35fc8..b80fca1ec0 100644 --- a/xen/xsm/flask/policy/access_vectors +++ b/xen/xsm/flask/policy/access_vectors @@ -101,6 +101,8 @@ class xen2 livepatch_op # XEN_SYSCTL_gcov_op gcov_op +# XEN_SYSCTL_set_parameter + set_parameter } # Classes domain and domain2 consist of operations that a domain performs on -- 2.12.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |