|
6 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | // you may not use this file except in compliance with the License. |
8 | 8 | // You may obtain a copy of the License at |
9 | | -// |
| 9 | +// |
10 | 10 | // http://www.apache.org/licenses/LICENSE-2.0 |
11 | | -// |
| 11 | +// |
12 | 12 | // Unless required by applicable law or agreed to in writing, software |
13 | 13 | // distributed under the License is distributed on an "AS IS" BASIS, |
14 | 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
19 | 19 | #ifndef KERNEL_CPUID_HPP |
20 | 20 | #define KERNEL_CPUID_HPP |
21 | 21 |
|
22 | | -struct CPUID { |
23 | | - static bool isAmdCpu(); |
24 | | - static bool isIntelCpu(); |
25 | | - static bool hasRDRAND(); |
26 | | -}; //< CPUID |
| 22 | +namespace CPUID |
| 23 | +{ |
| 24 | + enum class Feature |
| 25 | + { |
| 26 | + // ------------------------------------------------------------------------ |
| 27 | + // Processor Info and Feature Bits |
| 28 | + // ------------------------------------------------------------------------ |
| 29 | + SSE3, // Streaming SIMD Extensions 3 |
| 30 | + PCLMULQDQ, // PCLMULQDQ Instruction |
| 31 | + DTES64, // 64-Bit Debug Store Area |
| 32 | + MONITOR, // MONITOR/MWAIT |
| 33 | + DS_CPL, // CPL Qualified Debug Store |
| 34 | + VMX, // Virtual Machine Extensions |
| 35 | + SMX, // Safer Mode Extensions |
| 36 | + EST, // Enhanced SpeedStep Technology |
| 37 | + TM2, // Thermal Monitor 2 |
| 38 | + SSSE3, // Supplemental Streaming SIMD Extensions 3 |
| 39 | + CNXT_ID, // L1 Context ID |
| 40 | + FMA, // Fused Multiply Add |
| 41 | + CX16, // CMPXCHG16B Instruction |
| 42 | + XTPR, // xTPR Update Control |
| 43 | + PDCM, // Perf/Debug Capability MSR |
| 44 | + PCID, // Process-context Identifiers |
| 45 | + DCA, // Direct Cache Access |
| 46 | + SSE4_1, // Streaming SIMD Extensions 4.1 |
| 47 | + SSE4_2, // Streaming SIMD Extensions 4.2 |
| 48 | + X2APIC, // Extended xAPIC Support |
| 49 | + MOVBE, // MOVBE Instruction |
| 50 | + POPCNT, // POPCNT Instruction |
| 51 | + TSC_DEADLINE, // Local APIC supports TSC Deadline |
| 52 | + AES, // AESNI Instruction |
| 53 | + XSAVE, // XSAVE/XSTOR States |
| 54 | + OSXSAVE, // OS Enabled Extended State Management |
| 55 | + AVX, // AVX Instructions |
| 56 | + F16C, // 16-bit Floating Point Instructions |
| 57 | + RDRAND, // RDRAND Instruction |
| 58 | + |
| 59 | + FPU, // Floating-Point Unit On-Chip |
| 60 | + VME, // Virtual 8086 Mode Extensions |
| 61 | + DE, // Debugging Extensions |
| 62 | + PSE, // Page Size Extension |
| 63 | + TSC, // Time Stamp Counter |
| 64 | + MSR, // Model Specific Registers |
| 65 | + PAE, // Physical Address Extension |
| 66 | + MCE, // Machine-Check Exception |
| 67 | + CX8, // CMPXCHG8 Instruction |
| 68 | + APIC, // APIC On-Chip |
| 69 | + SEP, // SYSENTER/SYSEXIT instructions |
| 70 | + MTRR, // Memory Type Range Registers |
| 71 | + PGE, // Page Global Bit |
| 72 | + MCA, // Machine-Check Architecture |
| 73 | + CMOV, // Conditional Move Instruction |
| 74 | + PAT, // Page Attribute Table |
| 75 | + PSE_36, // 36-bit Page Size Extension |
| 76 | + PSN, // Processor Serial Number |
| 77 | + CLFLUSH, // CLFLUSH Instruction |
| 78 | + DS, // Debug Store |
| 79 | + ACPI, // Thermal Monitor and Software Clock Facilities |
| 80 | + MMX, // MMX Technology |
| 81 | + FXSR, // FXSAVE and FXSTOR Instructions |
| 82 | + SSE, // Streaming SIMD Extensions |
| 83 | + SSE2, // Streaming SIMD Extensions 2 |
| 84 | + SS, // Self Snoop |
| 85 | + HTT, // Multi-Threading |
| 86 | + TM, // Thermal Monitor |
| 87 | + PBE, // Pending Break Enable |
| 88 | + |
| 89 | + // ------------------------------------------------------------------------ |
| 90 | + // Extended Processor Info and Feature Bits (not complete) |
| 91 | + // ------------------------------------------------------------------------ |
| 92 | + SYSCALL, // SYSCALL/SYSRET |
| 93 | + NX, // Execute Disable Bit |
| 94 | + PDPE1GB, // 1 GB Pages |
| 95 | + RDTSCP, // RDTSCP and IA32_TSC_AUX |
| 96 | + LM, // Long mode (64-bit Architecture) |
| 97 | + }; |
| 98 | + |
| 99 | + bool is_amd_cpu(); |
| 100 | + bool is_intel_cpu(); |
| 101 | + bool has_feature(Feature f); |
| 102 | + |
| 103 | + unsigned kvm_function(); |
| 104 | + bool kvm_feature(unsigned id); |
| 105 | +} //< CPUID |
| 106 | + |
| 107 | +#define KVM_FEATURE_CLOCKSOURCE 0 |
| 108 | +#define KVM_FEATURE_NOP_IO_DELAY 1 |
| 109 | +#define KVM_FEATURE_MMU_OP 2 /* deprecated */ |
| 110 | +#define KVM_FEATURE_CLOCKSOURCE2 3 |
| 111 | +#define KVM_FEATURE_ASYNC_PF 4 |
| 112 | +#define KVM_FEATURE_STEAL_TIME 5 |
| 113 | +#define KVM_FEATURE_PV_EOI 6 |
| 114 | +#define KVM_FEATURE_PV_UNHALT 7 |
| 115 | +#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 24 |
27 | 116 |
|
28 | 117 | #endif //< KERNEL_CPUID_HPP |
0 commit comments