Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/initcpu.c
| Show First 20 Lines • Show All 285 Lines • ▼ Show 20 Lines | initializecpu(void) | ||||
| } | } | ||||
| if (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) | if (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) | ||||
| cr4 |= CR4_FSGSBASE; | cr4 |= CR4_FSGSBASE; | ||||
| if (cpu_stdext_feature2 & CPUID_STDEXT2_PKU) | if (cpu_stdext_feature2 & CPUID_STDEXT2_PKU) | ||||
| cr4 |= CR4_PKE; | cr4 |= CR4_PKE; | ||||
| /* | /* | ||||
| * Any CPU having Linear Address Space Separation (LASS) | |||||
emaste: Let's expand LASS once on first use - `Linear Address Space Separation (LASS)`. Where we fetch… | |||||
| * should have SMAP, but check it to be sure. Otherwise | |||||
| * userspace accesses from kernel cannot work. | |||||
| */ | |||||
| if (IS_BSP() && (cpu_stdext_feature4 & CPUID_STDEXT4_LASS) != 0 && | |||||
| (cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0) { | |||||
| lass_enabled = 1; | |||||
| TUNABLE_INT_FETCH("hw.lass", &lass_enabled); | |||||
| } | |||||
| if (lass_enabled) | |||||
| cr4 |= CR4_LASS; | |||||
| /* | |||||
| * If SMEP is present, we only need to flush RSB (by default) | * If SMEP is present, we only need to flush RSB (by default) | ||||
| * on context switches, to prevent cross-process ret2spec | * on context switches, to prevent cross-process ret2spec | ||||
| * attacks. Do it automatically if ibrs_disable is set, to | * attacks. Do it automatically if ibrs_disable is set, to | ||||
| * complete the mitigation. | * complete the mitigation. | ||||
| * | * | ||||
| * 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 | ||||
| ▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines | |||||
Let's expand LASS once on first use - Linear Address Space Separation (LASS). Where we fetch the tunable seems as good a place as any.