Module Name: src
Committed By: maxv
Date: Sat Jun 1 06:54:28 UTC 2019
Modified Files:
src/sys/arch/x86/x86: spectre.c
Log Message:
Mmh, check the highest leaf before calling x86_cpuid(), otherwise on old
CPUs we might be getting garbage. While here fix a typo.
Likely fixes PR/54256.
To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/x86/x86/spectre.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/x86/spectre.c
diff -u src/sys/arch/x86/x86/spectre.c:1.28 src/sys/arch/x86/x86/spectre.c:1.29
--- src/sys/arch/x86/x86/spectre.c:1.28 Sat May 18 08:54:38 2019
+++ src/sys/arch/x86/x86/spectre.c Sat Jun 1 06:54:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: spectre.c,v 1.28 2019/05/18 08:54:38 maxv Exp $ */
+/* $NetBSD: spectre.c,v 1.29 2019/06/01 06:54:28 maxv Exp $ */
/*
* Copyright (c) 2018-2019 NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.28 2019/05/18 08:54:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.29 2019/06/01 06:54:28 maxv Exp $");
#include "opt_spectre.h"
@@ -673,6 +673,10 @@ mds_detect_method(void)
return;
}
+ if (cpuid_level < 7) {
+ return;
+ }
+
x86_cpuid(0x7, descs);
if (descs[3] & CPUID_SEF_ARCH_CAP) {
msr = rdmsr(MSR_IA32_ARCH_CAPABILITIES);
@@ -850,7 +854,7 @@ cpu_speculation_init(struct cpu_info *ci
#endif
/*
- * Microarchectural Data Sampling.
+ * Microarchitectural Data Sampling.
*
* cpu0 is the one that detects the method and sets the global
* variable.