[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 02/13] libs/guest: allow fetching a specific CPUID leaf from a cpu policy
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Tue, 4 May 2021 15:47:53 +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=oZrKNOq23P+B+xPjn0c6ttemAMfOK/ov2+s6p8L+gKo=; b=P0/8FfTmwV8rezlNueayLL3oqFMKqiHWi4v42jXai58YzPlTyiWccp243Afcfo/5XT8Ohl7xbTwxDUmNy+mSiYnBHdBKMoj6qtE1/ySuTPjBOrvl1tfY+uFv+2mkh0Ht3lLCnvffmCB8SHdIUF952bZGBeyOtbo9sH/mJkwg4AkHcok/X9vSqr0ynM+44mAmCpeQLrcxeN9tYNoHL8P7kCIrAyBu1QKt0uub/rr6oST9y/ikxW8y5TZ8UodRId9rprhBt9QEKcbm7gzZBQ5mAMMuvsjuO/QLH28zjzAeKEH9aYeMyACBiG2fA/JNav2bIECM/ISxoMAZOyhZApg3Fw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XVXNYOTyK3RsciURKI+HPtL9soB5IqF04opAhHjqtgQQUrB8ZtX8PhdRjLPQCyE2gPTAFzlzkWO2D1/+VjhNqIsps9v+NQN1RcPIl1ZcdIh5kClU49OD49G3cTtCKnvMuJe+2H+4F07cakakW5fr9b4sjfX/sdcI2V3Rq2WDtjVteaCyXoPinbRPx9EEcASJMN50ft1yIF2yeKjAUSH/GxQqMVpG1EFQP+o7TIp4VYxCwErdBLbBlZbNtCRyLY2yfEr/ebIZX9RZDrRXI+kC48I76f3rV8369xB4oGhjMh9eb97KDj/NhoHInuZYAQFJLtykn+L6SvfxGhCuJvP34g==
- Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Tue, 04 May 2021 13:48:15 +0000
- Ironport-hdrordr: A9a23:9ySOCqhDMcOkGy1IO/ccKe235XBQX2pw3DAbvn1ZSRFFG/Gwv/ uF2NwGyB75jysQUnk8mdaGfJKNW2/Y6IQd2+YsFJ+Ydk3DtHGzJI9vqbHjzTrpBjHk+odmuZ tIW5NVTOf9BV0St6vHySGlDtctx8SG+qi0heHYi0xgVx1udrsI1WZEIyywe3cGIzVuL5w/CZ aa+45rpyC4f24Wc8S8ARA+LpL+jvfMk4/rZgNDOgUu7xOAgSjtxLnxFRWZ2Rl2aUIz/Z4J92 /Znwvlopiyqv3T8G6m60b/zbRz3OHgxNxKGdCWhqEuRAnEpw60aO1aKt+/lR8vpuXH0idOrP DtpFMaM913+zfteAiO0GfQ8i3B9Bpr1HP401+fhhLY0LzEbRY3EdBIi44cUjax0TtYgPhG3K hG332UuvNsZHuq9kSNhKm7azhQmkW5unYkm+II5kYvKbc2U7NNsZcZuHpcDZZoJlOK1KkcDO JsAMvAjcwmF2+yUnaxhBgK/PWcGl43HhuAX3EYvN2U3zV8jBlCvjUl7f1asXEa+J0nTZ5Yo8 zCL6RzjblLCvQbdKRnGY46MIeKI12IZSiJHHOZIFzhGq1CE3XRq6Tv6LFwwO2xYpQHwLY7hZ ypaiIWiUcCP2bVTeGe1pxC9R7ABE+nWy72981Y759l/pXhWbvCK0S4ORATuvrlh89aLtzQWv 61Np4TKeTkN3HSFYFA2BC7c4VOKEMZTNYetr8AKhOzi/OODrevmv3Qcf7VKraoOy0jQHnDDn wKWyW2C95H6mytR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PEcaJdiO2y8QQFZ YTGqKPcgtFR/d0rFP2W+E4Yle1SFn+ouR9TbDQwKRzbfdot76AylA760eRjj3Qp9cq5YD5qj7c YdAxnoyhEn5QczxKf5tDK2VOOrNGHYxQrwpsi/uJVXnB09pfEr+IzOrTHnrmrjAlRA2Mx0M+c6 rq8=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, May 04, 2021 at 12:59:43PM +0100, Andrew Cooper wrote:
> On 30/04/2021 16:52, Roger Pau Monne wrote:
> > @@ -822,3 +825,28 @@ int xc_cpu_policy_serialise(xc_interface *xch, const
> > xc_cpu_policy_t p,
> > errno = 0;
> > return 0;
> > }
> > +
> > +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)
> > +{
> > + unsigned int nr_leaves = ARRAY_SIZE(policy->leaves);
> > + xen_cpuid_leaf_t *tmp;
> > + int rc;
> > +
> > + rc = xc_cpu_policy_serialise(xch, policy, policy->leaves, &nr_leaves,
> > + NULL, 0);
> > + if ( rc )
> > + return rc;
>
> Sorry for not spotting this last time.
>
> You don't need to serialise. You can look up leaf/subleaf in O(1) time
> from cpuid_policy, which was a design goal of the structure originally.
>
> It is probably best to adapt most of the first switch statement in
> guest_cpuid() to be a libx86 function. The asserts aren't massively
> interesting to keep, and instead of messing around with nospec, just
> have the function return a pointer into the cpuid_policy (or NULL), and
> have a single block_speculation() in Xen.
libx86 already has array_access_nospec, so I think it's fine to just
leave the code as-is instead of adding a block_speculation in Xen and
dropping the array_access_nospec accessors?
> We'll also want a unit test
> to go with this new function to check that out-of-range leaves don't
> result in out-of-bounds reads.
Sure.
Also, whats your opinion regarding xc_cpu_policy_get_msr, should I
also split part of guest_rdmsr and place it in libx86 in order to
fetch the MSRs present in msr_policy?
Thanks, Roger.
|