From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH RFC 13/31] tools/libxc: Wire a featureset through to cpuid policy logic Date: Tue, 5 Jan 2016 16:20:37 +0000 Message-ID: <568BED55.3050402@citrix.com> References: <1450301073-28191-1-git-send-email-andrew.cooper3@citrix.com> <1450301073-28191-14-git-send-email-andrew.cooper3@citrix.com> <1452008549.13361.332.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1452008549.13361.332.camel@citrix.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: Ian Campbell , Xen-devel Cc: Wei Liu , Ian Jackson List-Id: xen-devel@lists.xenproject.org On 05/01/16 15:42, Ian Campbell wrote: > On Wed, 2015-12-16 at 21:24 +0000, Andrew Cooper wrote: >> Later changes will cause the cpuid generation logic to seed their >> information >> from a featureset. This patch adds the infrastructure to specify a >> featureset, and will obtain the appropriate default from Xen if omitted. >> >> Signed-off-by: Andrew Cooper >> --- >> CC: Ian Campbell >> CC: Ian Jackson >> CC: Wei Liu >> --- >> tools/libxc/include/xenctrl.h | 3 ++ >> tools/libxc/xc_cpuid_x86.c | 90 >> ++++++++++++++++++++++++++++++++++++++----- >> 2 files changed, 84 insertions(+), 9 deletions(-) >> >> diff --git a/tools/libxc/include/xenctrl.h >> b/tools/libxc/include/xenctrl.h >> index 27e1f45..b44aec7 100644 >> --- a/tools/libxc/include/xenctrl.h >> +++ b/tools/libxc/include/xenctrl.h >> @@ -2211,6 +2211,9 @@ int xc_cpuid_set(xc_interface *xch, >> char **config_transformed); >> int xc_cpuid_apply_policy(xc_interface *xch, >> domid_t domid); >> +int xc_cpuid_apply_policy_with_featureset(xc_interface *xch, domid_t domid, >> + uint32_t *featureset, >> + unsigned int nr_features); > We should aim to eventually only have one apply policy interface here not > two, unless there is some good reason why xc_cpuid_apply_policy() should > remain? > > AIUI passing featureset==NULL is going to be semantically identical to the > old interface, so I think we should just go with adding the new parameters > to the existing function. Will do. > >> @@ -103,6 +109,32 @@ static int get_cpuid_domain_info(xc_interface *xch, domid_t domid, >> info->hvm = di.hvm; >> info->pvh = di.pvh; >> >> + /* Get featureset information. */ >> + rc = xc_get_featureset(xch, XEN_SYSCTL_featureset_host, >> + &host_nr_features, NULL); >> + if ( rc ) >> + return rc; >> + >> + if ( host_nr_features < XEN_FEATURESET_7c0 ) >> + return -EINVAL; > Could we assert this? I mean if Xen and libxc don't agree on this then > something went pretty wrong during the dev window. Will do. > >> + >> + info->featureset = calloc(host_nr_features, sizeof(*info->featureset)); >> + if ( !info->featureset ) >> + return -ENOMEM; >> + >> + info->nr_features = host_nr_features; >> + >> + if ( featureset ) >> + { >> + memcpy(info->featureset, featureset, >> + min(host_nr_features, nr_features) * sizeof(*info->featureset)); >> + >> + /* Check for trucated set bits. */ > "truncated" Will fix. ~Andrew