Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/initcpu.c
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
* -1: automatic (default) | * -1: automatic (default) | ||||
* 0: keep enable CLFLUSH | * 0: keep enable CLFLUSH | ||||
* 1: force disable CLFLUSH | * 1: force disable CLFLUSH | ||||
*/ | */ | ||||
static int hw_clflush_disable = -1; | static int hw_clflush_disable = -1; | ||||
static void | static void | ||||
init_amd(void) | init_amd(void) | ||||
{ | { | ||||
emaste: Probably avoiding negative-sense tunables/sysctls is preferred (although we have clfush_disable… | |||||
uint64_t msr; | uint64_t msr; | ||||
/* | /* | ||||
* Work around Erratum 721 for Family 10h and 12h processors. | * Work around Erratum 721 for Family 10h and 12h processors. | ||||
* These processors may incorrectly update the stack pointer | * These processors may incorrectly update the stack pointer | ||||
* after a long series of push and/or near-call instructions, | * after a long series of push and/or near-call instructions, | ||||
* or a long series of pop and/or near-return instructions. | * or a long series of pop and/or near-return instructions. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | initializecpu(void) | ||||
if (!IS_BSP() && (cpu_stdext_feature & CPUID_STDEXT_SMEP)) | if (!IS_BSP() && (cpu_stdext_feature & CPUID_STDEXT_SMEP)) | ||||
cr4 |= CR4_SMEP; | cr4 |= CR4_SMEP; | ||||
load_cr4(cr4); | load_cr4(cr4); | ||||
if ((amd_feature & AMDID_NX) != 0) { | if ((amd_feature & AMDID_NX) != 0) { | ||||
msr = rdmsr(MSR_EFER) | EFER_NXE; | msr = rdmsr(MSR_EFER) | EFER_NXE; | ||||
wrmsr(MSR_EFER, msr); | wrmsr(MSR_EFER, msr); | ||||
pg_nx = PG_NX; | pg_nx = PG_NX; | ||||
} | } | ||||
hw_ibrs_recalculate(); | |||||
switch (cpu_vendor_id) { | switch (cpu_vendor_id) { | ||||
case CPU_VENDOR_AMD: | case CPU_VENDOR_AMD: | ||||
init_amd(); | init_amd(); | ||||
break; | break; | ||||
case CPU_VENDOR_CENTAUR: | case CPU_VENDOR_CENTAUR: | ||||
init_via(); | init_via(); | ||||
break; | break; | ||||
} | } | ||||
Show All 34 Lines |
Probably avoiding negative-sense tunables/sysctls is preferred (although we have clfush_disable just above, perhaps maintaining consistency is sensible)