diff options
author | Dmitry Chagin <dchagin@FreeBSD.org> | 2022-06-29 07:34:43 +0000 |
---|---|---|
committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2022-06-29 07:34:43 +0000 |
commit | 050f5a8405c63dadaf522d27c3d4f2a2ae522bf6 (patch) | |
tree | 669245b56f11fce718da9434dfd03ed3bbf6f1e6 | |
parent | 8da00a514e699e4fa788109cf36f3b02168b39d7 (diff) | |
download | src-050f5a8405c63dadaf522d27c3d4f2a2ae522bf6.tar.gz src-050f5a8405c63dadaf522d27c3d4f2a2ae522bf6.zip |
amd64: Reload CPU ext features after resume or cr4 changes
Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D35555
MFC after: 2 weeks
-rw-r--r-- | sys/amd64/amd64/initcpu.c | 3 | ||||
-rw-r--r-- | sys/x86/include/x86_var.h | 1 | ||||
-rw-r--r-- | sys/x86/x86/identcpu.c | 12 |
3 files changed, 16 insertions, 0 deletions
diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c index 44a294da205a..1a251208cfd6 100644 --- a/sys/amd64/amd64/initcpu.c +++ b/sys/amd64/amd64/initcpu.c @@ -292,6 +292,9 @@ initializecpu(void) cr4 |= CR4_SMAP; } load_cr4(cr4); + /* Reload cpu ext features to reflect cr4 changes */ + if (IS_BSP()) + identify_cpu_ext_features(); if (IS_BSP() && (amd_feature & AMDID_NX) != 0) { msr = rdmsr(MSR_EFER) | EFER_NXE; wrmsr(MSR_EFER, msr); diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index b4a27ca01eaa..3e8e643e1b9c 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -128,6 +128,7 @@ void restore_wp(bool old_wp); void finishidentcpu(void); void identify_cpu1(void); void identify_cpu2(void); +void identify_cpu_ext_features(void); void identify_cpu_fixup_bsp(void); void identify_hypervisor(void); void initializecpu(void); diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c index 4ccbd3da311f..7b2d32d9c7a3 100644 --- a/sys/x86/x86/identcpu.c +++ b/sys/x86/x86/identcpu.c @@ -1609,6 +1609,18 @@ identify_cpu2(void) } void +identify_cpu_ext_features(void) +{ + u_int regs[4]; + + if (cpu_high >= 7) { + cpuid_count(7, 0, regs); + cpu_stdext_feature2 = regs[2]; + cpu_stdext_feature3 = regs[3]; + } +} + +void identify_cpu_fixup_bsp(void) { u_int regs[4]; |