[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: Roger Pau Monne <roger.pau@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Tue, 4 May 2021 12:59:43 +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=K4jRvz7DAu+uZjDw20zqbODBVRrh323FvRl2G5GXE3A=; b=XcyJMV95ucStiGxL1SrXY4DRSnc2TXZEFn5wqIkx2IfjdfcpFT7wFThPnonJkNCL9xT0ZsT5966KqEW8dKjt/JTiYQNM04GXKoP/Rx5rvNixyr+bU2eCYoDBY0eXDMCuv+6XyZtU0fbYOeLgqqqZqMkdGpJ9M4M06TdLqbiaLK05lq4HwggEIT1G3a9O2S0baiUigXM2rmSjOQ6BYX3NDvYmbJ58OLylQ09679HgvPYITOEyWEoue7DD9mLzZ78XVzjEZO/XrQelWk3SCry0U/lZfkjgqwrJFXIdDJMy7PqgyA0koT5Lx6GWZ84XFtUbBCPD0ck6It3IrVYK1dIsdg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eRcd8yJ1xHLhMSDQLeFk29ISCoJ+BzLpnERzO5MAQUQQofKutW+FijtG3xHEVfr0dhMwBMbnTvu6UEref6hhQUj28NykYRKSvoZA1kPpzS+BSbWdiSO+zB/7a1NI85o2LdUVcntmAMj2LPpQzQr6xoztVJkPPrvbtyRqFy+m/jgya+KozFe4Xi+a4JF3B63DiaqGQGmqTFmRbJHhJJYG8WqDMG6ym+NoBJyYoGj9DVtB0qocu5HWoNgdto16HtvaJ0wuEWTXfxbVwx5rzLHKMEyoP1UBwgvKiINV24s2/XCFL7EwD/3AgzPm0Ycs6AsLMw69hcLNoaUT4u7PDGe15g==
- Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Tue, 04 May 2021 11:59:54 +0000
- Ironport-hdrordr: A9a23:cI2kAqijhrpeZRfGG1kfWzhAwHBQX3Vw3DAbvn1ZSRFFG/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/Lit7XK7ftqvfQfJ/oVfnQOAdhflm6Lm oIXTD1K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64Th8sTiDmTjXq5pG/eoufSwuSGeyyZDicUDXMFWUH k+XoeTfo95tpYNVGdLhVt5nl8uW1PdRdkOOpXgVhIxZBklr7Y4Ekf1H+F6ntU7+7C6iwzQEXmh rUBrklm6ebTCJCER5uqYDb5XUUdn5kSWj9vtPUTC1YQGQb4rG4XpYNFEAm5PfsH4hxXIjh3LVU Qm0=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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. 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.
~Andrew
|