[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] x86/cpuid: Infrastructure to support pseudo feature identifiers


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 4 Oct 2022 17:08:09 +0100
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 04 Oct 2022 16:08:42 +0000
  • Ironport-data: A9a23:Q+wl+qvUysOPWi3eBaCGPFMz/efnVIFeMUV32f8akzHdYApBsoF/q tZmKWnSaPiPNjf9KdBxOoXlphgBvJHcy9RhT1NkqCk9EixD+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVKiefHgZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ire7kIy1BjOkGlA5AZnPagX5AS2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDkl23 uBFDCorbSmnqMGd0Lfme8xMpe4aeZyD0IM34hmMzBncBPciB5vCX7/L9ZlT2zJYasJmRKiEI ZBDMHw2MUqGM0Yn1lQ/UfrSmM+BgHXlfiIeg1WSvactuEDYzRBr0airO93QEjCPbZUJwhnI/ D2fl4j/KgwbZdOV7jqkzimlgbLuniDqd68dKrLto5aGh3XMnzdOWXX6T2CTgfS/kF/4ZNtZJ GQd4C9opq83nGSuR8P4Vge1o1aFuAAdQNtaF+Am6ACLxbHQ6gzfDW8BJhZNZdknnM4wWz0x1 1WNks/pBDpgq7mcQzSW8bL8hSO/P20ZIHEPYQcATBAZ+J/zrYcrlBXNQ91/VqmvgbXdOxv93 jSLpygWnKgIgIgA0KDT1U/DqyKhoN7OVAFd2+nMdjv7tEUjPtfjPtH2rwiAhRpdEGqHZmGqo CUgge6d1cQhLrqdkXG8ZcUuNoj8sp5pLwbgqVJoGpAg8RGk9HiiYZ1c7VlCGat5DioXUWS3O RGO4Gu98LcWZSL3NvEvP+pdHuxwlcDd+cLZuuc4hzakSrx4b0e58S5nfiZ8NEi9wRF3wcnT1 Xp2GPtA7Er264w9lVJapM9Hi9fHIxzSIkuMLa0XNzz9jdKjiIe9EN/pymemYOEj97+jqw7I6 dtZPMbi40wBDrGuOHOMod5Ncw9iwZ0H6Xfe9KRqmhOreFI6SAnN9deIqV/eR2CVt/sMzbqZl p1MckRZ1ED+lRX6FOl+UVg6MeuHYHqKhShkVcDaFQr3hiNLjEfGxPt3SqbbipF+r707kqQkE qZtlgfpKq0ndwkrMg81NfHVxLGOvjzw7e5SF0JJuAQCQqM=
  • Ironport-hdrordr: A9a23:2VHCt6uEgNy0BHGMmJ8lGVl77skDTNV00zEX/kB9WHVpmszxra GTdZMgpGfJYVcqKQgdcL+7Scq9qB/nmqKdpLNhWYtKPzOW3ldATrsSj7cKqgeIc0aVm4JgPO VbAs9D4bXLfCNHZK3BgDVQfexP/DD+ytHMudvj
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

A future change will want a cpuid-like identifier which doesn't have a mapping
to a feature bit.

 * Pass the feature name into the parse callback.
 * Exclude a feature value of ~0u from falling into the general set/clear bit
   paths.
 * In gen-cpuid.py, insert a placeholder to collect all the pseudo feature
   names.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
CC: Henry Wang <Henry.Wang@xxxxxxx>
CC: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
CC: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
---
 xen/arch/x86/cpuid.c   | 17 +++++++++++++----
 xen/tools/gen-cpuid.py | 13 +++++++++++++
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 822f9ace1087..112ee63a9449 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -39,7 +39,8 @@ static const struct feature_name {
  * function pointer call in the middle of the loop.
  */
 static int __init always_inline parse_cpuid(
-    const char *s, void (*callback)(unsigned int feat, bool val))
+    const char *s, void (*callback)(const char *name,
+                                    unsigned int feat, bool val))
 {
     const char *ss;
     int val, rc = 0;
@@ -81,7 +82,7 @@ static int __init always_inline parse_cpuid(
 
             if ( (val = parse_boolean(mid->name, s, ss)) >= 0 )
             {
-                callback(mid->bit, val);
+                callback(mid->name, mid->bit, val);
                 mid = NULL;
             }
 
@@ -101,8 +102,12 @@ static int __init always_inline parse_cpuid(
     return rc;
 }
 
-static void __init cf_check _parse_xen_cpuid(unsigned int feat, bool val)
+static void __init cf_check _parse_xen_cpuid(
+    const char *name, unsigned int feat, bool val)
 {
+    if ( unlikely(feat == ~0u) )
+        return;
+
     if ( !val )
         setup_clear_cpu_cap(feat);
     else if ( feat == X86_FEATURE_RDRAND &&
@@ -120,8 +125,12 @@ static bool __initdata dom0_cpuid_cmdline;
 static uint32_t __initdata dom0_enable_feat[FSCAPINTS];
 static uint32_t __initdata dom0_disable_feat[FSCAPINTS];
 
-static void __init cf_check _parse_dom0_cpuid(unsigned int feat, bool val)
+static void __init cf_check _parse_dom0_cpuid(
+    const char *name, unsigned int feat, bool val)
 {
+    if ( unlikely(feat == ~0u) )
+        return;
+
     __set_bit  (feat, val ? dom0_enable_feat  : dom0_disable_feat);
     __clear_bit(feat, val ? dom0_disable_feat : dom0_enable_feat );
 }
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index 4f7c8d78cce7..f3045b3bfd36 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -297,6 +297,19 @@ def crunch_numbers(state):
         RTM: [TSXLDTRK],
     }
 
+    #
+    # Pseudo feature names.  These don't map to a feature bit, but are
+    # inserted into the values dictionary so they can be parsed and handled
+    # specially
+    #
+    pseduo_names = (
+    )
+
+    for n in pseduo_names:
+        if n in state.values:
+            raise Fail("Pseduo feature name %s aliases real feature" % (n, ))
+        state.values[n] = 0xffffffff
+
     deep_features = tuple(sorted(deps.keys()))
     state.deep_deps = {}
 
-- 
2.11.0




 


Rackspace

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