[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 6/6] libxl: add support for parsing MSR features


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 17 Jul 2023 16:46:25 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9XE6hngjyvDPrBecSEUxnjPDwhFaAoQ10IEUjLKS+y8=; b=oebvgRgMI9wWQEKuhVvIEFJOFE4fUq8w9stlwr4zHuupq/AXU3sP2sArG1tgVJxF5XhyB7ERQLs91gGBG8I/npgAshf0A/BhGVd0jAXLX9hGc5BZAXwlHaVxoln7XX7V2hOGhmv6hrQ2PU+RrzU3GR0eUKl05aEjBbB11kZ7YpJ3vu1G7/oNNnc82O80tgmjwyXtqNRPqiXpUJu7McI1x3qyUCvbaW2FhOhZFrwW3kj3RSvFFscq6oVWFY75oS+qzkQbvwnsOOr15AXEbSgBhNnb8ywNLOdFkXiwSx3Z0AtiyKauGypFlBdvA39FTegIsE8oFuk5S01Z1GRrplYxng==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CTrML7wCtpbGGMtThBoC9kAN7An2olRq7dDXqmwBoRVgnVuxyhhwA4mRtIT+zfxWeaGLI+JP0LKQoRGdUvEypi/IwzA0rL8FQm1a2smgWPBi/ncOb5yObDzBBdk/h6I+uKbjENKyzWE/VsKLVtD3FxWKmTc5gl7fHrLw+Kp6pRY4MNB6SP5n0OiaTgxtHMZ19ooEwl3YWgT5eB8HYDsMARIZi8jQIEifhbwOtbOTUauZbUxrJm26ECSeOC/RK+AJtujAcKGLq9DMM6GADa4IwGKXue6mI9yKrmW+coZAjAqUduJhRqBolalwtUA8+mILUtijfKzVCvJGwxTGQdls4w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Mon, 17 Jul 2023 14:46:47 +0000
  • Ironport-data: A9a23:CUiE4agBkJQ3ivKnX8Hm7TWuX161RBEKZh0ujC45NGQN5FlHY01je htvUGmHOaqIZ2Oge95yaYi0/BxXu8LWn9U1TgporiA2Rngb9cadCdqndUqhZCn6wu8v7q5Ex 55HNoSfdpBcolv0/ErF3m3J9CEkvU2wbuOgTrWCYmYpHlUMpB4J0XpLg/Q+jpNjne+3CgaMv cKai8DEMRqu1iUc3lg8sspvkzsx+qyr0N8klgZmP6sT4waBzyB94K83fsldEVOpGuG4IcbiL wrz5OnR1n/U+R4rFuSknt7TGqHdauePVeQmoiM+t5mK2nCulARrukoIHKN0hXNsoyeIh7hMJ OBl7vRcf+uL0prkw4zxWzEAe8130DYvFLXveRBTuuTLp6HKnueFL1yDwyjaMKVBktubD12i+ tQAEzkGcy2gjti1/4++VulQ3dQaApHSadZ3VnFIlVk1DN4AaLWaGuDmwIEd2z09wMdTAfzZe swVLyJ1awjNaAFOPVFRD48imOCvhT/0dDgwRFC9/PJrpTSMilEuluGybrI5efTTLSlRtlyfq W/cuXzwHzkRNcCFyCrD+XWp7gPKtXqiBtlORObnq5aGhnW1z2AdJiQRCmCyvKjhq2+fR/AFI nQtr39GQa8asRbDosPGdw21pjuIswARX/JUEvYm80edx6zM+QGbC2MYCDlbZ7QOq8seVTEsk FiTkLvBBzN1t6aOYWmA7brSpjS3URX5NkcHbC4ACAcAvd/qpdhqigqVF4k9VqmoktfyBDf8h SiQqzQzjKkSishN0Lin+VfAgHSnoZ2hohMJ2zg7l1mNtmtRDLNJraTxgbQHxZ6s9Lqkc2Q=
  • Ironport-hdrordr: A9a23:xMXQca+CKT9BmEQY6lduk+AoI+orL9Y04lQ7vn2ZKSY5TiX4rb HIoB1/73XJYVkqN03I9ervBEDEewK+yXcX2/h0AV7BZmnbUQKTRekP0WKh+UyDJ8SXzIVgPM xbAs1D4bPLbGSTjazBkXWF+9RL+qj5zEh/792usUuETmtRGtBdBx8SMHf8LqXvLjM2f6bQEv Cnl7N6jgvlQ1s7ROKhCEIIWuDSzue76a4PMXY9dmYaABDlt0LS1ILH
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Jul 13, 2023 at 11:39:53AM +0100, Anthony PERARD wrote:
> On Tue, Jul 11, 2023 at 11:22:30AM +0200, Roger Pau Monne wrote:
> > diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c
> > index b1c4f8f2f45b..86a08f29a19c 100644
> > --- a/tools/libs/light/libxl_cpuid.c
> > +++ b/tools/libs/light/libxl_cpuid.c
> > @@ -158,6 +158,57 @@ static int cpuid_add(libxl_cpuid_policy_list *policy,
> >      return 0;
> >  }
> >  
> > +static struct xc_msr *msr_find_match(libxl_cpuid_policy_list *pl, uint32_t 
> > index)
> > +{
> > +    unsigned int i = 0;
> > +    libxl_cpuid_policy_list policy = *pl;
> > +
> > +    if (policy == NULL)
> > +        policy = *pl = calloc(1, sizeof(*policy));
> > +
> > +    if (policy->msr != NULL)
> > +        for (i = 0; policy->msr[i].index != XC_MSR_INPUT_UNUSED; i++)
> 
> Could you add { } for this two blocks? One line after a if() without { }
> is ok, but not more.

Sure.

> > +            if (policy->msr[i].index == index)
> > +                return &policy->msr[i];
> > +
> > +    policy->msr = realloc(policy->msr, sizeof(struct xc_msr) * (i + 2));
> > +    policy->msr[i].index = index;
> > +    memset(policy->msr[i].policy, 'x', ARRAY_SIZE(policy->msr[0].policy) - 
> > 1);
> 
> Is this "array_size() - 1" correct? The -1 need to go, right?
> 
> > +    policy->msr[i].policy[ARRAY_SIZE(policy->msr[0].policy) - 1] = '\0';
> 
> Is it for convenience? Maybe for easier debugging (printf)? Also, I
> guess having a NUL at the end mean the -1 on the previous statement kind
> of useful.

Yes, it's also to match the format of the policy string used by
xc_xend_cpuid, which also has a terminating zero.

Are you OK with this?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.