Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/initcpu.c
Show First 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | initializecpu(void) | ||||
* Postpone enabling the SMEP on the boot CPU until the page | * Postpone enabling the SMEP on the boot CPU until the page | ||||
* tables are switched from the boot loader identity mapping | * tables are switched from the boot loader identity mapping | ||||
* to the kernel tables. The boot loader enables the U bit in | * to the kernel tables. The boot loader enables the U bit in | ||||
* its tables. | * its tables. | ||||
*/ | */ | ||||
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 (IS_BSP() && (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(); | hw_ibrs_recalculate(); | ||||
switch (cpu_vendor_id) { | switch (cpu_vendor_id) { | ||||
case CPU_VENDOR_AMD: | case CPU_VENDOR_AMD: | ||||
init_amd(); | init_amd(); | ||||
Show All 39 Lines |