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

Re: [PATCH v3 03/13] libs/guest: allow fetching a specific MSR entry from a cpu policy


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 4 May 2021 18:11:25 +0100
  • 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-SenderADCheck; bh=EBVKAU/3atcB2PR5D0RKoqYfEHv+UESguO6ovrxI4s4=; b=AN9OayFG/21pHVg8A1Xme2oZ1JNjPLGA8MegDZ6RwXxpMKzSuDJTeFOkzjBE485bx2AsraI+U0pJVHSdrXYmVAWTlkakwYk8YxLXbY3Lsc+4Yz9Zhed0OX4+v9zujytxOUUvcJWQKDYydFQI7S56DJmomHBF3FXy3tMTy6hv9dcT8D3BvxtjsxnTo0MaX3UTCG4pkFuWmdTffvEUR4trOihJ+GiZTAaPUHQtufTlJRkMpOVT5/5iLBGhHi9c+1SnpPO9pOeIxbdmzobtIp1dJ11P78dKMtUCDtPjf2xFBf2MgnudBgJeLo8bNbctU7GQhIvWdMDJ3oTZd80NiTNdXQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O0GBlWioToy/2dBD5UTa6dwF4GgnB4ilpInxXzkMP2tBTqaz5GcHYR8T10gzSLX53GSSeELDg9I4lcdDE4gJ5Jx03fAAedCVnPZLHM4H5eu3XjwhlfGASBg98ZHy0vx89rPyOHEWJDL3aoaXDe0IIS1jP3X2dmtTOTuq5Ne70pW+r/nYzouGc49ByHabbYWthodfWLtUAKZM+rw/Y/Yefb1uvTnXvjRc36n4UceDBvDshpUkncxN8mgtLfIlfDQt5LHfjUNz2aSRZL2hV7kiEQfnXQNEln6vdyGY4cwscEC3qALmtjTmnV/d3U6Q0q8IDJR2fJkMJ7wVLLf3uF0xXA==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 04 May 2021 17:11:45 +0000
  • Ironport-hdrordr: A9a23:BoYpvaiwD7xcXBnYT9Q+eZL973BQX3Vw3DAbvn1ZSRFFG/Gwv/ uF2NwGyB75jysQUnk8mdaGfJKNW2/Y6IQd2+csFJ+Ydk3DtHGzJI9vqbHjzTrpBjHk+odmup tIW5NVTOf9BV0St6rHySGlDtctx8SG+qi0heHYi0xgVx1udrsI1WdEIyywe3cGIDVuL5w/CZ aa+45jrz2vZXwYYq2Adwc4dsLEoMDGk4+jXAUPAAQp5BLLoTSj7rP7FBbw5GZgbxpkx7A+/W /Z1zHo/6nLiYDG9jbw9U/2q65Xltzo18dZCKW36/Q9Bz3whm+TFf9ccpKYujRdmpDI1H8Ll5 32rw4kL4BP7RrqDxyIiD/M/yWl7zo08X/lzjaj8AneiOj0XigzBcYEpa8xSGqg12MasNtx0L 1G0gui3vI9Z36w/1Welqz1fipnmUaurX0pnfR7tQ05baIkZKJMtotaxUtJEf47bVHHwbo6G+ pjBty03ocuTXqmaRnizwxS6eC3Um92NhmLRVVqgL3u7xFm2Fp9z0ce2fUFmGYB+J8XW/B/lp T5G5Utu7dUQsAMa6VhQM8HXMusE2TIBSnBKWSIPD3cZe86EkOIj6SyzKQ+5emsdpBN5JwumK 7ZWFcdkWIpYUrhBeCHwZUjyGGNfEyNGRDWju1O7ZlwvbPxAJDxNzeYdVwom8y8590CH8zyQZ +ISdBrKs6mCVGrNZdC3gX4VZUXA2IZStcpttEyXE/Lit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G deCiAoJmqGG8nqrCm6MHaMVe067uU8amI8euVzulE4BU5VptbTqzBV9aDoAyUP932tPlAcZtlF jIpHPPM/i+D5qMcyTgVUapR9vGO+dMv+eD5dcnV/6VAo1WQaPTR/sEM1dPtgz1Y8sSZKBVncfs csQ/7xvkeC05eQhN6bRo75ndW2OcvTz/ClOkDUyjiyUs3ftW7waoNZ8Fwi9Oxp/j5L1Rt17T0V 01U=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 04/05/2021 12:58, Roger Pau Monné wrote:
> On Tue, May 04, 2021 at 01:40:11PM +0200, Jan Beulich wrote:
>> On 04.05.2021 12:56, Roger Pau Monné wrote:
>>> On Mon, May 03, 2021 at 12:41:29PM +0200, Jan Beulich wrote:
>>>> On 30.04.2021 17:52, Roger Pau Monne wrote:
>>>>> --- a/tools/libs/guest/xg_cpuid_x86.c
>>>>> +++ b/tools/libs/guest/xg_cpuid_x86.c
>>>>> @@ -850,3 +850,45 @@ int xc_cpu_policy_get_cpuid(xc_interface *xch, const 
>>>>> xc_cpu_policy_t policy,
>>>>>      *out = *tmp;
>>>>>      return 0;
>>>>>  }
>>>>> +
>>>>> +static int compare_entries(const void *l, const void *r)
>>>>> +{
>>>>> +    const xen_msr_entry_t *lhs = l;
>>>>> +    const xen_msr_entry_t *rhs = r;
>>>>> +
>>>>> +    if ( lhs->idx == rhs->idx )
>>>>> +        return 0;
>>>>> +    return lhs->idx < rhs->idx ? -1 : 1;
>>>>> +}
>>>>> +
>>>>> +static xen_msr_entry_t *find_entry(xen_msr_entry_t *entries,
>>>>> +                                   unsigned int nr_entries, unsigned int 
>>>>> index)
>>>>> +{
>>>>> +    const xen_msr_entry_t key = { index };
>>>>> +
>>>>> +    return bsearch(&key, entries, nr_entries, sizeof(*entries), 
>>>>> compare_entries);
>>>>> +}
>>>> Isn't "entries" / "entry" a little too generic a name here, considering
>>>> the CPUID equivalents use "leaves" / "leaf"? (Noticed really while looking
>>>> at patch 7.)
>>> Would you be fine with naming the function find_msr and leaving the
>>> rest of the parameters names as-is?
>> Yes. But recall I'm not the maintainer of this code anyway.

This file in particular has been entirely within the x86 remit for
multiple years now, as have the other cpuid bits in misc/ and libxl.

> You cared to provide feedback, and I'm happy to make the change.

find_msr() would be a better name.  As for entries and nr_entries,
suggestions welcome.  I couldn't think of anything better for the low
level helpers.

~Andrew




 


Rackspace

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