diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2018-01-05 21:06:19 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2018-01-05 21:06:19 +0000 |
commit | 0530a9360f72fa080d17eaf96b384a79b83a6e7c (patch) | |
tree | 58fe75291f3758eda9ae880aec28df2ce80b36ac /sys/x86 | |
parent | b4f55763cef7b61acb16f1041f69669fc6c2ac02 (diff) | |
download | src-0530a9360f72fa080d17eaf96b384a79b83a6e7c.tar.gz src-0530a9360f72fa080d17eaf96b384a79b83a6e7c.zip |
Make it possible to re-evaluate cpu_features.
Add cpuctl(4) ioctl CPUCTL_EVAL_CPU_FEATURES which forces re-read of
cpu_features, cpu_features2, cpu_stdext_features, and
std_stdext_features2.
The intent is to allow the kernel to see the changes in the CPU
features after micocode update. Of course, the update is not atomic
across variables and not synchronized with readers. See the man page
warning as well.
Reviewed by: imp (previous version), jilles
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13770
Notes
Notes:
svn path=/head/; revision=327597
Diffstat (limited to 'sys/x86')
-rw-r--r-- | sys/x86/include/x86_var.h | 3 | ||||
-rw-r--r-- | sys/x86/x86/identcpu.c | 46 |
2 files changed, 28 insertions, 21 deletions
diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index 57716869584c..b996a5a0a04f 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -119,7 +119,8 @@ void cpu_setregs(void); void dump_add_page(vm_paddr_t); void dump_drop_page(vm_paddr_t); void finishidentcpu(void); -void identify_cpu(void); +void identify_cpu1(void); +void identify_cpu2(void); void identify_hypervisor(void); void initializecpu(void); void initializecpucache(void); diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c index 8d4da42c83ac..31fc7341c332 100644 --- a/sys/x86/x86/identcpu.c +++ b/sys/x86/x86/identcpu.c @@ -1385,9 +1385,8 @@ fix_cpuid(void) return (false); } -#ifdef __amd64__ void -identify_cpu(void) +identify_cpu1(void) { u_int regs[4]; @@ -1404,7 +1403,29 @@ identify_cpu(void) cpu_feature = regs[3]; cpu_feature2 = regs[2]; } -#endif + +void +identify_cpu2(void) +{ + u_int regs[4], cpu_stdext_disable; + + if (cpu_high >= 7) { + cpuid_count(7, 0, regs); + cpu_stdext_feature = regs[1]; + + /* + * Some hypervisors failed to filter out unsupported + * extended features. Allow to disable the + * extensions, activation of which requires setting a + * bit in CR4, and which VM monitors do not support. + */ + cpu_stdext_disable = 0; + TUNABLE_INT_FETCH("hw.cpu_stdext_disable", &cpu_stdext_disable); + cpu_stdext_feature &= ~cpu_stdext_disable; + + cpu_stdext_feature2 = regs[2]; + } +} /* * Final stage of CPU identification. @@ -1412,7 +1433,7 @@ identify_cpu(void) void finishidentcpu(void) { - u_int regs[4], cpu_stdext_disable; + u_int regs[4]; #ifdef __i386__ u_char ccr3; #endif @@ -1431,22 +1452,7 @@ finishidentcpu(void) cpu_mon_max_size = regs[1] & CPUID5_MON_MAX_SIZE; } - if (cpu_high >= 7) { - cpuid_count(7, 0, regs); - cpu_stdext_feature = regs[1]; - - /* - * Some hypervisors failed to filter out unsupported - * extended features. Allow to disable the - * extensions, activation of which requires setting a - * bit in CR4, and which VM monitors do not support. - */ - cpu_stdext_disable = 0; - TUNABLE_INT_FETCH("hw.cpu_stdext_disable", &cpu_stdext_disable); - cpu_stdext_feature &= ~cpu_stdext_disable; - - cpu_stdext_feature2 = regs[2]; - } + identify_cpu2(); #ifdef __i386__ if (cpu_high > 0 && |