From 2f6148a64b67294c4060ecd913c89688d2406524 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 16 May 2019 17:37:48 -0700 Subject: [PATCH] kernel - Implement support for SMAP and SMEP security (2) * Oops. Do the CR4 initialization in the correct place, so it is applied to all CPUs. --- sys/platform/pc64/x86_64/pmap.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/platform/pc64/x86_64/pmap.c b/sys/platform/pc64/x86_64/pmap.c index 12bf0c394e..cd6f803c24 100644 --- a/sys/platform/pc64/x86_64/pmap.c +++ b/sys/platform/pc64/x86_64/pmap.c @@ -1116,17 +1116,6 @@ pmap_bootstrap(vm_paddr_t *firstaddr) x86_64_protection_init(); /* - * Check for SMAP support and enable if available. Must be done - * after cr3 is loaded. - */ - if (cpu_stdext_feature & CPUID_STDEXT_SMAP) { - load_cr4(rcr4() | CR4_SMAP); - } - if (cpu_stdext_feature & CPUID_STDEXT_SMEP) { - load_cr4(rcr4() | CR4_SMEP); - } - - /* * The kernel's pmap is statically allocated so we don't have to use * pmap_create, which is unlikely to work correctly at this part of * the boot sequence (XXX and which no longer exists). @@ -1279,6 +1268,17 @@ pmap_set_opt(void) if (mycpu->gd_cpuid == 0) /* only on BSP */ cpu_invltlb(); } + + /* + * Check for SMAP support and enable if available. Must be done + * after cr3 is loaded, and on all cores. + */ + if (cpu_stdext_feature & CPUID_STDEXT_SMAP) { + load_cr4(rcr4() | CR4_SMAP); + } + if (cpu_stdext_feature & CPUID_STDEXT_SMEP) { + load_cr4(rcr4() | CR4_SMEP); + } } /* -- 2.11.4.GIT