Message ID | 1506160104-5890-3-git-send-email-yi.y.sun@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sat, Sep 23, 2017 at 09:48:11AM +0000, Yi Sun wrote: > --- a/xen/arch/x86/domctl.c > +++ b/xen/arch/x86/domctl.c > @@ -1439,60 +1439,60 @@ long arch_do_domctl( > } > break; > > - case XEN_DOMCTL_psr_cat_op: > - switch ( domctl->u.psr_cat_op.cmd ) > + case XEN_DOMCTL_psr_alloc: > + switch ( domctl->u.psr_alloc.cmd ) > { > uint32_t val32; > > - case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CBM: > - ret = psr_set_val(d, domctl->u.psr_cat_op.target, > - domctl->u.psr_cat_op.data, > + case XEN_DOMCTL_PSR_SET_L3_CBM: > + ret = psr_set_val(d, domctl->u.psr_alloc.target, > + domctl->u.psr_alloc.data, > PSR_CBM_TYPE_L3); > break; > > - case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CODE: > - ret = psr_set_val(d, domctl->u.psr_cat_op.target, > - domctl->u.psr_cat_op.data, > + case XEN_DOMCTL_PSR_SET_L3_CODE: > + ret = psr_set_val(d, domctl->u.psr_alloc.target, > + domctl->u.psr_alloc.data, > PSR_CBM_TYPE_L3_CODE); > break; > > - case XEN_DOMCTL_PSR_CAT_OP_SET_L3_DATA: > - ret = psr_set_val(d, domctl->u.psr_cat_op.target, > - domctl->u.psr_cat_op.data, > + case XEN_DOMCTL_PSR_SET_L3_DATA: > + ret = psr_set_val(d, domctl->u.psr_alloc.target, > + domctl->u.psr_alloc.data, > PSR_CBM_TYPE_L3_DATA); > break; > > - case XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM: > - ret = psr_set_val(d, domctl->u.psr_cat_op.target, > - domctl->u.psr_cat_op.data, > + case XEN_DOMCTL_PSR_SET_L2_CBM: > + ret = psr_set_val(d, domctl->u.psr_alloc.target, > + domctl->u.psr_alloc.data, > PSR_CBM_TYPE_L2); > break; > > - case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM: > - ret = psr_get_val(d, domctl->u.psr_cat_op.target, > + case XEN_DOMCTL_PSR_GET_L3_CBM: > + ret = psr_get_val(d, domctl->u.psr_alloc.target, > &val32, PSR_CBM_TYPE_L3); > - domctl->u.psr_cat_op.data = val32; > + domctl->u.psr_alloc.data = val32; > copyback = true; > break; > > - case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE: > - ret = psr_get_val(d, domctl->u.psr_cat_op.target, > + case XEN_DOMCTL_PSR_GET_L3_CODE: > + ret = psr_get_val(d, domctl->u.psr_alloc.target, > &val32, PSR_CBM_TYPE_L3_CODE); > - domctl->u.psr_cat_op.data = val32; > + domctl->u.psr_alloc.data = val32; > copyback = true; > break; > > - case XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA: > - ret = psr_get_val(d, domctl->u.psr_cat_op.target, > + case XEN_DOMCTL_PSR_GET_L3_DATA: > + ret = psr_get_val(d, domctl->u.psr_alloc.target, > &val32, PSR_CBM_TYPE_L3_DATA); > - domctl->u.psr_cat_op.data = val32; > + domctl->u.psr_alloc.data = val32; > copyback = true; > break; > > - case XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM: > - ret = psr_get_val(d, domctl->u.psr_cat_op.target, > + case XEN_DOMCTL_PSR_GET_L2_CBM: > + ret = psr_get_val(d, domctl->u.psr_alloc.target, > &val32, PSR_CBM_TYPE_L2); > - domctl->u.psr_cat_op.data = val32; > + domctl->u.psr_alloc.data = val32; > copyback = true; This: ret = psr_get_val(...); domctl->u.psr...; copyback = true; Construct is quite repetitive, maybe you could consider adding a local macro to hide it? Maybe then you could also hide the val32 declaration inside of it. > break; > > diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c > index daa2aeb..c851511 100644 > --- a/xen/arch/x86/psr.c > +++ b/xen/arch/x86/psr.c > @@ -382,7 +382,7 @@ static bool l3_cdp_get_feat_info(const struct feat_node *feat, > if ( !cat_get_feat_info(feat, data, array_len) ) > return false; > > - data[PSR_INFO_IDX_CAT_FLAG] |= XEN_SYSCTL_PSR_CAT_L3_CDP; > + data[PSR_INFO_IDX_CAT_FLAG] |= XEN_SYSCTL_PSR_L3_CDP; > > return true; > } > diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c > index c3fdae8..e44d8ad 100644 > --- a/xen/arch/x86/sysctl.c > +++ b/xen/arch/x86/sysctl.c > @@ -171,45 +171,45 @@ long arch_do_sysctl( > > break; > > - case XEN_SYSCTL_psr_cat_op: > - switch ( sysctl->u.psr_cat_op.cmd ) > + case XEN_SYSCTL_psr_alloc: > + switch ( sysctl->u.psr_alloc.cmd ) > { > uint32_t data[PSR_INFO_ARRAY_SIZE]; > > - case XEN_SYSCTL_PSR_CAT_get_l3_info: > + case XEN_SYSCTL_PSR_get_l3_info: > { > - ret = psr_get_info(sysctl->u.psr_cat_op.target, > + ret = psr_get_info(sysctl->u.psr_alloc.target, > PSR_CBM_TYPE_L3, data, ARRAY_SIZE(data)); > if ( ret ) > break; > > - sysctl->u.psr_cat_op.u.cat_info.cos_max = > + sysctl->u.psr_alloc.u.cat_info.cos_max = > data[PSR_INFO_IDX_COS_MAX]; > - sysctl->u.psr_cat_op.u.cat_info.cbm_len = > + sysctl->u.psr_alloc.u.cat_info.cbm_len = > data[PSR_INFO_IDX_CAT_CBM_LEN]; > - sysctl->u.psr_cat_op.u.cat_info.flags = > + sysctl->u.psr_alloc.u.cat_info.flags = > data[PSR_INFO_IDX_CAT_FLAG]; > > - if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) ) > + if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc) ) > ret = -EFAULT; > break; > } > > - case XEN_SYSCTL_PSR_CAT_get_l2_info: > + case XEN_SYSCTL_PSR_get_l2_info: > { > - ret = psr_get_info(sysctl->u.psr_cat_op.target, > + ret = psr_get_info(sysctl->u.psr_alloc.target, > PSR_CBM_TYPE_L2, data, ARRAY_SIZE(data)); > if ( ret ) > break; > > - sysctl->u.psr_cat_op.u.cat_info.cos_max = > + sysctl->u.psr_alloc.u.cat_info.cos_max = > data[PSR_INFO_IDX_COS_MAX]; > - sysctl->u.psr_cat_op.u.cat_info.cbm_len = > + sysctl->u.psr_alloc.u.cat_info.cbm_len = > data[PSR_INFO_IDX_CAT_CBM_LEN]; > - sysctl->u.psr_cat_op.u.cat_info.flags = > + sysctl->u.psr_alloc.u.cat_info.flags = > data[PSR_INFO_IDX_CAT_FLAG]; The above repetition is also unneeded AFAICT. Why not simplify the switch to: uint32_t data[PSR_INFO_ARRAY_SIZE]; enum cbm_type type; switch ( sysctl->u.psr_alloc.cmd ) { case XEN_SYSCTL_PSR_get_l3_info: type = PSR_CBM_TYPE_L3; break; case XEN_SYSCTL_PSR_get_l2_info: type = PSR_CBM_TYPE_L2; break; default: return -EOPNOTSUPP; } ret = psr_get_info(sysctl->u.psr_alloc.target, type, data, ARRAY_SIZE(data)); if ( ret ) break; sysctl->u.psr_alloc.u.cat_info.cos_max = data[PSR_INFO_IDX_COS_MAX]; ... It would prevent some of this code repetition IMHO. Thanks, Roger.
On 17-09-25 17:15:21, Roger Pau Monn� wrote: > On Sat, Sep 23, 2017 at 09:48:11AM +0000, Yi Sun wrote: > > --- a/xen/arch/x86/domctl.c > > +++ b/xen/arch/x86/domctl.c [...] > > - case XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA: > > - ret = psr_get_val(d, domctl->u.psr_cat_op.target, > > + case XEN_DOMCTL_PSR_GET_L3_DATA: > > + ret = psr_get_val(d, domctl->u.psr_alloc.target, > > &val32, PSR_CBM_TYPE_L3_DATA); > > - domctl->u.psr_cat_op.data = val32; > > + domctl->u.psr_alloc.data = val32; > > copyback = true; > > break; > > > > - case XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM: > > - ret = psr_get_val(d, domctl->u.psr_cat_op.target, > > + case XEN_DOMCTL_PSR_GET_L2_CBM: > > + ret = psr_get_val(d, domctl->u.psr_alloc.target, > > &val32, PSR_CBM_TYPE_L2); > > - domctl->u.psr_cat_op.data = val32; > > + domctl->u.psr_alloc.data = val32; > > copyback = true; > > This: > > ret = psr_get_val(...); > domctl->u.psr...; > copyback = true; > > Construct is quite repetitive, maybe you could consider adding a local > macro to hide it? > > Maybe then you could also hide the val32 declaration inside of it. > Thanks for the suggestion! Let me try. [...] > > > > --- a/xen/arch/x86/sysctl.c > > +++ b/xen/arch/x86/sysctl.c > > @@ -171,45 +171,45 @@ long arch_do_sysctl( > > > > break; > > > > - case XEN_SYSCTL_psr_cat_op: > > - switch ( sysctl->u.psr_cat_op.cmd ) > > + case XEN_SYSCTL_psr_alloc: > > + switch ( sysctl->u.psr_alloc.cmd ) > > { > > uint32_t data[PSR_INFO_ARRAY_SIZE]; > > > > - case XEN_SYSCTL_PSR_CAT_get_l3_info: > > + case XEN_SYSCTL_PSR_get_l3_info: > > { > > - ret = psr_get_info(sysctl->u.psr_cat_op.target, > > + ret = psr_get_info(sysctl->u.psr_alloc.target, > > PSR_CBM_TYPE_L3, data, ARRAY_SIZE(data)); > > if ( ret ) > > break; > > > > - sysctl->u.psr_cat_op.u.cat_info.cos_max = > > + sysctl->u.psr_alloc.u.cat_info.cos_max = > > data[PSR_INFO_IDX_COS_MAX]; > > - sysctl->u.psr_cat_op.u.cat_info.cbm_len = > > + sysctl->u.psr_alloc.u.cat_info.cbm_len = > > data[PSR_INFO_IDX_CAT_CBM_LEN]; > > - sysctl->u.psr_cat_op.u.cat_info.flags = > > + sysctl->u.psr_alloc.u.cat_info.flags = > > data[PSR_INFO_IDX_CAT_FLAG]; > > > > - if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) ) > > + if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc) ) > > ret = -EFAULT; > > break; > > } > > > > - case XEN_SYSCTL_PSR_CAT_get_l2_info: > > + case XEN_SYSCTL_PSR_get_l2_info: > > { > > - ret = psr_get_info(sysctl->u.psr_cat_op.target, > > + ret = psr_get_info(sysctl->u.psr_alloc.target, > > PSR_CBM_TYPE_L2, data, ARRAY_SIZE(data)); > > if ( ret ) > > break; > > > > - sysctl->u.psr_cat_op.u.cat_info.cos_max = > > + sysctl->u.psr_alloc.u.cat_info.cos_max = > > data[PSR_INFO_IDX_COS_MAX]; > > - sysctl->u.psr_cat_op.u.cat_info.cbm_len = > > + sysctl->u.psr_alloc.u.cat_info.cbm_len = > > data[PSR_INFO_IDX_CAT_CBM_LEN]; > > - sysctl->u.psr_cat_op.u.cat_info.flags = > > + sysctl->u.psr_alloc.u.cat_info.flags = > > data[PSR_INFO_IDX_CAT_FLAG]; > > The above repetition is also unneeded AFAICT. Why not simplify the > switch to: > > uint32_t data[PSR_INFO_ARRAY_SIZE]; > enum cbm_type type; > > switch ( sysctl->u.psr_alloc.cmd ) > { > case XEN_SYSCTL_PSR_get_l3_info: > type = PSR_CBM_TYPE_L3; > break; > case XEN_SYSCTL_PSR_get_l2_info: > type = PSR_CBM_TYPE_L2; > break; > default: > return -EOPNOTSUPP; > } > > ret = psr_get_info(sysctl->u.psr_alloc.target, type, data, ARRAY_SIZE(data)); > if ( ret ) > break; > > sysctl->u.psr_alloc.u.cat_info.cos_max = data[PSR_INFO_IDX_COS_MAX]; > ... > > It would prevent some of this code repetition IMHO. > Thank you! But this way seems only good to CAT features but could not cover MBA. Although I can assign "type = PSR_TYPE_MBA_THRTL" for MBA, the assignment of 'sysctl->u.psr_alloc.u.mba_info' and 'sysctl->u.psr_alloc.u.cat_info' cannot be converged. We have to check the type to decide to assign value to which 'info'. > Thanks, Roger.
On Sat, Sep 23, 2017 at 05:48:11PM +0800, Yi Sun wrote: > This patch renames PSR sysctl/domctl interfaces and related xsm policy to > make them be general for all resource allocation features but not only > for CAT. Then, we can resuse the interfaces for all allocation features. > > Basically, it changes 'psr_cat_op' to 'psr_alloc', and remove 'CAT_' from some > macros. E.g.: > 1. psr_cat_op -> psr_alloc > 2. XEN_DOMCTL_psr_cat_op -> XEN_DOMCTL_psr_alloc > 3. XEN_SYSCTL_psr_cat_op -> XEN_SYSCTL_psr_alloc > 4. XEN_DOMCTL_PSR_CAT_SET_L3_CBM -> XEN_DOMCTL_PSR_SET_L3_CBM > 5. XEN_SYSCTL_PSR_CAT_get_l3_info -> XEN_SYSCTL_PSR_get_l3_info > > The sysctl/domctl version numbers are bumped. > > Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com> > Reviewed-by: Wei Liu <wei.liu2@citrix.com> > Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Normally if there have been substantive changes you should drop the reviews. It seems to be the case. I will need to review this patch again.
On 17-09-26 15:19:19, Wei Liu wrote: > On Sat, Sep 23, 2017 at 05:48:11PM +0800, Yi Sun wrote: > > This patch renames PSR sysctl/domctl interfaces and related xsm policy to > > make them be general for all resource allocation features but not only > > for CAT. Then, we can resuse the interfaces for all allocation features. > > > > Basically, it changes 'psr_cat_op' to 'psr_alloc', and remove 'CAT_' from some > > macros. E.g.: > > 1. psr_cat_op -> psr_alloc > > 2. XEN_DOMCTL_psr_cat_op -> XEN_DOMCTL_psr_alloc > > 3. XEN_SYSCTL_psr_cat_op -> XEN_SYSCTL_psr_alloc > > 4. XEN_DOMCTL_PSR_CAT_SET_L3_CBM -> XEN_DOMCTL_PSR_SET_L3_CBM > > 5. XEN_SYSCTL_PSR_CAT_get_l3_info -> XEN_SYSCTL_PSR_get_l3_info > > > > The sysctl/domctl version numbers are bumped. > > > > Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com> > > Reviewed-by: Wei Liu <wei.liu2@citrix.com> > > Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> > > Normally if there have been substantive changes you should drop the > reviews. It seems to be the case. I will need to review this patch > again. Sorry for that. I thought they were just name changes. So I did not drop reviews. But this patch's main purpose is 'rename'. I should drop reviews. Will notice this.
On Thu, Sep 28, 2017 at 10:12:08AM +0800, Yi Sun wrote: > On 17-09-26 15:19:19, Wei Liu wrote: > > On Sat, Sep 23, 2017 at 05:48:11PM +0800, Yi Sun wrote: > > > This patch renames PSR sysctl/domctl interfaces and related xsm policy to > > > make them be general for all resource allocation features but not only > > > for CAT. Then, we can resuse the interfaces for all allocation features. > > > > > > Basically, it changes 'psr_cat_op' to 'psr_alloc', and remove 'CAT_' from some > > > macros. E.g.: > > > 1. psr_cat_op -> psr_alloc > > > 2. XEN_DOMCTL_psr_cat_op -> XEN_DOMCTL_psr_alloc > > > 3. XEN_SYSCTL_psr_cat_op -> XEN_SYSCTL_psr_alloc > > > 4. XEN_DOMCTL_PSR_CAT_SET_L3_CBM -> XEN_DOMCTL_PSR_SET_L3_CBM > > > 5. XEN_SYSCTL_PSR_CAT_get_l3_info -> XEN_SYSCTL_PSR_get_l3_info > > > > > > The sysctl/domctl version numbers are bumped. > > > > > > Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com> > > > Reviewed-by: Wei Liu <wei.liu2@citrix.com> > > > Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> > > > > Normally if there have been substantive changes you should drop the > > reviews. It seems to be the case. I will need to review this patch > > again. > > Sorry for that. > > I thought they were just name changes. So I did not drop reviews. But > this patch's main purpose is 'rename'. I should drop reviews. Will > notice this. No need to be sorry, really. This isn't something that can be documented clearly. If unsure, always drop the tags in the future.
>>> On 23.09.17 at 11:48, <yi.y.sun@linux.intel.com> wrote: > --- a/xen/include/public/domctl.h > +++ b/xen/include/public/domctl.h > @@ -37,7 +37,7 @@ > #include "hvm/save.h" > #include "memory.h" > > -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000e > +#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f This is needed only if the series doesn't make 4.10; 4.9 had it ad 0x0000000d. > @@ -743,22 +743,22 @@ struct xen_sysctl_pcitopoinfo { > typedef struct xen_sysctl_pcitopoinfo xen_sysctl_pcitopoinfo_t; > DEFINE_XEN_GUEST_HANDLE(xen_sysctl_pcitopoinfo_t); > > -#define XEN_SYSCTL_PSR_CAT_get_l3_info 0 > -#define XEN_SYSCTL_PSR_CAT_get_l2_info 1 > -struct xen_sysctl_psr_cat_op { > - uint32_t cmd; /* IN: XEN_SYSCTL_PSR_CAT_* */ > +#define XEN_SYSCTL_PSR_get_l3_info 0 > +#define XEN_SYSCTL_PSR_get_l2_info 1 > +struct xen_sysctl_psr_alloc { > + uint32_t cmd; /* IN: XEN_SYSCTL_PSR_* */ > uint32_t target; /* IN */ > union { > struct { > uint32_t cbm_len; /* OUT: CBM length */ > uint32_t cos_max; /* OUT: Maximum COS */ > -#define XEN_SYSCTL_PSR_CAT_L3_CDP (1u << 0) > +#define XEN_SYSCTL_PSR_L3_CDP (1u << 0) Is MBA have something like CDP as well, which can go through the same subop? Otherwise I think CAT would better remain present in this constant's name. Jan
On 17-09-28 04:21:10, Jan Beulich wrote: > >>> On 23.09.17 at 11:48, <yi.y.sun@linux.intel.com> wrote: > > --- a/xen/include/public/domctl.h > > +++ b/xen/include/public/domctl.h > > @@ -37,7 +37,7 @@ > > #include "hvm/save.h" > > #include "memory.h" > > > > -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000e > > +#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f > > This is needed only if the series doesn't make 4.10; 4.9 had it > ad 0x0000000d. > Thanks! So, this version number is upgraded only for one release. I thought every interface change should bump it. > > @@ -743,22 +743,22 @@ struct xen_sysctl_pcitopoinfo { > > typedef struct xen_sysctl_pcitopoinfo xen_sysctl_pcitopoinfo_t; > > DEFINE_XEN_GUEST_HANDLE(xen_sysctl_pcitopoinfo_t); > > > > -#define XEN_SYSCTL_PSR_CAT_get_l3_info 0 > > -#define XEN_SYSCTL_PSR_CAT_get_l2_info 1 > > -struct xen_sysctl_psr_cat_op { > > - uint32_t cmd; /* IN: XEN_SYSCTL_PSR_CAT_* */ > > +#define XEN_SYSCTL_PSR_get_l3_info 0 > > +#define XEN_SYSCTL_PSR_get_l2_info 1 > > +struct xen_sysctl_psr_alloc { > > + uint32_t cmd; /* IN: XEN_SYSCTL_PSR_* */ > > uint32_t target; /* IN */ > > union { > > struct { > > uint32_t cbm_len; /* OUT: CBM length */ > > uint32_t cos_max; /* OUT: Maximum COS */ > > -#define XEN_SYSCTL_PSR_CAT_L3_CDP (1u << 0) > > +#define XEN_SYSCTL_PSR_L3_CDP (1u << 0) > > Is MBA have something like CDP as well, which can go through the > same subop? Otherwise I think CAT would better remain present > in this constant's name. > No. I will keep CAT for this macro. > Jan
>>> Yi Sun <yi.y.sun@linux.intel.com> 09/29/17 3:37 AM >>> >On 17-09-28 04:21:10, Jan Beulich wrote: >> >>> On 23.09.17 at 11:48, <yi.y.sun@linux.intel.com> wrote: >> > --- a/xen/include/public/domctl.h >> > +++ b/xen/include/public/domctl.h >> > @@ -37,7 +37,7 @@ >> > #include "hvm/save.h" >> > #include "memory.h" >> > >> > -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000e >> > +#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f >> >> This is needed only if the series doesn't make 4.10; 4.9 had it >> ad 0x0000000d. >> >Thanks! So, this version number is upgraded only for one release. I thought >every interface change should bump it. It's for consumers to be in line with releases; breaking consumers between unstable snapshots is not a concern (developers should be aware). Jan
diff --git a/tools/flask/policy/modules/dom0.te b/tools/flask/policy/modules/dom0.te index 338caaf..fb1a299 100644 --- a/tools/flask/policy/modules/dom0.te +++ b/tools/flask/policy/modules/dom0.te @@ -14,7 +14,7 @@ allow dom0_t xen_t:xen { tmem_control getscheduler setscheduler }; allow dom0_t xen_t:xen2 { - resource_op psr_cmt_op psr_cat_op pmu_ctrl get_symbol + resource_op psr_cmt_op psr_alloc pmu_ctrl get_symbol get_cpu_levelling_caps get_cpu_featureset livepatch_op gcov_op set_parameter }; @@ -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_alloc }; allow dom0_t dom0_t:resource { add remove }; diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c index 039b920..623e26b 100644 --- a/tools/libxc/xc_psr.c +++ b/tools/libxc/xc_psr.c @@ -258,27 +258,27 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid, switch ( type ) { case XC_PSR_CAT_L3_CBM: - cmd = XEN_DOMCTL_PSR_CAT_OP_SET_L3_CBM; + cmd = XEN_DOMCTL_PSR_SET_L3_CBM; break; case XC_PSR_CAT_L3_CBM_CODE: - cmd = XEN_DOMCTL_PSR_CAT_OP_SET_L3_CODE; + cmd = XEN_DOMCTL_PSR_SET_L3_CODE; break; case XC_PSR_CAT_L3_CBM_DATA: - cmd = XEN_DOMCTL_PSR_CAT_OP_SET_L3_DATA; + cmd = XEN_DOMCTL_PSR_SET_L3_DATA; break; case XC_PSR_CAT_L2_CBM: - cmd = XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM; + cmd = XEN_DOMCTL_PSR_SET_L2_CBM; break; default: errno = EINVAL; return -1; } - domctl.cmd = XEN_DOMCTL_psr_cat_op; + domctl.cmd = XEN_DOMCTL_psr_alloc; domctl.domain = (domid_t)domid; - domctl.u.psr_cat_op.cmd = cmd; - domctl.u.psr_cat_op.target = target; - domctl.u.psr_cat_op.data = data; + domctl.u.psr_alloc.cmd = cmd; + domctl.u.psr_alloc.target = target; + domctl.u.psr_alloc.data = data; return do_domctl(xch, &domctl); } @@ -294,31 +294,31 @@ int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid, switch ( type ) { case XC_PSR_CAT_L3_CBM: - cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM; + cmd = XEN_DOMCTL_PSR_GET_L3_CBM; break; case XC_PSR_CAT_L3_CBM_CODE: - cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE; + cmd = XEN_DOMCTL_PSR_GET_L3_CODE; break; case XC_PSR_CAT_L3_CBM_DATA: - cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA; + cmd = XEN_DOMCTL_PSR_GET_L3_DATA; break; case XC_PSR_CAT_L2_CBM: - cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM; + cmd = XEN_DOMCTL_PSR_GET_L2_CBM; break; default: errno = EINVAL; return -1; } - domctl.cmd = XEN_DOMCTL_psr_cat_op; + domctl.cmd = XEN_DOMCTL_psr_alloc; domctl.domain = (domid_t)domid; - domctl.u.psr_cat_op.cmd = cmd; - domctl.u.psr_cat_op.target = target; + domctl.u.psr_alloc.cmd = cmd; + domctl.u.psr_alloc.target = target; rc = do_domctl(xch, &domctl); if ( !rc ) - *data = domctl.u.psr_cat_op.data; + *data = domctl.u.psr_alloc.data; return rc; } @@ -329,30 +329,30 @@ int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, unsigned int lvl, int rc = -1; DECLARE_SYSCTL; - sysctl.cmd = XEN_SYSCTL_psr_cat_op; - sysctl.u.psr_cat_op.target = socket; + sysctl.cmd = XEN_SYSCTL_psr_alloc; + sysctl.u.psr_alloc.target = socket; switch ( lvl ) { case 2: - sysctl.u.psr_cat_op.cmd = XEN_SYSCTL_PSR_CAT_get_l2_info; + sysctl.u.psr_alloc.cmd = XEN_SYSCTL_PSR_get_l2_info; rc = xc_sysctl(xch, &sysctl); if ( !rc ) { - *cos_max = sysctl.u.psr_cat_op.u.cat_info.cos_max; - *cbm_len = sysctl.u.psr_cat_op.u.cat_info.cbm_len; + *cos_max = sysctl.u.psr_alloc.u.cat_info.cos_max; + *cbm_len = sysctl.u.psr_alloc.u.cat_info.cbm_len; *cdp_enabled = false; } break; case 3: - sysctl.u.psr_cat_op.cmd = XEN_SYSCTL_PSR_CAT_get_l3_info; + sysctl.u.psr_alloc.cmd = XEN_SYSCTL_PSR_get_l3_info; rc = xc_sysctl(xch, &sysctl); if ( !rc ) { - *cos_max = sysctl.u.psr_cat_op.u.cat_info.cos_max; - *cbm_len = sysctl.u.psr_cat_op.u.cat_info.cbm_len; - *cdp_enabled = sysctl.u.psr_cat_op.u.cat_info.flags & - XEN_SYSCTL_PSR_CAT_L3_CDP; + *cos_max = sysctl.u.psr_alloc.u.cat_info.cos_max; + *cbm_len = sysctl.u.psr_alloc.u.cat_info.cbm_len; + *cdp_enabled = sysctl.u.psr_alloc.u.cat_info.flags & + XEN_SYSCTL_PSR_L3_CDP; } break; default: diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 127c84e..b9afdf3 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1439,60 +1439,60 @@ long arch_do_domctl( } break; - case XEN_DOMCTL_psr_cat_op: - switch ( domctl->u.psr_cat_op.cmd ) + case XEN_DOMCTL_psr_alloc: + switch ( domctl->u.psr_alloc.cmd ) { uint32_t val32; - case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CBM: - ret = psr_set_val(d, domctl->u.psr_cat_op.target, - domctl->u.psr_cat_op.data, + case XEN_DOMCTL_PSR_SET_L3_CBM: + ret = psr_set_val(d, domctl->u.psr_alloc.target, + domctl->u.psr_alloc.data, PSR_CBM_TYPE_L3); break; - case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CODE: - ret = psr_set_val(d, domctl->u.psr_cat_op.target, - domctl->u.psr_cat_op.data, + case XEN_DOMCTL_PSR_SET_L3_CODE: + ret = psr_set_val(d, domctl->u.psr_alloc.target, + domctl->u.psr_alloc.data, PSR_CBM_TYPE_L3_CODE); break; - case XEN_DOMCTL_PSR_CAT_OP_SET_L3_DATA: - ret = psr_set_val(d, domctl->u.psr_cat_op.target, - domctl->u.psr_cat_op.data, + case XEN_DOMCTL_PSR_SET_L3_DATA: + ret = psr_set_val(d, domctl->u.psr_alloc.target, + domctl->u.psr_alloc.data, PSR_CBM_TYPE_L3_DATA); break; - case XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM: - ret = psr_set_val(d, domctl->u.psr_cat_op.target, - domctl->u.psr_cat_op.data, + case XEN_DOMCTL_PSR_SET_L2_CBM: + ret = psr_set_val(d, domctl->u.psr_alloc.target, + domctl->u.psr_alloc.data, PSR_CBM_TYPE_L2); break; - case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM: - ret = psr_get_val(d, domctl->u.psr_cat_op.target, + case XEN_DOMCTL_PSR_GET_L3_CBM: + ret = psr_get_val(d, domctl->u.psr_alloc.target, &val32, PSR_CBM_TYPE_L3); - domctl->u.psr_cat_op.data = val32; + domctl->u.psr_alloc.data = val32; copyback = true; break; - case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE: - ret = psr_get_val(d, domctl->u.psr_cat_op.target, + case XEN_DOMCTL_PSR_GET_L3_CODE: + ret = psr_get_val(d, domctl->u.psr_alloc.target, &val32, PSR_CBM_TYPE_L3_CODE); - domctl->u.psr_cat_op.data = val32; + domctl->u.psr_alloc.data = val32; copyback = true; break; - case XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA: - ret = psr_get_val(d, domctl->u.psr_cat_op.target, + case XEN_DOMCTL_PSR_GET_L3_DATA: + ret = psr_get_val(d, domctl->u.psr_alloc.target, &val32, PSR_CBM_TYPE_L3_DATA); - domctl->u.psr_cat_op.data = val32; + domctl->u.psr_alloc.data = val32; copyback = true; break; - case XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM: - ret = psr_get_val(d, domctl->u.psr_cat_op.target, + case XEN_DOMCTL_PSR_GET_L2_CBM: + ret = psr_get_val(d, domctl->u.psr_alloc.target, &val32, PSR_CBM_TYPE_L2); - domctl->u.psr_cat_op.data = val32; + domctl->u.psr_alloc.data = val32; copyback = true; break; diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index daa2aeb..c851511 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -382,7 +382,7 @@ static bool l3_cdp_get_feat_info(const struct feat_node *feat, if ( !cat_get_feat_info(feat, data, array_len) ) return false; - data[PSR_INFO_IDX_CAT_FLAG] |= XEN_SYSCTL_PSR_CAT_L3_CDP; + data[PSR_INFO_IDX_CAT_FLAG] |= XEN_SYSCTL_PSR_L3_CDP; return true; } diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index c3fdae8..e44d8ad 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -171,45 +171,45 @@ long arch_do_sysctl( break; - case XEN_SYSCTL_psr_cat_op: - switch ( sysctl->u.psr_cat_op.cmd ) + case XEN_SYSCTL_psr_alloc: + switch ( sysctl->u.psr_alloc.cmd ) { uint32_t data[PSR_INFO_ARRAY_SIZE]; - case XEN_SYSCTL_PSR_CAT_get_l3_info: + case XEN_SYSCTL_PSR_get_l3_info: { - ret = psr_get_info(sysctl->u.psr_cat_op.target, + ret = psr_get_info(sysctl->u.psr_alloc.target, PSR_CBM_TYPE_L3, data, ARRAY_SIZE(data)); if ( ret ) break; - sysctl->u.psr_cat_op.u.cat_info.cos_max = + sysctl->u.psr_alloc.u.cat_info.cos_max = data[PSR_INFO_IDX_COS_MAX]; - sysctl->u.psr_cat_op.u.cat_info.cbm_len = + sysctl->u.psr_alloc.u.cat_info.cbm_len = data[PSR_INFO_IDX_CAT_CBM_LEN]; - sysctl->u.psr_cat_op.u.cat_info.flags = + sysctl->u.psr_alloc.u.cat_info.flags = data[PSR_INFO_IDX_CAT_FLAG]; - if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) ) + if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc) ) ret = -EFAULT; break; } - case XEN_SYSCTL_PSR_CAT_get_l2_info: + case XEN_SYSCTL_PSR_get_l2_info: { - ret = psr_get_info(sysctl->u.psr_cat_op.target, + ret = psr_get_info(sysctl->u.psr_alloc.target, PSR_CBM_TYPE_L2, data, ARRAY_SIZE(data)); if ( ret ) break; - sysctl->u.psr_cat_op.u.cat_info.cos_max = + sysctl->u.psr_alloc.u.cat_info.cos_max = data[PSR_INFO_IDX_COS_MAX]; - sysctl->u.psr_cat_op.u.cat_info.cbm_len = + sysctl->u.psr_alloc.u.cat_info.cbm_len = data[PSR_INFO_IDX_CAT_CBM_LEN]; - sysctl->u.psr_cat_op.u.cat_info.flags = + sysctl->u.psr_alloc.u.cat_info.flags = data[PSR_INFO_IDX_CAT_FLAG]; - if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) ) + if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc) ) ret = -EFAULT; break; } diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 50ff58f..0c6f6ae 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -37,7 +37,7 @@ #include "hvm/save.h" #include "memory.h" -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000e +#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f /* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. @@ -1147,21 +1147,21 @@ struct xen_domctl_monitor_op { typedef struct xen_domctl_monitor_op xen_domctl_monitor_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_monitor_op_t); -struct xen_domctl_psr_cat_op { -#define XEN_DOMCTL_PSR_CAT_OP_SET_L3_CBM 0 -#define XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM 1 -#define XEN_DOMCTL_PSR_CAT_OP_SET_L3_CODE 2 -#define XEN_DOMCTL_PSR_CAT_OP_SET_L3_DATA 3 -#define XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE 4 -#define XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA 5 -#define XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM 6 -#define XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM 7 - uint32_t cmd; /* IN: XEN_DOMCTL_PSR_CAT_OP_* */ +struct xen_domctl_psr_alloc { +#define XEN_DOMCTL_PSR_SET_L3_CBM 0 +#define XEN_DOMCTL_PSR_GET_L3_CBM 1 +#define XEN_DOMCTL_PSR_SET_L3_CODE 2 +#define XEN_DOMCTL_PSR_SET_L3_DATA 3 +#define XEN_DOMCTL_PSR_GET_L3_CODE 4 +#define XEN_DOMCTL_PSR_GET_L3_DATA 5 +#define XEN_DOMCTL_PSR_SET_L2_CBM 6 +#define XEN_DOMCTL_PSR_GET_L2_CBM 7 + uint32_t cmd; /* IN: XEN_DOMCTL_PSR_* */ uint32_t target; /* IN */ uint64_t data; /* IN/OUT */ }; -typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t; -DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t); +typedef struct xen_domctl_psr_alloc xen_domctl_psr_alloc_t; +DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_alloc_t); struct xen_domctl { uint32_t cmd; @@ -1238,7 +1238,7 @@ struct xen_domctl { #define XEN_DOMCTL_setvnumainfo 74 #define XEN_DOMCTL_psr_cmt_op 75 #define XEN_DOMCTL_monitor_op 77 -#define XEN_DOMCTL_psr_cat_op 78 +#define XEN_DOMCTL_psr_alloc 78 #define XEN_DOMCTL_soft_reset 79 #define XEN_DOMCTL_gdbsx_guestmemio 1000 #define XEN_DOMCTL_gdbsx_pausevcpu 1001 @@ -1301,7 +1301,7 @@ struct xen_domctl { struct xen_domctl_vnuma vnuma; 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_psr_alloc psr_alloc; uint8_t pad[128]; } u; }; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 7830b98..9cb7e19 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -36,7 +36,7 @@ #include "physdev.h" #include "tmem.h" -#define XEN_SYSCTL_INTERFACE_VERSION 0x0000000F +#define XEN_SYSCTL_INTERFACE_VERSION 0x00000010 /* * Read console content from Xen buffer ring. @@ -743,22 +743,22 @@ struct xen_sysctl_pcitopoinfo { typedef struct xen_sysctl_pcitopoinfo xen_sysctl_pcitopoinfo_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_pcitopoinfo_t); -#define XEN_SYSCTL_PSR_CAT_get_l3_info 0 -#define XEN_SYSCTL_PSR_CAT_get_l2_info 1 -struct xen_sysctl_psr_cat_op { - uint32_t cmd; /* IN: XEN_SYSCTL_PSR_CAT_* */ +#define XEN_SYSCTL_PSR_get_l3_info 0 +#define XEN_SYSCTL_PSR_get_l2_info 1 +struct xen_sysctl_psr_alloc { + uint32_t cmd; /* IN: XEN_SYSCTL_PSR_* */ uint32_t target; /* IN */ union { struct { uint32_t cbm_len; /* OUT: CBM length */ uint32_t cos_max; /* OUT: Maximum COS */ -#define XEN_SYSCTL_PSR_CAT_L3_CDP (1u << 0) +#define XEN_SYSCTL_PSR_L3_CDP (1u << 0) uint32_t flags; /* OUT: CAT flags */ } cat_info; } u; }; -typedef struct xen_sysctl_psr_cat_op xen_sysctl_psr_cat_op_t; -DEFINE_XEN_GUEST_HANDLE(xen_sysctl_psr_cat_op_t); +typedef struct xen_sysctl_psr_alloc xen_sysctl_psr_alloc_t; +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_psr_alloc_t); #define XEN_SYSCTL_TMEM_OP_ALL_CLIENTS 0xFFFFU @@ -1137,7 +1137,7 @@ struct xen_sysctl { #define XEN_SYSCTL_gcov_op 20 #define XEN_SYSCTL_psr_cmt_op 21 #define XEN_SYSCTL_pcitopoinfo 22 -#define XEN_SYSCTL_psr_cat_op 23 +#define XEN_SYSCTL_psr_alloc 23 #define XEN_SYSCTL_tmem_op 24 #define XEN_SYSCTL_get_cpu_levelling_caps 25 #define XEN_SYSCTL_get_cpu_featureset 26 @@ -1166,7 +1166,7 @@ struct xen_sysctl { struct xen_sysctl_scheduler_op scheduler_op; struct xen_sysctl_gcov_op gcov_op; struct xen_sysctl_psr_cmt_op psr_cmt_op; - struct xen_sysctl_psr_cat_op psr_cat_op; + struct xen_sysctl_psr_alloc psr_alloc; struct xen_sysctl_tmem_op tmem_op; struct xen_sysctl_cpu_levelling_caps cpu_levelling_caps; struct xen_sysctl_cpu_featureset cpu_featureset; diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 56dc5b0..e5387c6 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -743,8 +743,8 @@ static int flask_domctl(struct domain *d, int cmd) case XEN_DOMCTL_psr_cmt_op: return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__PSR_CMT_OP); - case XEN_DOMCTL_psr_cat_op: - return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__PSR_CAT_OP); + case XEN_DOMCTL_psr_alloc: + return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__PSR_ALLOC); case XEN_DOMCTL_soft_reset: return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__SOFT_RESET); @@ -807,9 +807,9 @@ static int flask_sysctl(int cmd) case XEN_SYSCTL_psr_cmt_op: return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN2, XEN2__PSR_CMT_OP, NULL); - case XEN_SYSCTL_psr_cat_op: + case XEN_SYSCTL_psr_alloc: return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN2, - XEN2__PSR_CAT_OP, NULL); + XEN2__PSR_ALLOC, NULL); case XEN_SYSCTL_tmem_op: return domain_has_xen(current->domain, XEN__TMEM_CONTROL); diff --git a/xen/xsm/flask/policy/access_vectors b/xen/xsm/flask/policy/access_vectors index da9f3df..df5f372 100644 --- a/xen/xsm/flask/policy/access_vectors +++ b/xen/xsm/flask/policy/access_vectors @@ -85,8 +85,8 @@ class xen2 resource_op # XEN_SYSCTL_psr_cmt_op psr_cmt_op -# XEN_SYSCTL_psr_cat_op - psr_cat_op +# XEN_SYSCTL_psr_alloc + psr_alloc # XENPF_get_symbol get_symbol # PMU control @@ -246,8 +246,8 @@ class domain2 mem_paging # XENMEM_sharing_op mem_sharing -# XEN_DOMCTL_psr_cat_op - psr_cat_op +# XEN_DOMCTL_psr_alloc + psr_alloc } # Similar to class domain, but primarily contains domctls related to HVM domains