blob: 0a8ad18ff10a29720289228fba6e7770c3bf4fcb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* Public domain. */
#ifndef _ASM_CPUFEATURE_H
#define _ASM_CPUFEATURE_H
#if defined(__amd64__) || defined(__i386__)
#define X86_FEATURE_CLFLUSH 1
#define X86_FEATURE_XMM4_1 2
#define X86_FEATURE_PAT 3
#define X86_FEATURE_HYPERVISOR 4
static inline bool
static_cpu_has(uint16_t f)
{
switch (f) {
case X86_FEATURE_CLFLUSH:
return curcpu()->ci_cflushsz != 0;
case X86_FEATURE_XMM4_1:
return (cpu_ecxfeature & CPUIDECX_SSE41) != 0;
case X86_FEATURE_PAT:
return (curcpu()->ci_feature_flags & CPUID_PAT) != 0;
case X86_FEATURE_HYPERVISOR:
return (cpu_ecxfeature & CPUIDECX_HV) != 0;
default:
return false;
}
}
#define boot_cpu_has(x) static_cpu_has(x)
static inline void
clflushopt(volatile void *addr)
{
if (curcpu()->ci_feature_sefflags_ebx & SEFF0EBX_CLFLUSHOPT)
__asm volatile("clflushopt %0" : "+m" (*(volatile char *)addr));
else
__asm volatile("clflush %0" : "+m" (*(volatile char *)addr));
}
#endif
#endif
|