[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/3] x86/cpuid: Disentangle logic for new feature leaves
- To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Thu, 27 Jan 2022 16:20:05 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Rz4MeOqmOd6nVkvhcy1G9N2jnczBmfonv6t51gRcFzU=; b=STD8bQXv6m54dZzteIbD0NKZFl6w3MsoHQtFkaC7Vgk0NbluqnlWDwO3qZOK5uNHjHzOtCEdxAn0DVuElJPYGFaNatpMebbQC8RRlUutv/EMgaEiHLjgnCE5QpmHoXCUKy5qt+XA+dIzfpR9pwXgBcxch9B5UutkImLxye0156dcEtix2sgaCvtZVBxx9pJxlVxW0Gf9N0+iLNHfrgSXI70ipTJBoWUbb9WXrjaf0hS/YoPRrXeQhp/6P/Ob+DdRdZDcmTX910Q1MqBQG1MjMSeKOXk5nXWf0DgwKO+LJdC47qp30dk6ktih00T+UK4NHF2i/fC98x4LeqgrfkTPiA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cskUz9heUgDt6tXwXzd9jCO4ArhDYU+UHen/AzoxwFLhkx8d00ifli7fNNQ4bEdBka3X2Bq/hHoHKF/Au5DXfgS2PXPwct9H3MOViu0FH0Mzj7nfiuydmg76vfQ4kTIZ+ctcGnywlVwxmFgNuqsyKV/xaJJLoNZXOXYeJRwT8uhydg8lDbDlAJQ5hkp7HQztI/qFO1Re7uQAU5xQ2vf4IV1L5cF/ZqcJrHFNO/bjmzLJAtlJwuVimWjIOA7eGBF7CLyGnbmJ9BQ0eizbk0LVmAxWvUVu0pPArDDnbwldvz89AJgvtAdGMZ1Y61WG76MN8fLPsBohnStjLtbSIyognQ==
- Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Thu, 27 Jan 2022 16:20:21 +0000
- Ironport-data: A9a23:JKTUV6luAypR/eU99Bcr7+jo5gxsIURdPkR7XQ2eYbSJt1+Wr1Gzt xJLCm+GMvaPMWuhf9t+O43goU8AvpTTm4AwTQI9pHg9RCMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA180IMsdoUg7wbRh29Q32YLR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 N5VmoWgcCMtBJHByc8gAyNEHHk5BaITrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBODtMJkSpTdLyjbBAOx9aZvCX7/L9ZlT2zJYasVmQ6uGN 5dDMWEHgBLofTRsYwszDZAEnbmVrWHVdzp/8w/Eqv9ii4TU5FMoi+W8WDbPQfSVQe1Fk0Deo XjJl0zbKBwHMN2UyRKe72mhwOTImEvTSI8UUbG16PNuqFmS3XAITg0bU0Ohpvu0gVL4XMhQQ 3H44QJ38/J0rhbyCICgAVvo+xZooyLwRfJbC8Ij+DipzpDo7leyOzg+UjEZL+Qp4ZpeqSMR6 neFmNbgBDpKubKTSG6A+rr8kQ5eKRT5PkdZO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/e +nl6x6Tk2bCBMqh6qAdxs4dtmGg+eOuIPtYBYACRJiwhKJlymU5LnzFAXd9gsCUhtUqI1Ssl Ttokjc3OGOovu7whjT2yv49JJNgubszdNFGYilltUVEDPxkQylDb4RGYFq/QpF5d1H2mxa1+ UkkC1QefibLEmhJ11dlCGdnzUIFgxes0MKh2Xo2kcL6vaJOw7SQ/Ax+76xNCGptnbI9esMoJ 6ilQiixutqJAKFkyLn69fSURZ20kKyvHo5iOYWy2dSSI0EddZq3MYiFW5uYd899RjBmcsa+S hVfbXhzecTdUnfY2HSv2FpztDpVnMvHg2eSkxHvsCOyTBZkH1w0kNdnaUk7zs93YN4T4MB6/ XPM6xumr0LRsgKbbhlDONERcesEGTCTR/FLWrXK1X6E6MMPW7LtvfMkfgIzfDvfIZNwIo5mZ zHXl8dvWkue1j2AcnLx5FP+gClehT1Yd0s8LAp23FUgMyPeFPbC1z1dLl1qbrSnxw2OLyvZ8 qO
- Ironport-sdr: cnb8f63fWneYzH8TwNljrh+cENDrdcpqhtYr6vaPNp+hcDmQOlNQClkWBDMUAugnZaDtx6QHP2 X4w8BuecxPIfe7pkWBZUI/P6icJ6mBqlgYgaGpg0rMRW7i9HMB1/bYIUPyK59YXXi0wi06C5K9 9E0ctGwBksE3cy/ihLugn62yajxRUHeWm82CR0PW3pct2gkxwoN4HRCasUtB8W0NA+9I5FiQc5 VlpPN339Jdd0ObvULjVbrzdpNtJHzuAQzI5kXtw7nYWnz9Ar914TB4C+3R2AEt1xDCkvJnqVbo YzEXcwSnzNZnKcOsrmlmw2Mq
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHYE5hplKNdaXkno0SC1jCd8+jv06x3DEoA
- Thread-topic: [PATCH 1/3] x86/cpuid: Disentangle logic for new feature leaves
On 27/01/2022 16:09, Andrew Cooper wrote:
> Adding a new feature leaf is a reasonable amount of boilerplate and for the
> patch to build, at least one feature from the new leaf needs defining. This
> typically causes two non-trivial changes to be merged together.
>
> First, have gen-cpuid.py write out some extra placeholder defines:
>
> #define CPUID_BITFIELD_11 bool :1, :1, lfence_dispatch:1, ...
> #define CPUID_BITFIELD_12 uint32_t :32 /* placeholder */
> #define CPUID_BITFIELD_13 uint32_t :32 /* placeholder */
> #define CPUID_BITFIELD_14 uint32_t :32 /* placeholder */
> #define CPUID_BITFIELD_15 uint32_t :32 /* placeholder */
>
> This allows DECL_BITFIELD() to be added to struct cpuid_policy without
> requiring a XEN_CPUFEATURE() declared for the leaf. The choice of 4 is
> arbitrary, and allows us to add more than one leaf at a time if necessary.
>
> Second, rework generic_identify() to not use feature leaf names.
This should say "not use specific feature names."
Fixed locally.
~Andrew
> The choice of deriving the index from a feature was to avoid mismatches, but
> its correctness depends on bugs like c/s 249e0f1d8f20 ("x86/cpuid: Fix
> TSXLDTRK definition") not happening.
>
> Switch to using FEATURESET_* just like the policy/featureset helpers. This
> breaks the cognitive complexity of needing to know which leaf a specifically
> named feature should reside in, and is shorter to write. It is also far
> easier to identify as correct at a glance, given the correlation with the
> CPUID leaf being read.
>
> In addition, tidy up some other bits of generic_identify()
> * Drop leading zeros from leaf numbers.
> * Don't use a locked update for X86_FEATURE_APERFMPERF.
> * Rework extended_cpuid_level calculation to avoid setting it twice.
> * Use "leaf >= $N" consistently so $N matches with the CPUID input.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
|