// Copyright 2020 The ChromiumOS Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34// These cpuid bit definitions come from HAXM here:5// https://github.com/intel/haxm/blob/v7.6.1/core/include/cpuid.h#L9767use bitflags::bitflags;89const fn feature_bit(bit: u32) -> u32 {101 << bit11}1213/*14* Intel SDM Vol. 2A: Table 3-10.15* Feature Information Returned in the ECX Register16* Features for CPUID with EAX=01h stored in ECX17*/18bitflags! {19#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]20#[repr(transparent)]21pub struct Feature1Ecx: u32 {22const SSE3 = feature_bit(0); /* 0x00000001 Streaming SIMD Extensions 3 */23const PCLMULQDQ = feature_bit(1); /* 0x00000002 PCLMULQDQ Instruction */24const DTES64 = feature_bit(2); /* 0x00000004 64-bit DS Area */25const MONITOR = feature_bit(3); /* 0x00000008 MONITOR/MWAIT Instructions */26const DS_CPL = feature_bit(4); /* 0x00000010 CPL Qualified Debug Store */27const VMX = feature_bit(5); /* 0x00000020 Virtual Machine Extensions */28const SMX = feature_bit(6); /* 0x00000040 Safer Mode Extensions */29const EIST = feature_bit(7); /* 0x00000080 Enhanced Intel SpeedStep technology */30const TM2 = feature_bit(8); /* 0x00000100 Thermal Monitor 2 */31const SSSE3 = feature_bit(9); /* 0x00000200 Supplemental Streaming SIMD Extensions 3 */32const CNXT_ID = feature_bit(10); /* 0x00000400 L1 Context ID */33const SDBG = feature_bit(11); /* 0x00000800 Silicon Debug Interface */34const FMA = feature_bit(12); /* 0x00001000 Fused Multiply-Add */35const CMPXCHG16B = feature_bit(13); /* 0x00002000 CMPXCHG16B Instruction */36const XTPR_UPDATE = feature_bit(14); /* 0x00004000 xTPR Update Control */37const PDCM = feature_bit(15); /* 0x00008000 Perfmon and Debug Capability */38const PCID = feature_bit(17); /* 0x00020000 Process-context identifiers */39const DCA = feature_bit(18); /* 0x00040000 Direct cache access for DMA writes */40const SSE41 = feature_bit(19); /* 0x00080000 Streaming SIMD Extensions 4.1 */41const SSE42 = feature_bit(20); /* 0x00100000 Streaming SIMD Extensions 4.2 */42const X2APIC = feature_bit(21); /* 0x00200000 x2APIC support */43const MOVBE = feature_bit(22); /* 0x00400000 MOVBE Instruction */44const POPCNT = feature_bit(23); /* 0x00800000 POPCNT Instruction */45const TSC_DEADLINE = feature_bit(24); /* 0x01000000 APIC supports one-shot operation using TSC deadline */46const AESNI = feature_bit(25); /* 0x02000000 AESNI Extension */47const XSAVE = feature_bit(26); /* 0x04000000 XSAVE/XRSTOR/XSETBV/XGETBV Instructions and XCR0 */48const OSXSAVE = feature_bit(27); /* 0x08000000 XSAVE enabled by OS */49const AVX = feature_bit(28); /* 0x10000000 Advanced Vector Extensions */50const F16C = feature_bit(29); /* 0x20000000 16-bit Floating-Point Instructions */51const RDRAND = feature_bit(30); /* 0x40000000 RDRAND Instruction */52const HYPERVISOR = feature_bit(31); /* 0x80000000 Hypervisor Running */53}54}5556/*57* Intel SDM Vol. 2A: Table 3-11.58* More on Feature Information Returned in the EDX Register59* Features for CPUID with EAX=01h stored in EDX60*/61bitflags! {62#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]63#[repr(transparent)]64pub struct Feature1Edx: u32 {65const FPU = feature_bit(0); /* 0x00000001 Floating Point Unit On-Chip */66const VME = feature_bit(1); /* 0x00000002 Virtual 8086 Mode Enhancements */67const DE = feature_bit(2); /* 0x00000004 Debugging Extensions */68const PSE = feature_bit(3); /* 0x00000008 Page Size Extension */69const TSC = feature_bit(4); /* 0x00000010 Time Stamp Counter */70const MSR = feature_bit(5); /* 0x00000020 RDMSR/WRMSR Instructions */71const PAE = feature_bit(6); /* 0x00000040 Physical Address Extension */72const MCE = feature_bit(7); /* 0x00000080 Machine Check Exception */73const CX8 = feature_bit(8); /* 0x00000100 CMPXCHG8B Instruction */74const APIC = feature_bit(9); /* 0x00000200 APIC On-Chip */75const SEP = feature_bit(11); /* 0x00000800 SYSENTER/SYSEXIT Instructions */76const MTRR = feature_bit(12); /* 0x00001000 Memory Type Range Registers */77const PGE = feature_bit(13); /* 0x00002000 Page Global Bit */78const MCA = feature_bit(14); /* 0x00004000 Machine Check Architecture */79const CMOV = feature_bit(15); /* 0x00008000 Conditional Move Instructions */80const PAT = feature_bit(16); /* 0x00010000 Page Attribute Table */81const PSE36 = feature_bit(17); /* 0x00020000 36-Bit Page Size Extension */82const PSN = feature_bit(18); /* 0x00040000 Processor Serial Number */83const CLFSH = feature_bit(19); /* 0x00080000 CLFLUSH Instruction */84const DS = feature_bit(21); /* 0x00200000 Debug Store */85const ACPI = feature_bit(22); /* 0x00400000 Thermal Monitor and Software Controlled Clock Facilities */86const MMX = feature_bit(23); /* 0x00800000 Intel MMX Technology */87const FXSR = feature_bit(24); /* 0x01000000 FXSAVE and FXRSTOR Instructions */88const SSE = feature_bit(25); /* 0x02000000 Streaming SIMD Extensions */89const SSE2 = feature_bit(26); /* 0x04000000 Streaming SIMD Extensions 2 */90const SS = feature_bit(27); /* 0x08000000 Self Snoop */91const HTT = feature_bit(28); /* 0x10000000 Max APIC IDs reserved field is Valid */92const TM = feature_bit(29); /* 0x20000000 Thermal Monitor */93const PBE = feature_bit(31); /* 0x80000000 Pending Break Enable */94}95}96/*97* Intel SDM Vol. 2A: Table 3-8. Information Returned by CPUID Instruction98* Extended Function CPUID Information99* Features for CPUID with EAX=80000001h stored in ECX100*/101bitflags! {102#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]103#[repr(transparent)]104pub struct Feature80000001Ecx: u32 {105const LAHF = feature_bit(0); /* 0x00000001 LAHF/SAHF Instructions */106const ABM = feature_bit(5); /* 0x00000020 Advanced bit manipulation (lzcnt and popcnt) */107const PREFETCHW = feature_bit(8); /* 0x00000100 PREFETCH/PREFETCHW instructions */108}109}110111/*112* Intel SDM Vol. 2A: Table 3-8. Information Returned by CPUID Instruction113* Extended Function CPUID Information114* Features for CPUID with EAX=80000001h stored in EDX115*/116bitflags! {117#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]118#[repr(transparent)]119pub struct Feature80000001Edx: u32 {120const SYSCALL = feature_bit(11); /* 0x00000800 SYSCALL/SYSRET Instructions */121const NX = feature_bit(20); /* 0x00100000 No-Execute Bit */122const PDPE1GB = feature_bit(26); /* 0x04000000 Gibibyte pages */123const RDTSCP = feature_bit(27); /* 0x08000000 RDTSCP Instruction */124const EM64T = feature_bit(29); /* 0x20000000 Long Mode */125}126}127128129