From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH v2 23/30] xen+tools: Export maximum host and guest cpu featuresets via SYSCTL Date: Wed, 17 Feb 2016 01:30:38 -0700 Message-ID: <56C43DBE02000078000D2F28@prv-mh.provo.novell.com> References: <1454679743-18133-1-git-send-email-andrew.cooper3@citrix.com> <1454679743-18133-24-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1454679743-18133-24-git-send-email-andrew.cooper3@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Wei Liu , Ian Campbell , Tim Deegan , Rob Hoes , Xen-devel , David Scott List-Id: xen-devel@lists.xenproject.org >>> On 05.02.16 at 14:42, wrote: > @@ -190,6 +191,71 @@ long arch_do_sysctl( > } > break; > > + case XEN_SYSCTL_get_cpu_featureset: > + { > + const uint32_t *featureset; > + unsigned int nr; > + > + /* Request for maximum number of features? */ > + if ( guest_handle_is_null(sysctl->u.cpu_featureset.features) ) > + { > + sysctl->u.cpu_featureset.nr_features = FSCAPINTS; > + if ( __copy_field_to_guest(u_sysctl, sysctl, > + u.cpu_featureset.nr_features) ) > + ret = -EFAULT; > + break; > + } > + > + /* Clip the number of entries. */ > + nr = sysctl->u.cpu_featureset.nr_features; > + if ( nr > FSCAPINTS ) > + nr = FSCAPINTS; min() (perhaps even allowing to obviate the comment)? > + switch ( sysctl->u.cpu_featureset.index ) > + { > + case XEN_SYSCTL_cpu_featureset_raw: > + featureset = raw_featureset; > + break; > + > + case XEN_SYSCTL_cpu_featureset_host: > + featureset = host_featureset; > + break; > + > + case XEN_SYSCTL_cpu_featureset_pv: > + featureset = pv_featureset; > + break; > + > + case XEN_SYSCTL_cpu_featureset_hvm: > + featureset = hvm_featureset; > + break; > + > + default: > + featureset = NULL; > + break; > + } > + > + /* Bad featureset index? */ > + if ( !ret && !featureset ) > + ret = -EINVAL; Nothing above altered "ret" from its zero value, so the check here is pointless. > --- a/xen/include/public/sysctl.h > +++ b/xen/include/public/sysctl.h > @@ -766,6 +766,29 @@ struct xen_sysctl_tmem_op { > typedef struct xen_sysctl_tmem_op xen_sysctl_tmem_op_t; > DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tmem_op_t); > > +/* > + * XEN_SYSCTL_get_cpu_featureset (x86 specific) > + * > + * Return information about the maximum sets of features which can be offered > + * to different types of guests. This is all strictly information as found in > + * `cpuid` feature leaves with no synthetic additions. > + */ The reference to guests in the comment conflicts with the raw and host types below. > +struct xen_sysctl_cpu_featureset { > +#define XEN_SYSCTL_cpu_featureset_raw 0 > +#define XEN_SYSCTL_cpu_featureset_host 1 > +#define XEN_SYSCTL_cpu_featureset_pv 2 > +#define XEN_SYSCTL_cpu_featureset_hvm 3 > + uint32_t index; /* IN: Which featureset to query? */ > + uint32_t nr_features; /* IN/OUT: Number of entries in/written to > + * 'features', or the maximum number of features if > + * the guest handle is NULL. NB. All featuresets > + * come from the same numberspace, so have the same > + * maximum length. */ > + XEN_GUEST_HANDLE_64(uint32) features; /* OUT: */ Stray colon. Jan