[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 Monne <roger.pau@xxxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Thu, 13 Jul 2023 11:39:53 +0100
  • Authentication-results: esa1.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: Thu, 13 Jul 2023 10:40:16 +0000
  • Ironport-data: A9a23:ijHIqau9SlpzNK9sa3uFYWCcHOfnVENeMUV32f8akzHdYApBsoF/q tZmKWyGPf6OZjf0coxyaIu18BkP75fQndU3Tws+ryBhQXsU+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVKiffHg3HVQ+IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4rKq4Vv0gnRkPaoQ5ACHzCFMZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwMzMkLRuzvdmKg5GADfBstOZ6Hu23I9ZK0p1g5Wmx4fcORJnCR+PB5MNC3Sd2jcdLdRrcT 5NHM3w1Nk2GOkARfA5NU/rSn8/x7pX7WzRetFKSo7tx+2XJxRZ9+LPsLMDUapqBQsA9ckOw/ zuYoj2iXk5HXDCZ4SKL8mKBm8bdpCLYZa4rMZ2FquZ4kULGkwT/DzVJDADm8JFVkHWWS99Zb kAZ5Ccqhawz71CwCMnwWQWip3yJtQJaXMBfe8Ul7Cmdx6yS5ByWbkAGQSRGc8cOr9ItSHoh0 Vrht9rxCCZmqrG9VXOX/bDSpjS3URX5NkdbO3VCF1FcpYC+/sdq1Emnostf/LCdld7cWjrA+ Qu27wsFwKwTv+xS5YHn4gWS696znaQlXjLZ9y2OADL0t1MiO9L8D2C7wQOFtKgdde51WnHE5 SFZwJbGsYjiGLnXzESwrPMx8KZFDhpvGBnVmhZREpYo7FxBEFbzLNkLsFmSyKqEW/vomAMFg 2eJ42u9HLcJYBOXgVZfOupd8fgCw6n6DsjCXfvJdNdIaZUZXFbZrHA3NRDAgDi1zhVEfUQD1 XCzKJbEMJrnIf4/kGreqxk1jNfHORzSNUuMHMumnnxLIJKVZWKPSKdtDbd9RrlR0U9wmy2Mq 4w3H5LTm31ivBjWPnG/HXg7cQpbchDWxPne96RqSwJ0ClE4QT5xUqOJnOtJlk4Mt/09q9okN 0qVAidwoGcTT1WeQelWQhiPsI/SYKs=
  • Ironport-hdrordr: A9a23:bVWT3qhTu7qVVmGWadSaUjM4RXBQXggji2hC6mlwRA09TyXPrb HToB0+726OtN93YgBZpTngAtj4fZq4z/RICOYqTNSftWXd2FdAabsSiLcKoAeQfREWlNQtt5 uIKJIOcuEYZGIS5a3HCUuDYrIdKbK8gceVbInlrktFfEVDd7xn9AthDxbzKDwKeOCEP/YE/V ini/avawDORZ3fVKqGOkU=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

> +            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.

> +    policy->msr[i + 1].index = XC_MSR_INPUT_UNUSED;
> +
> +    return &policy->msr[i];
> +}

Thanks,

-- 
Anthony PERARD



 


Rackspace

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