* CPUID instruction, but this is not preclude other sources of information.
*/
+/*
+ * Attribute syntax:
+ *
+ * Attributes for a particular feature are provided as characters before the
+ * first space in the comment immediately following the feature value.
+ *
+ * Special: '!'
+ * This bit has special properties and is not a straight indication of a
+ * piece of new functionality. Xen will handle these differently,
+ * and may override toolstack settings completely.
+ */
+
/* Intel-defined CPU features, CPUID level 0x00000001.edx, word 0 */
XEN_CPUFEATURE(FPU, 0*32+ 0) /* Onboard FPU */
XEN_CPUFEATURE(VME, 0*32+ 1) /* Virtual Mode Extensions */
XEN_CPUFEATURE(PAE, 0*32+ 6) /* Physical Address Extensions */
XEN_CPUFEATURE(MCE, 0*32+ 7) /* Machine Check Architecture */
XEN_CPUFEATURE(CX8, 0*32+ 8) /* CMPXCHG8 instruction */
-XEN_CPUFEATURE(APIC, 0*32+ 9) /* Onboard APIC */
+XEN_CPUFEATURE(APIC, 0*32+ 9) /*! Onboard APIC */
XEN_CPUFEATURE(SEP, 0*32+11) /* SYSENTER/SYSEXIT */
XEN_CPUFEATURE(MTRR, 0*32+12) /* Memory Type Range Registers */
XEN_CPUFEATURE(PGE, 0*32+13) /* Page Global Enable */
XEN_CPUFEATURE(FXSR, 0*32+24) /* FXSAVE and FXRSTOR instructions */
XEN_CPUFEATURE(SSE, 0*32+25) /* Streaming SIMD Extensions */
XEN_CPUFEATURE(SSE2, 0*32+26) /* Streaming SIMD Extensions-2 */
-XEN_CPUFEATURE(HTT, 0*32+28) /* Hyper-Threading Technology */
+XEN_CPUFEATURE(HTT, 0*32+28) /*! Hyper-Threading Technology */
XEN_CPUFEATURE(TM1, 0*32+29) /* Thermal Monitor 1 */
XEN_CPUFEATURE(PBE, 0*32+31) /* Pending Break Enable */
XEN_CPUFEATURE(DCA, 1*32+18) /* Direct Cache Access */
XEN_CPUFEATURE(SSE4_1, 1*32+19) /* Streaming SIMD Extensions 4.1 */
XEN_CPUFEATURE(SSE4_2, 1*32+20) /* Streaming SIMD Extensions 4.2 */
-XEN_CPUFEATURE(X2APIC, 1*32+21) /* Extended xAPIC */
+XEN_CPUFEATURE(X2APIC, 1*32+21) /*! Extended xAPIC */
XEN_CPUFEATURE(MOVBE, 1*32+22) /* movbe instruction */
XEN_CPUFEATURE(POPCNT, 1*32+23) /* POPCNT instruction */
XEN_CPUFEATURE(TSC_DEADLINE, 1*32+24) /* TSC Deadline Timer */
XEN_CPUFEATURE(AESNI, 1*32+25) /* AES instructions */
XEN_CPUFEATURE(XSAVE, 1*32+26) /* XSAVE/XRSTOR/XSETBV/XGETBV */
-XEN_CPUFEATURE(OSXSAVE, 1*32+27) /* OSXSAVE */
+XEN_CPUFEATURE(OSXSAVE, 1*32+27) /*! OSXSAVE */
XEN_CPUFEATURE(AVX, 1*32+28) /* Advanced Vector Extensions */
XEN_CPUFEATURE(F16C, 1*32+29) /* Half-precision convert instruction */
XEN_CPUFEATURE(RDRAND, 1*32+30) /* Digital Random Number Generator */
-XEN_CPUFEATURE(HYPERVISOR, 1*32+31) /* Running under some hypervisor */
+XEN_CPUFEATURE(HYPERVISOR, 1*32+31) /*! Running under some hypervisor */
/* AMD-defined CPU features, CPUID level 0x80000001.edx, word 2 */
XEN_CPUFEATURE(SYSCALL, 2*32+11) /* SYSCALL/SYSRET */
/* AMD-defined CPU features, CPUID level 0x80000001.ecx, word 3 */
XEN_CPUFEATURE(LAHF_LM, 3*32+ 0) /* LAHF/SAHF in long mode */
-XEN_CPUFEATURE(CMP_LEGACY, 3*32+ 1) /* If yes HyperThreading not valid */
+XEN_CPUFEATURE(CMP_LEGACY, 3*32+ 1) /*! If yes HyperThreading not valid */
XEN_CPUFEATURE(SVM, 3*32+ 2) /* Secure virtual machine */
XEN_CPUFEATURE(EXTAPIC, 3*32+ 3) /* Extended APIC space */
XEN_CPUFEATURE(CR8_LEGACY, 3*32+ 4) /* CR8 in 32-bit mode */
XEN_CPUFEATURE(BMI1, 5*32+ 3) /* 1st bit manipulation extensions */
XEN_CPUFEATURE(HLE, 5*32+ 4) /* Hardware Lock Elision */
XEN_CPUFEATURE(AVX2, 5*32+ 5) /* AVX2 instructions */
-XEN_CPUFEATURE(FDP_EXCP_ONLY, 5*32+ 6) /* x87 FDP only updated on exception. */
+XEN_CPUFEATURE(FDP_EXCP_ONLY, 5*32+ 6) /*! x87 FDP only updated on exception. */
XEN_CPUFEATURE(SMEP, 5*32+ 7) /* Supervisor Mode Execution Protection */
XEN_CPUFEATURE(BMI2, 5*32+ 8) /* 2nd bit manipulation extensions */
XEN_CPUFEATURE(ERMS, 5*32+ 9) /* Enhanced REP MOVSB/STOSB */
XEN_CPUFEATURE(INVPCID, 5*32+10) /* Invalidate Process Context ID */
XEN_CPUFEATURE(RTM, 5*32+11) /* Restricted Transactional Memory */
XEN_CPUFEATURE(PQM, 5*32+12) /* Platform QoS Monitoring */
-XEN_CPUFEATURE(NO_FPU_SEL, 5*32+13) /* FPU CS/DS stored as zero */
+XEN_CPUFEATURE(NO_FPU_SEL, 5*32+13) /*! FPU CS/DS stored as zero */
XEN_CPUFEATURE(MPX, 5*32+14) /* Memory Protection Extensions */
XEN_CPUFEATURE(PQE, 5*32+15) /* Platform QoS Enforcement */
XEN_CPUFEATURE(RDSEED, 5*32+18) /* RDSEED instruction */
/* Intel-defined CPU features, CPUID level 0x00000007:0.ecx, word 6 */
XEN_CPUFEATURE(PREFETCHWT1, 6*32+ 0) /* PREFETCHWT1 instruction */
XEN_CPUFEATURE(PKU, 6*32+ 3) /* Protection Keys for Userspace */
-XEN_CPUFEATURE(OSPKE, 6*32+ 4) /* OS Protection Keys Enable */
+XEN_CPUFEATURE(OSPKE, 6*32+ 4) /*! OS Protection Keys Enable */
/* AMD-defined CPU features, CPUID level 0x80000007.edx, word 7 */
XEN_CPUFEATURE(ITSC, 7*32+ 8) /* Invariant TSC */
# State parsed from input
self.names = {} # Name => value mapping
+ self.raw_special = set()
# State calculated
self.nr_entries = 0 # Number of words in a featureset
self.common_1d = 0 # Common features between 1d and e1d
self.known = [] # All known features
+ self.special = [] # Features with special semantics
def parse_definitions(state):
"""
"""
feat_regex = re.compile(
r"^XEN_CPUFEATURE\(([A-Z0-9_]+),"
- "\s+([\s\d]+\*[\s\d]+\+[\s\d]+)\).*$")
+ "\s+([\s\d]+\*[\s\d]+\+[\s\d]+)\)"
+ "\s+/\*([!]*) .*$")
this = sys.modules[__name__]
name = res.groups()[0]
val = eval(res.groups()[1]) # Regex confines this to a very simple expression
+ attr = res.groups()[2]
if hasattr(this, name):
raise Fail("Duplicate symbol %s" % (name,))
# Construct a reverse mapping of value to name
state.names[val] = name
+ for a in attr:
+
+ if a == "!":
+ state.raw_special.add(val)
+ else:
+ raise Fail("Unrecognised attribute '%s' for %s" % (a, name))
+
if len(state.names) == 0:
raise Fail("No features found")
state.names[e1d_base + (f % 32)] = "E1D_" + state.names[f]
state.common_1d = featureset_to_uint32s(common_1d, 1)[0]
+ state.special = featureset_to_uint32s(state.raw_special, nr_entries)
def write_results(state):
#define CPUID_COMMON_1D_FEATURES %s
#define INIT_KNOWN_FEATURES { \\\n%s\n}
+
+#define INIT_SPECIAL_FEATURES { \\\n%s\n}
""" % (state.nr_entries,
state.common_1d,
format_uint32s(state.known, 4),
+ format_uint32s(state.special, 4),
))
state.output.write(