[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: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 4 May 2021 12:56:11 +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-SenderADCheck; bh=fcY4ysDXt9Hr533qwosADRT5FVEQ/4539qETJLeVOwQ=; b=lZ63qDqWxmt6madIZqPDTi83o5h4iyGi7JyRFbGbFGcShM8LL5ChVFgoEbarFG8b0o2vMCHxlp0sDGqXZ8tDMin0WsE5gVIbqWS/2TlI0SofvDQuiuEQOcg/dKbPn0vc4mosrxBfur4FbpCR1N9itXll9BXutUOUvbMNf9R01fi310AOws+Wq1SHKG3IJgrRgMiJ9WD1nha/lbN24zl2ZBhU5CGPLzrNnSwmLXbDIDK5cmhNvyXz05p1J+hxbTHFU1fiv+vdoCtM7RjrLWm9RjSjWIO7Q8Qenk7n0JPK1s2WSprg8+TkXdZ3taPISv2xBnorHtkl/uQU4TiItUHMLA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AwxPL+Czi1+3uath0xc6RLXiIfurmQtRaLY7X+IGZwOpLVuwjnq5JUorY7LeWQSiVh7nyvo9cC+gd67PTfNsTEASK2yU6rdvxHI92H9IwwRihHfR5sCcrLa0R7JFC7sX85aHUBYCOko8nf3XjFMCMTPvbJ1G0tG4UuXptjpg4FtZWEvCZv2jBqviP+vCZbeB4V9QplCJylQgeeRsbmi8YLGUqdsRgLv/fCaaNANjBvaGapjvzRvjqklQOTJwURVGx9tzBNSeNKbwGJK7QSo5/pDk19RPTDY10Qi5UbYqpe76mQlL7B3XyuNde44o7U9CvHM9joDnDYlvV3PYHNzNqg==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 04 May 2021 10:56:23 +0000
  • Ironport-hdrordr: A9a23:u7qwCa36i6LhUsnx2gnTvgqjBQB3eYIsi2QD101hICF9Wvez0+ izgfUW0gL1gj4NWHcm3euNIrWEXGm0z/BIyKErF/OHUBP9sGWlaLtj44zr3iH6F0TFmdJ1/Z xLN5JzANiYNzRHpO7n/Qi1FMshytGb8KauwdzT1WtpUBsCUcFdxi1SYzzrdHFebg9AGJY/Cd 6w5tBfoSChZHQQaa2AdwQ4dsLEoMDGk4+jXAUPAAQp5BLLoTSj7rP7FBbw5GZjbxpkx7A+/W /Z1zHo/6nLiYDA9jbw9U/2q65Xltzo18dZCKW36/Q9Bz3whm+TFeFccpKYujRdmpDK1H8Ll5 32rw4kL4BP7RrqDx6IiD/M/yWl7zo08X/lzjaj8AjeiOj0XigzBcYEpa8xSGqg12MasNtx0L 1G0gui3vI9Z36w/1Welq31fipnmUaurX0pnfR7tQ0lbaIkZKJMtotaxUtJEf47bVLHwbo6G+ pjBty03ocuTXqmaRnizw5S6e3pdHEyEhCae1MFq8yY3hNH9UoJvncw9YgxmGwN+4k6TIQBz+ PYMr5wnLULdcMOa7lhbd1xDvefOyjoe1bhIWiSKVPoGOUuPG/MkYf+5PEQ6PuxcJIF4ZMukP 36IR1lnF93X3irJdyF3ZVN/ByIan66Ry7RxsZX4IU8kqHgRZLwWBfzC2wGoo+FmbEyE8fbU/ G8NNZ9GPn4N1bjHo5PwknXR4RSE38DS8cY0+xLG26mk4buEMnHp+bbePH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nR79OVCXIr04mAsyIQFH2X+CnD4sS8WCC hB/IU0YX1n4gNfXWt6pAmiA1xm8U9AcTRAKLdFI6FIT/xL55BYuGtkSFGXmw5Licxg0fxZfXnc 21k8iryRH6Q8LZ5EYY4nvarTz7uL3zgyoKR/oFb2bnkP/NLCuYY+A/74soR1p+Yt8ezoMkfCTq c20=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, May 03, 2021 at 12:41:29PM +0200, Jan Beulich wrote:
> On 30.04.2021 17:52, Roger Pau Monne wrote:
> > Introduce an interface that returns a specific MSR entry from a cpu
> > policy in xen_msr_entry_t format. Provide a helper to perform a binary
> > search against an array of MSR entries.
> > 
> > This is useful to callers can peek data from the opaque
> > xc_cpu_policy_t type.
> > 
> > No caller of the interface introduced on this patch.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> > ---
> > Changes since v1:
> >  - Introduce a helper to perform a binary search of the MSR entries
> >    array.
> > ---
> >  tools/include/xenctrl.h         |  2 ++
> >  tools/libs/guest/xg_cpuid_x86.c | 42 +++++++++++++++++++++++++++++++++
> >  2 files changed, 44 insertions(+)
> > 
> > diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
> > index cbca7209e34..605c632cf30 100644
> > --- a/tools/include/xenctrl.h
> > +++ b/tools/include/xenctrl.h
> > @@ -2611,6 +2611,8 @@ int xc_cpu_policy_serialise(xc_interface *xch, const 
> > xc_cpu_policy_t policy,
> >  int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t 
> > policy,
> >                              uint32_t leaf, uint32_t subleaf,
> >                              xen_cpuid_leaf_t *out);
> > +int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t policy,
> > +                          uint32_t msr, xen_msr_entry_t *out);
> >  
> >  int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
> >  int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
> > diff --git a/tools/libs/guest/xg_cpuid_x86.c 
> > b/tools/libs/guest/xg_cpuid_x86.c
> > index de27826f415..9e83daca0e6 100644
> > --- 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?

Thanks, Roger.



 


Rackspace

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