[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v7 04/16] xen: add new domctl hypercall to set grant table resource limits
On 19/09/17 12:14, Paul Durrant wrote: >> -----Original Message----- >> From: Xen-devel [mailto:xen-devel-bounces@xxxxxxxxxxxxx] On Behalf Of >> Juergen Gross >> Sent: 19 September 2017 10:59 >> To: xen-devel@xxxxxxxxxxxxxxxxxxxx >> Cc: Juergen Gross <jgross@xxxxxxxx>; sstabellini@xxxxxxxxxx; Wei Liu >> <wei.liu2@xxxxxxxxxx>; George Dunlap <George.Dunlap@xxxxxxxxxx>; >> Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>; Ian Jackson >> <Ian.Jackson@xxxxxxxxxx>; Tim (Xen.org) <tim@xxxxxxx>; >> julien.grall@xxxxxxx; jbeulich@xxxxxxxx; dgdegra@xxxxxxxxxxxxx >> Subject: [Xen-devel] [PATCH v7 04/16] xen: add new domctl hypercall to set >> grant table resource limits >> >> Add a domctl hypercall to set the domain's resource limits regarding >> grant tables. >> >> Signed-off-by: Juergen Gross <jgross@xxxxxxxx> >> Acked-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx> >> --- >> V6: >> - moved earlier in series to support set_gnttab_limits being >> mandatory for domain creation >> >> V5: >> - add set_gnttab_limits to create_domain_common in xen.if >> (Daniel De Graaf) >> >> V3: >> - rename *gnttbl* to *gnttab* (Paul Durrant) >> --- >> tools/flask/policy/modules/dom0.te | 2 +- >> tools/flask/policy/modules/xen.if | 2 +- >> xen/common/domctl.c | 6 ++++++ >> xen/common/grant_table.c | 19 +++++++++++++++++++ >> xen/include/public/domctl.h | 11 +++++++++++ >> xen/include/xen/grant_table.h | 2 ++ >> xen/xsm/flask/hooks.c | 3 +++ >> xen/xsm/flask/policy/access_vectors | 2 ++ >> 8 files changed, 45 insertions(+), 2 deletions(-) >> >> diff --git a/tools/flask/policy/modules/dom0.te >> b/tools/flask/policy/modules/dom0.te >> index 338caaf41e..1643b400f0 100644 >> --- a/tools/flask/policy/modules/dom0.te >> +++ b/tools/flask/policy/modules/dom0.te >> @@ -39,7 +39,7 @@ allow dom0_t dom0_t:domain { >> }; >> allow dom0_t dom0_t:domain2 { >> set_cpuid gettsc settsc setscheduler set_max_evtchn >> set_vnumainfo >> - get_vnumainfo psr_cmt_op psr_cat_op >> + get_vnumainfo psr_cmt_op psr_cat_op set_gnttab_limits >> }; >> allow dom0_t dom0_t:resource { add remove }; >> >> diff --git a/tools/flask/policy/modules/xen.if >> b/tools/flask/policy/modules/xen.if >> index 912640002e..55437496f6 100644 >> --- a/tools/flask/policy/modules/xen.if >> +++ b/tools/flask/policy/modules/xen.if >> @@ -52,7 +52,7 @@ define(`create_domain_common', ` >> settime setdomainhandle getvcpucontext >> set_misc_info }; >> allow $1 $2:domain2 { set_cpuid settsc setscheduler setclaim >> set_max_evtchn set_vnumainfo get_vnumainfo >> cacheflush >> - psr_cmt_op psr_cat_op soft_reset }; >> + psr_cmt_op psr_cat_op soft_reset set_gnttab_limits >> }; >> allow $1 $2:security check_context; >> allow $1 $2:shadow enable; >> allow $1 $2:mmu { map_read map_write adjust memorymap >> physmap pinpage mmuext_op updatemp }; >> diff --git a/xen/common/domctl.c b/xen/common/domctl.c >> index 42658e5744..58381f8fe9 100644 >> --- a/xen/common/domctl.c >> +++ b/xen/common/domctl.c >> @@ -14,6 +14,7 @@ >> #include <xen/sched-if.h> >> #include <xen/domain.h> >> #include <xen/event.h> >> +#include <xen/grant_table.h> >> #include <xen/domain_page.h> >> #include <xen/trace.h> >> #include <xen/console.h> >> @@ -1149,6 +1150,11 @@ long >> do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) >> copyback = 1; >> break; >> >> + case XEN_DOMCTL_set_gnttab_limits: >> + ret = grant_table_set_limits(d, >> op->u.set_gnttab_limits.grant_frames, >> + >> op->u.set_gnttab_limits.maptrack_frames); >> + break; >> + >> default: >> ret = arch_do_domctl(op, d, u_domctl); >> break; >> diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c >> index ac845dbb35..f48eeff7ad 100644 >> --- a/xen/common/grant_table.c >> +++ b/xen/common/grant_table.c >> @@ -3640,6 +3640,25 @@ void grant_table_init_vcpu(struct vcpu *v) >> v->maptrack_tail = MAPTRACK_TAIL; >> } >> >> +int grant_table_set_limits(struct domain *d, unsigned int grant_frames, >> + unsigned int maptrack_frames) >> +{ >> + struct grant_table *gt = d->grant_table; >> + int ret = -EBUSY; >> + >> + if ( !gt ) >> + return -ENOENT; >> + >> + grant_write_lock(gt); >> + >> + ret = 0; >> + /* Set limits, alloc needed arrays. */ >> + >> + grant_write_unlock(gt); >> + >> + return ret; >> +} >> + >> #ifdef CONFIG_HAS_MEM_SHARING >> int mem_sharing_gref_to_gfn(struct grant_table *gt, grant_ref_t ref, >> gfn_t *gfn, uint16_t *status) >> diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h >> index 50ff58f5b9..685c6ebc15 100644 >> --- a/xen/include/public/domctl.h >> +++ b/xen/include/public/domctl.h >> @@ -1163,6 +1163,15 @@ struct xen_domctl_psr_cat_op { >> typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t; >> DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t); >> >> +struct xen_domctl_set_gnttab_limits { >> + uint32_t grant_frames; /* IN: if 0, dont change */ >> + uint32_t maptrack_frames; /* IN: if 0, dont change */ >> +}; > > Why the #if 0 here? Because I missed to delete it. The "if 0" comments above are stale, too. Juergen > > Paul > >> +#if 0 >> +typedef struct xen_domctl_set_gnttab_limits >> xen_domctl_set_gnttab_limits_t; >> +DEFINE_XEN_GUEST_HANDLE(xen_domctl_set_gnttab_limits_t); >> +#endif >> + >> struct xen_domctl { >> uint32_t cmd; >> #define XEN_DOMCTL_createdomain 1 >> @@ -1240,6 +1249,7 @@ struct xen_domctl { >> #define XEN_DOMCTL_monitor_op 77 >> #define XEN_DOMCTL_psr_cat_op 78 >> #define XEN_DOMCTL_soft_reset 79 >> +#define XEN_DOMCTL_set_gnttab_limits 80 >> #define XEN_DOMCTL_gdbsx_guestmemio 1000 >> #define XEN_DOMCTL_gdbsx_pausevcpu 1001 >> #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 >> @@ -1302,6 +1312,7 @@ struct xen_domctl { >> struct xen_domctl_psr_cmt_op psr_cmt_op; >> struct xen_domctl_monitor_op monitor_op; >> struct xen_domctl_psr_cat_op psr_cat_op; >> + struct xen_domctl_set_gnttab_limits set_gnttab_limits; >> uint8_t pad[128]; >> } u; >> }; >> diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h >> index 43b07e60c5..df11b31264 100644 >> --- a/xen/include/xen/grant_table.h >> +++ b/xen/include/xen/grant_table.h >> @@ -38,6 +38,8 @@ int grant_table_create( >> void grant_table_destroy( >> struct domain *d); >> void grant_table_init_vcpu(struct vcpu *v); >> +int grant_table_set_limits(struct domain *d, unsigned int grant_frames, >> + unsigned int maptrack_frames); >> >> /* >> * Check if domain has active grants and log first 10 of them. >> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c >> index 56dc5b0ab9..7b005af834 100644 >> --- a/xen/xsm/flask/hooks.c >> +++ b/xen/xsm/flask/hooks.c >> @@ -749,6 +749,9 @@ static int flask_domctl(struct domain *d, int cmd) >> case XEN_DOMCTL_soft_reset: >> return current_has_perm(d, SECCLASS_DOMAIN2, >> DOMAIN2__SOFT_RESET); >> >> + case XEN_DOMCTL_set_gnttab_limits: >> + return current_has_perm(d, SECCLASS_DOMAIN2, >> DOMAIN2__SET_GNTTAB_LIMITS); >> + >> default: >> return avc_unknown_permission("domctl", cmd); >> } >> diff --git a/xen/xsm/flask/policy/access_vectors >> b/xen/xsm/flask/policy/access_vectors >> index da9f3dfb2e..3a2d863b8f 100644 >> --- a/xen/xsm/flask/policy/access_vectors >> +++ b/xen/xsm/flask/policy/access_vectors >> @@ -248,6 +248,8 @@ class domain2 >> mem_sharing >> # XEN_DOMCTL_psr_cat_op >> psr_cat_op >> +# XEN_DOMCTL_set_gnttab_limits >> + set_gnttab_limits >> } >> >> # Similar to class domain, but primarily contains domctls related to HVM >> domains >> -- >> 2.12.3 >> >> >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@xxxxxxxxxxxxx >> https://lists.xen.org/xen-devel _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |