git: 050f5a8405c6 - main - amd64: Reload CPU ext features after resume or cr4 changes
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 29 Jun 2022 07:39:05 UTC
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=050f5a8405c63dadaf522d27c3d4f2a2ae522bf6 commit 050f5a8405c63dadaf522d27c3d4f2a2ae522bf6 Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2022-06-29 07:34:43 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2022-06-29 07:34:43 +0000 amd64: Reload CPU ext features after resume or cr4 changes Reviewed by: kib Differential revision: https://reviews.freebsd.org/D35555 MFC after: 2 weeks --- sys/amd64/amd64/initcpu.c | 3 +++ sys/x86/include/x86_var.h | 1 + sys/x86/x86/identcpu.c | 12 ++++++++++++ 3 files changed, 16 insertions(+) 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 @@ -1608,6 +1608,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) {