From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2 23/30] xen+tools: Export maximum host and guest cpu featuresets via SYSCTL Date: Wed, 17 Feb 2016 12:17:22 +0000 Message-ID: <56C464D2.80808@citrix.com> References: <1454679743-18133-1-git-send-email-andrew.cooper3@citrix.com> <1454679743-18133-24-git-send-email-andrew.cooper3@citrix.com> <56C43DBE02000078000D2F28@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <56C43DBE02000078000D2F28@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Wei Liu , Ian Campbell , Tim Deegan , Rob Hoes , Xen-devel , David Scott List-Id: xen-devel@lists.xenproject.org On 17/02/16 08:30, Jan Beulich wrote: >>>> 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)? They are different types, and you specifically objected to min_t() before. > >> + 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. So it is. > >> --- 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. I will reword. ~Andrew