[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 07/13] libs/guest: obtain a compatible cpu policy from two input ones
- To: Roger Pau Monne <roger.pau@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Tue, 4 May 2021 17:50:36 +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=ARxJWajNZ7W1OZf1kb8wuakHh0okaJWDH+NHh7IFqi8=; b=OkPrilEWpsG3Ime5u9A0Z3x05XUru3G2Kt8WLuIRpzF/0qM+R6tTV6ggYvknwRWXlO7shMvt/r1Qn6CLS7cPI6koufOHARZsoax2BittU83RRvXZgUgO/AkJ7ByVNa0brybEa+/rD7VpDXh9L0PtD+QBqhWq5K7c232vz4MekhDGT6b/axHg0jQ3onTmIwcZYcRXYs8VyYeh/eIrauxgflbAoksgA8VT++L0SXosOuU0cb7V78aF3H4syw2OBax+sQoc7yv35t6Ij1TNJViWrm5aYCskhiHNsCGxs3NrdT493xAWXGvQd9JMVhjd0zAYxuf4Crxskz3pCRUPan/DLg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iyDygCyxKE/PYFoRE5IgDOmXNJvLwIkvLB0Ey/OcvCh116VmDEJvxAMuy9DiCsni0efHyCrQBYKmmlY2CHs07N+duJ2P2s7VtNY1FwjRsweTpOv/Q7yYCA2xoaSYtolTJO2jAT4DupaBd7Uxr27yBqaFMZRM2UuVP4ic7ObI3CxCsTE4+igXf6IkVIuckp5ld8E0dHaOnx+AzJDan6h0b7BUTsozwx5BtQ1Misdw1R/JzESq6trruQvN+s7IgVNlL4KiGfaMLupgomcbyneXXJlizbK90qC+nw0nvVNOrcUoHYOzq5is5qJaY3lYz0s3GU0wb6D+jygOcO7rMps0pA==
- Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
- Delivery-date: Tue, 04 May 2021 16:50:59 +0000
- Ironport-hdrordr: A9a23:oDAu46H0UVEzBENPpLqFcpTXdLJzesId70hD6mlYcjYQWtCEls yogfQQ3QL1jjFUY307hdWcIsC7L0/03aVepa0cJ62rUgWjgmunK4l+8ZDvqgeOJwTXzcQY76 tpdsFFZOHYJ158kMr8/U2EA88tqeP3v5yAqMX/6zNWTQ9sY7x99AsRMGemO2B/WQUuP+tBKL Oy/cxCzgDQG0g/TsP+PXUdWviGmtujruOdXTcjJzoKrDaDlimp7rmSKWnX4j47XylUybkvtU jp+jaJnpmLiP2wxh/C22K71f0/87GNqqohOOW2hscYMTnqgAqzDb4RIIGqhzwpvPqprG8jjd ikmWZnA+1I93jTcmupyCGdvzXI7Tc053fujX+ejHfzyPaJIg4SNstbiYpVNibe8kor1esMt5 5j4mTxjeszMTrw2Azg+t6NbB1xj0yyu3Znq/ILlmdSS5F2Us4skaUvuGduVLsQFiPz744qVM N0CtvH2fpQeVSGK1jEo2hG2rWXLzUONybDZnJHlt2e0jBQknw85VAf3tYjknAJ8494Y4VY5t 7DLr9jmNh1P48rRJM4IN1Ebdq8C2TLTx6JGnmVO07bGKYOPG+IjJLr/rMv5qWPdIYTxJU/3L TNOWko9lIaSgbLM4mjzZdL+hfCTCGWRjL20PxT4JB/p/nyX7zuPSqfSE0/kseprvkFa/erHs qbCdZzObvOPGHuEYFG00nVQJ9JM0QTV8UTp5I6Vju104b2A7yvktaeXOfYJbLrHzphcHj4GG E/UD/6I9gF6FuqVH/+iB3YQGjsZ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uAf/P4UVfBuZjsK ynUkcmJW5cCm/jRKH8QLbe+2ZBTMaclSCUGDX+C16rfkYzVS4uUUABzwOjOSJa0Rc+Xf1ie20U lLU=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 30/04/2021 16:52, Roger Pau Monne wrote:
> Introduce a helper to obtain a compatible cpu policy based on two
> input cpu policies. Currently this is done by and'ing all CPUID
> feature leaves and MSR entries, except for MSR_ARCH_CAPABILITIES which
> has the RSBA bit or'ed.
>
> The _AC macro is pulled from libxl_internal.h into xen-tools/libs.h
> since it's required in order to use the msr-index.h header.
>
> Note there's no need to place this helper in libx86, since the
> calculation of a compatible policy shouldn't be done from the
> hypervisor.
>
> No callers of the interface introduced.
>
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
> Changes since v2:
> - Add some comments.
> - Remove stray double semicolon.
> - AND all 0x7 subleaves (except 0.EAX).
> - Explicitly handle MSR indexes in a switch statement.
> - Error out when an unhandled MSR is found.
> - Add handling of leaf 0x80000021.
>
> Changes since v1:
> - Only AND the feature parts of cpuid.
> - Use a binary search to find the matching leaves and msr entries.
> - Remove default case from MSR level function.
> ---
> tools/include/xen-tools/libs.h | 5 ++
> tools/include/xenctrl.h | 4 +
> tools/libs/guest/xg_cpuid_x86.c | 137 ++++++++++++++++++++++++++++++
> tools/libs/light/libxl_internal.h | 2 -
This *needs* to be in libx86. I don't particularly mind if you start
with it behind #ifdef __XEN__ (I'm still sure we'll need it in the
hypervisor), but this, more than just about anything else, needs to be
covered by the unit tests.
Next, you need to follow the same structure as Xen's cpuid.c for
deriving policies. You can't just loop through the two serialised forms
like this.
To start with, you want to calculate the min of a/b->max_leaf, then loop
over that pulling information sideways from a/b.
For MSRs, all but MSR_INTEL_PLATFORM_INFO are CPUID qualified, so need
to look like:
if ( out.cpuid.feat.arch_caps )
out.msr.arch_caps.raw =
((a.msr.arch_caps.raw ^ INV_MASK) &
(b.msr.arch_caps.raw ^ INV_MASK)) ^ INV_MASK;
Where INV_MASK is the mask of arch caps bits which want inverted
polarity. (Name subject to change - perhap ARCH_CAPS_POLARITY_MASK ?)
I'm sure I had some work starting this somewhere. I'll see if I can
locate it.
~Andrew
|