[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: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Tue, 18 Jul 2023 12:26:05 +0100
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Tue, 18 Jul 2023 11:26:36 +0000
  • Ironport-data: A9a23:rVhEVaBrqwYyBBVW/zrjw5YqxClBgxIJ4kV8jS/XYbTApDkl1T1Vx msaWziHbqqMY2b1ed5+boS09UxUuZOEmINiQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsspvlDs15K6p4GxB7gRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw/b18J3NJ9 uMiJG4mLQusne60wLeJc7w57igjBJGD0II3v3hhyXfSDOo8QICFSKLPjTNa9G5u3IYUR6+YP pdHL2M1N3wsYDUWUrsTIJs4gOevgGi5azBCoUiZjaE2/3LS3Ep6172F3N/9I4XXH5UIxxvHz o7A103YCRIFC8yE8CSu2yicmf/Uvg6lAo1HQdVU8dY12QbOlwT/EiY+RVa95PW0lEO6c9ZeM FAPvDojq7Ao806mRcW7WAe3yFabujYMVtwWFPc1gCmPxbDT+B2xHXUfQ3hKb9lOnMYuSCYjz FOhg9LjDjspu7qQIU9x7Z/N82n0Y3JMazZfO2ldF1BtD8TfTJ8biUnEaMRkE7GPgoPeWirf2 TyIrC0MvuBG5SIU7JlX7Wwrkhr1+MiYEFBrul2JNo62xlgnPdD4PuRE/XCetK8dd9jBEzFtq VBew6CjAPYy4YZhfcBnaMEEB/mX6vmMK1UwanY/TsB6p1xBF5NOFL28AQ2Sx28zaK7ogRezP CfuVfp5vfe/xkeCY65teJ6WAM8316XmHtmNfqmKPosQO8guLV7YpHgGiausM4bFyhBEfUYXY MrzTCpRJSxCVfQPIMSeHI/xLoPHNghhnDiOFPgXPjys0KaEZW79dFv2GALmUwzN14vd+F+92 48GZ6O3J+B3DLWWjt//rdRCcjjn7BETWfjLliCgXrTbclM6RjF8W6G5LHFIU9UNopm5X9zgp hmVMnK0AnKm7ZEbAW1mskxeVY4=
  • Ironport-hdrordr: A9a23:ANeCPKs1lr6m2DAgkcMyampT7skDstV00zEX/kB9WHVpm6yj+v xG/c5rsCMc7Qx6ZJhOo7+90cW7L080lqQFg7X5X43DYOCOggLBQL2KhbGI/9SKIVycygcy78 Zdm6gVMqyLMbB55/yKnTVRxbwbsaW6GKPDv5ag8590JzsaD52Jd21Ce36m+ksdfnggObMJUK Cyy+BgvDSadXEefq2AdwI4t7iqnaysqHr+CyR2fiIa1A==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Jul 17, 2023 at 04:46:25PM +0200, Roger Pau Monné wrote:
> 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?

Yes.

With the other style change done:
Acked-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>

Thanks,

-- 
Anthony PERARD



 


Rackspace

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