Utility routines for identifying features of the processor. More...
Data Structures | |
struct | features_t |
Utility routines for identifying features of the processor.
#define DR_FPSTATE_ALIGN 16 |
The alignment requirements of floating point state buffer.
#define DR_FPSTATE_BUF_SIZE 512 |
The maximum possible required size of floating point state buffer for processors with different features (i.e., the processors with the FXSR feature on x86, or the processors with the VFPv3 feature on ARM).
#define FAMILY_486 4 |
proc_get_family() processor family: 486
#define FAMILY_ATHLON 6 |
proc_get_family() processor family: Athlon
#define FAMILY_CORE 6 |
proc_get_family() processor family: Core
#define FAMILY_CORE_2 6 |
proc_get_family() processor family: Core 2
#define FAMILY_CORE_I7 6 |
proc_get_family() processor family: Core i7
#define FAMILY_ITANIUM 7 |
proc_get_family() processor family: Itanium
#define FAMILY_ITANIUM_2 16 |
proc_get_family() processor family: Itanium 2
#define FAMILY_ITANIUM_2_DC 17 |
proc_get_family() processor family: Itanium 2 DC
#define FAMILY_IVYBRIDGE 6 |
proc_get_family() processor family: IvyBridge
#define FAMILY_K5 5 |
proc_get_family() processor family: K5
#define FAMILY_K6 5 |
proc_get_family() processor family: K6
#define FAMILY_K7 6 |
proc_get_family() processor family: AMD K7
#define FAMILY_K8 15 |
proc_get_family() processor family: AMD K8
#define FAMILY_K8_MOBILE 17 |
proc_get_family() processor family: AMD K8 Mobile
#define FAMILY_K8L 16 |
proc_get_family() processor family: AMD K8L
#define FAMILY_LLANO 18 |
proc_get_family() processor family: AMD Llano
#define FAMILY_NEHALEM 6 |
proc_get_family() processor family: Nehalem
#define FAMILY_P4 15 |
proc_get_family() processor family: P4 family
#define FAMILY_P5 5 |
proc_get_family() processor family: P5 family
#define FAMILY_P6 6 |
proc_get_family() processor family: P6 family
#define FAMILY_PENTIUM 5 |
proc_get_family() processor family: Pentium
#define FAMILY_PENTIUM_2 6 |
proc_get_family() processor family: Pentium 2
#define FAMILY_PENTIUM_3 6 |
proc_get_family() processor family: Pentium 3
#define FAMILY_PENTIUM_4 15 |
proc_get_family() processor family: Pentium 4
#define FAMILY_PENTIUM_M 6 |
proc_get_family() processor family: Pentium M
#define FAMILY_PENTIUM_PRO 6 |
proc_get_family() processor family: Pentium Pro
#define FAMILY_SANDYBRIDGE 6 |
proc_get_family() processor family: SandyBridge
#define MODEL_ATOM 28 |
proc_get_model(): Atom
#define MODEL_ATOM_CEDARVIEW 54 |
proc_get_model(): Atom Cedarview
#define MODEL_ATOM_LINCROFT 38 |
proc_get_model(): Atom Lincroft
#define MODEL_CORE 14 |
proc_get_model(): Core Yonah
#define MODEL_CORE_2 15 |
proc_get_model(): Core 2 Merom/Conroe
#define MODEL_CORE_MEROM 15 |
proc_get_model(): Core 2 Merom
#define MODEL_CORE_PENRYN 23 |
proc_get_model(): Core 2 Penryn
#define MODEL_HASWELL 60 |
proc_get_model(): Haswell
#define MODEL_I7_CLARKDALE 37 |
proc_get_model(): Westmere Clarkdale/Arrandale
#define MODEL_I7_CLARKSFIELD 30 |
proc_get_model(): Core i7 Clarksfield/Lynnfield
#define MODEL_I7_GAINESTOWN 26 |
proc_get_model(): Core i7 Gainestown (Nehalem)
#define MODEL_I7_HAVENDALE 31 |
proc_get_model(): Core i7 Havendale/Auburndale
#define MODEL_I7_WESTMERE 44 |
proc_get_model(): Westmere
#define MODEL_I7_WESTMERE_EX 47 |
proc_get_model(): Sandybridge Westmere Ex
#define MODEL_IVYBRIDGE 58 |
proc_get_model(): Ivybridge
#define MODEL_PENTIUM_M 13 |
proc_get_model(): Pentium M 2MB L2
#define MODEL_PENTIUM_M_1MB 9 |
proc_get_model(): Pentium M 1MB L2
#define MODEL_SANDYBRIDGE 42 |
proc_get_model(): Sandybridge
#define MODEL_SANDYBRIDGE_E 45 |
proc_get_model(): Sandybridge-E, -EN, -EP
anonymous enum |
Constants returned by proc_get_vendor().
Enumerator | |
---|---|
VENDOR_INTEL | proc_get_vendor() processor identification: Intel |
VENDOR_AMD | proc_get_vendor() processor identification: AMD |
VENDOR_ARM | proc_get_vendor() processor identification: ARM |
VENDOR_UNKNOWN | proc_get_vendor() processor identification: unknown |
enum cache_size_t |
L1 and L2 cache sizes, used by proc_get_L1_icache_size(), proc_get_L1_dcache_size(), proc_get_L2_cache_size(), and proc_get_cache_size_str().
enum feature_bit_t |
Feature bits returned by cpuid. Pass one of these values to proc_has_feature() to determine whether the underlying processor has the feature.
Enumerator | |
---|---|
FEATURE_FPU | Floating-point unit on chip |
FEATURE_VME | Virtual Mode Extension |
FEATURE_DE | Debugging Extension |
FEATURE_PSE | Page Size Extension |
FEATURE_TSC | Time-Stamp Counter |
FEATURE_MSR | Model Specific Registers |
FEATURE_PAE | Physical Address Extension |
FEATURE_MCE | Machine Check Exception |
FEATURE_CX8 | OP_cmpxchg8b supported |
FEATURE_APIC | On-chip APIC Hardware supported |
FEATURE_SEP | Fast System Call |
FEATURE_MTRR | Memory Type Range Registers |
FEATURE_PGE | Page Global Enable |
FEATURE_MCA | Machine Check Architecture |
FEATURE_CMOV | Conditional Move Instruction |
FEATURE_PAT | Page Attribute Table |
FEATURE_PSE_36 | 36-bit Page Size Extension |
FEATURE_PSN | Processor serial # present & enabled |
FEATURE_CLFSH | OP_clflush supported |
FEATURE_DS | Debug Store |
FEATURE_ACPI | Thermal monitor & SCC supported |
FEATURE_MMX | MMX technology supported |
FEATURE_FXSR | Fast FP save and restore |
FEATURE_SSE | SSE Extensions supported |
FEATURE_SSE2 | SSE2 Extensions supported |
FEATURE_SS | Self-snoop |
FEATURE_HTT | Hyper-threading Technology |
FEATURE_TM | Thermal Monitor supported |
FEATURE_IA64 | IA64 Capabilities |
FEATURE_PBE | Pending Break Enable |
FEATURE_SSE3 | SSE3 Extensions supported |
FEATURE_PCLMULQDQ | OP_pclmulqdq supported |
FEATURE_DTES64 | 64-bit debug store supported |
FEATURE_MONITOR | OP_monitor/OP_mwait supported |
FEATURE_DS_CPL | CPL Qualified Debug Store |
FEATURE_VMX | Virtual Machine Extensions |
FEATURE_SMX | Safer Mode Extensions |
FEATURE_EST | Enhanced Speedstep Technology |
FEATURE_TM2 | Thermal Monitor 2 |
FEATURE_SSSE3 | SSSE3 Extensions supported |
FEATURE_CID | Context ID |
FEATURE_FMA | FMA instructions supported |
FEATURE_CX16 | OP_cmpxchg16b supported |
FEATURE_xTPR | Send Task Priority Messages |
FEATURE_PDCM | Perfmon and Debug Capability |
FEATURE_PCID | Process-context identifiers |
FEATURE_DCA | Prefetch from memory-mapped devices |
FEATURE_SSE41 | SSE4.1 Extensions supported |
FEATURE_SSE42 | SSE4.2 Extensions supported |
FEATURE_x2APIC | x2APIC supported |
FEATURE_MOVBE | OP_movbe supported |
FEATURE_POPCNT | OP_popcnt supported |
FEATURE_AES | AES instructions supported |
FEATURE_XSAVE | OP_xsave* supported |
FEATURE_OSXSAVE | OP_xgetbv supported in user mode |
FEATURE_AVX | AVX instructions supported |
FEATURE_F16C | 16-bit floating-point conversion supported |
FEATURE_RDRAND | OP_rdrand supported |
FEATURE_SYSCALL | OP_syscall/OP_sysret supported |
FEATURE_XD_Bit | Execution Disable bit |
FEATURE_MMX_EXT | AMD MMX Extensions |
FEATURE_PDPE1GB | Gigabyte pages |
FEATURE_RDTSCP | OP_rdtscp supported |
FEATURE_EM64T | Extended Memory 64 Technology |
FEATURE_3DNOW_EXT | AMD 3DNow! Extensions |
FEATURE_3DNOW | AMD 3DNow! instructions supported |
FEATURE_LAHF | |
FEATURE_SVM | AMD Secure Virtual Machine |
FEATURE_LZCNT | OP_lzcnt supported |
FEATURE_SSE4A | AMD SSE4A Extensions supported |
FEATURE_PRFCHW | OP_prefetchw supported |
FEATURE_XOP | AMD XOP supported |
FEATURE_SKINIT | |
FEATURE_FMA4 | AMD FMA4 supported |
FEATURE_TBM | AMD Trailing Bit Manipulation supported |
FEATURE_FSGSBASE | OP_rdfsbase, etc. supported |
FEATURE_BMI1 | BMI1 instructions supported |
FEATURE_HLE | Hardware Lock Elision supported |
FEATURE_AVX2 | AVX2 instructions supported |
FEATURE_BMI2 | BMI2 instructions supported |
FEATURE_ERMSB | Enhanced rep movsb/stosb supported |
FEATURE_INVPCID | OP_invpcid supported |
FEATURE_RTM | Restricted Transactional Memory supported |
bool dr_insert_get_seg_base | ( | void * | drcontext, |
instrlist_t * | ilist, | ||
instr_t * | instr, | ||
reg_id_t | seg, | ||
reg_id_t | reg | ||
) |
Insert code to get the segment base address pointed to by seg into register reg. In Linux, it is only supported with -mangle_app_seg option. In Windows, it only supports getting base address of the TLS segment.
void dr_insert_restore_fpstate | ( | void * | drcontext, |
instrlist_t * | ilist, | ||
instr_t * | where, | ||
opnd_t | buf | ||
) |
Inserts into ilist
prior to where
meta-instruction(s) to restore the floating point state from the 16-byte-aligned buffer referred to by buf, which must be 512 bytes for processors with the FXSR feature, and 108 bytes for those without (where this routine does not support 16-bit operand sizing). buf
should have size of OPSZ_512; this routine will automatically adjust it to OPSZ_108 if necessary.
When the FXSR feature is present, the fxsave format matches the bitwidth of the ISA mode of the current thread (see dr_get_isa_mode()).
Inserts into ilist
prior to where
meta-instruction(s) to save the floating point state into the 16-byte-aligned buffer referred to by buf
, which must be 512 bytes for processors with the FXSR feature, and 108 bytes for those without (where this routine does not support 16-bit operand sizing). buf
should have size of OPSZ_512; this routine will automatically adjust it to OPSZ_108 if necessary.
When the FXSR feature is present, the fxsave format matches the bitwidth of the ISA mode of the current thread (see dr_get_isa_mode()).
The last floating-point instruction address is left in an untranslated state (i.e., it may point into the code cache).
bool proc_avx_enabled | ( | void | ) |
Returns whether AVX is enabled by both the processor and the operating system. Even if the processor supports AVX, if the operating system does not enable AVX state saving, then AVX instructions will fault.
ptr_uint_t proc_bump_to_end_of_cache_line | ( | ptr_uint_t | sz | ) |
Returns n >= sz
such that n is a multiple of the cache line size.
size_t proc_fpstate_save_size | ( | void | ) |
Returns the size in bytes needed for a buffer for saving the floating point state.
features_t* proc_get_all_feature_bits | ( | void | ) |
Returns all 4 32-bit feature values. Use proc_has_feature to test for specific features.
char* proc_get_brand_string | ( | void | ) |
Returns the processor brand string as given by the cpuid instruction.
size_t proc_get_cache_line_size | ( | void | ) |
Returns the cache line size in bytes of the processor.
const char* proc_get_cache_size_str | ( | cache_size_t | size | ) |
Converts a cache_size_t type to a string.
void* proc_get_containing_page | ( | void * | addr | ) |
Returns n <= addr
such that n is a multiple of the page size.
uint proc_get_family | ( | void | ) |
Returns the processor family as given by the cpuid instruction, adjusted by the extended family as described in the Intel documentation. The FAMILY_ constants identify important family values.
cache_size_t proc_get_L1_dcache_size | ( | void | ) |
Returns the size of the L1 data cache.
cache_size_t proc_get_L1_icache_size | ( | void | ) |
Returns the size of the L1 instruction cache.
cache_size_t proc_get_L2_cache_size | ( | void | ) |
Returns the size of the L2 cache.
uint proc_get_model | ( | void | ) |
Returns the processor model as given by the cpuid instruction, adjusted by the extended model as described in the Intel documentation. The MODEL_ constants identify important model values.
uint proc_get_stepping | ( | void | ) |
Returns the processor stepping ID.
uint proc_get_type | ( | void | ) |
Returns the processor type as given by the cpuid instruction.
uint proc_get_vendor | ( | void | ) |
Returns one of the VENDOR_ constants.
bool proc_has_feature | ( | feature_bit_t | feature | ) |
Tests if processor has selected feature.
bool proc_is_cache_aligned | ( | void * | addr | ) |
Returns true only if addr
is cache-line-aligned.
void proc_restore_fpstate | ( | byte * | buf | ) |
Restores the floating point state from the buffer buf
. On x86, the buffer must be 16-byte-aligned, and it must be 512 (DR_FPSTATE_BUF_SIZE) bytes for processors with the FXSR feature, and 108 bytes for those without (where this routine does not support 16-bit operand sizing). On ARM/AArch64, nothing needs to be restored as the SIMD/FP registers are restored together with the general-purpose registers.
When the FXSR feature is present, the fxsave format matches the bitwidth of the ISA mode of the current thread (see dr_get_isa_mode()).
size_t proc_save_fpstate | ( | byte * | buf | ) |
Saves the floating point state into the buffer buf
.
On x86, the buffer must be 16-byte-aligned, and it must be 512 (DR_FPSTATE_BUF_SIZE) bytes for processors with the FXSR feature, and 108 bytes for those without (where this routine does not support 16-bit operand sizing). On ARM/AArch64, nothing needs to be saved as the SIMD/FP registers are saved together with the general-purpose registers.
When the FXSR feature is present, the fxsave format matches the bitwidth of the ISA mode of the current thread (see dr_get_isa_mode()).
The last floating-point instruction address is left in an untranslated state (i.e., it may point into the code cache).
DR does NOT save the application's floating-point or MMX state on context switches! Thus if a client performs any floating-point operations in its main routines called by DR, the client must save and restore the floating-point/MMX state. If the client needs to do so inside the code cache the client should implement that itself. Returns number of bytes written.
int proc_set_vendor | ( | uint | new_vendor | ) |
Sets the vendor to the given VENDOR_ constant. This function is supplied to support decoding or encoding with respect to other than the current processor being executed on. The change in vendor will be seen by the decoder and encoder, as well as the rest of the system.