Skip to contentSkip to conversation

x86/gen-cpuid: Distinguish default vs max in feature annotations

PATCH In review Andrew Cooper 2 participants 3 messages May 8, 2020 – May 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/gen-cpuid: Distinguish default vs max in feature annotations

Allow lowercase a/s/h to be used to annotate a non-default feature.

However, until the toolstack migration logic is fixed, it is not safe to activate yet. Tolerate the annotations, but ignore them for now.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

This patch has been pending the toolstack work for several months now, and we want to start using the max tags for x86 emul work.

---
 xen/include/public/arch-x86/cpufeatureset.h | 2 ++
 xen/tools/gen-cpuid.py                      | 5 +++++
 2 files changed, 7 insertions(+)
xen/include/public/arch-x86/cpufeatureset.h +2 -0
index e2749245f3..0ffab6c57b 100644
@@ -87,6 +87,8 @@ enum {
  *   'A' = All guests.
  *   'S' = All HVM guests (not PV guests).
  *   'H' = HVM HAP guests (not PV or HVM Shadow guests).
+ *   Upper case => Available by default
+ *   Lower case => Can be opted-in to, but not available by default.
  */
 
 /* Intel-defined CPU features, CPUID level 0x00000001.edx, word 0 */
xen/tools/gen-cpuid.py +5 -0
index af5610a5e6..d90a2d85c7 100755
@@ -23,6 +23,7 @@ def __init__(self, input, output):
         self.raw = {
             '!': set(),
             'A': set(), 'S': set(), 'H': set(),
+            'a': set(), 's': set(), 'h': set(),
         }
 
         # State calculated
@@ -133,9 +134,13 @@ def crunch_numbers(state):
     state.hvm_shadow_def = state.pv_def | state.raw['S']
     state.hvm_hap_def = state.hvm_shadow_def | state.raw['H']
 
+    # TODO: Ignore def/max split until the toolstack migration logic is fixed
     state.pv_max = state.pv_def
     state.hvm_shadow_max = state.hvm_shadow_def
     state.hvm_hap_max = state.hvm_hap_def
+    # state.pv_max = state.raw['A'] | state.raw['a']
+    # state.hvm_shadow_max = state.pv_max | state.raw['S'] | state.raw['s']
+    # state.hvm_hap_max = state.hvm_shadow_max | state.raw['H'] | state.raw['h']
 
     #
     # Feature dependency information.
Signature · 1 line
2.11.0
#1 lore raw

xen/tools/gen-cpuid.py def crunch_numbers(state): · line 143

Quoted 11 lines · Andrew Cooper
xen/tools/gen-cpuid.py +4 -0
@@ -133,9 +134,13 @@ def crunch_numbers(state):
     state.hvm_shadow_def = state.pv_def | state.raw['S']
     state.hvm_hap_def = state.hvm_shadow_def | state.raw['H']
 
+    # TODO: Ignore def/max split until the toolstack migration logic is fixed
     state.pv_max = state.pv_def
     state.hvm_shadow_max = state.hvm_shadow_def
     state.hvm_hap_max = state.hvm_hap_def
+    # state.pv_max = state.raw['A'] | state.raw['a']
+    # state.hvm_shadow_max = state.pv_max | state.raw['S'] | state.raw['s']
+    # state.hvm_hap_max = state.hvm_shadow_max | state.raw['H'] | state.raw['h']

While in comment form it doesn't matter yet, for actually enabling this it would seem to me to be more expressive as

state.pv_max = state.pv_def | state.raw['a'] state.hvm_shadow_max = state.hvm_shadow_def | state.pv_max | state.raw['s'] state.hvm_hap_max = state.hvm_hap_def | state.hvm_shadow_max | state.raw['h']

Thoughts?

Jan

#2 lore raw
Quoted 17 lines · Jan Beulich

[CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments unless you have verified the sender and know the content is safe.

xen/tools/gen-cpuid.py def crunch_numbers(state): · line 143

Quoted 11 lines · Andrew Cooper
xen/tools/gen-cpuid.py +4 -0
@@ -133,9 +134,13 @@ def crunch_numbers(state):
     state.hvm_shadow_def = state.pv_def | state.raw['S']
     state.hvm_hap_def = state.hvm_shadow_def | state.raw['H']
 
+    # TODO: Ignore def/max split until the toolstack migration logic is fixed
     state.pv_max = state.pv_def
     state.hvm_shadow_max = state.hvm_shadow_def
     state.hvm_hap_max = state.hvm_hap_def
+    # state.pv_max = state.raw['A'] | state.raw['a']
+    # state.hvm_shadow_max = state.pv_max | state.raw['S'] | state.raw['s']
+    # state.hvm_hap_max = state.hvm_shadow_max | state.raw['H'] | state.raw['h']

While in comment form it doesn't matter yet, for actually enabling this it would seem to me to be more expressive as

Quoted 5 lines

state.pv_max = state.pv_def | state.raw['a'] state.hvm_shadow_max = state.hvm_shadow_def | state.pv_max | state.raw['s'] state.hvm_hap_max = state.hvm_hap_def | state.hvm_shadow_max | state.raw['h']

Thoughts?

The format/layout of metadata prohibits that from having any kind of difference.

Furthermore, expressing it this way doesn't require anyone to look at the *_def derivation to figure out what is going on.

I'm going to commit it in this form, but will tidy it up to be properly tabulated in a future patch, to make it easier to read.

~Andrew