Module Name:    src
Committed By:   martin
Date:           Sat Dec 14 12:24:23 UTC 2019

Modified Files:
        src/sys/arch/x86/x86 [netbsd-9]: spectre.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #550):

        sys/arch/x86/x86/spectre.c: revision 1.32

Check CPUID.IBRS in addition to ARCH_CAP.IBRS_ALL. For clarity, and also
because VirtualBox clears the former but forgets to clear the latter (which
makes us hit a #GP on RDMSR).


To generate a diff of this commit:
cvs rdiff -u -r1.29.2.2 -r1.29.2.3 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.29.2.2 src/sys/arch/x86/x86/spectre.c:1.29.2.3
--- src/sys/arch/x86/x86/spectre.c:1.29.2.2	Tue Nov 12 18:24:37 2019
+++ src/sys/arch/x86/x86/spectre.c	Sat Dec 14 12:24:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: spectre.c,v 1.29.2.2 2019/11/12 18:24:37 martin Exp $	*/
+/*	$NetBSD: spectre.c,v 1.29.2.3 2019/12/14 12:24:23 martin Exp $	*/
 
 /*
  * Copyright (c) 2018-2019 NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.29.2.2 2019/11/12 18:24:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.29.2.3 2019/12/14 12:24:23 martin Exp $");
 
 #include "opt_spectre.h"
 
@@ -126,20 +126,20 @@ v2_detect_method(void)
 		if (cpuid_level >= 7) {
 			x86_cpuid(7, descs);
 
-			if (descs[3] & CPUID_SEF_ARCH_CAP) {
-				msr = rdmsr(MSR_IA32_ARCH_CAPABILITIES);
-				if (msr & IA32_ARCH_IBRS_ALL) {
-					v2_mitigation_method =
-					    V2_MITIGATION_INTEL_ENHANCED_IBRS;
-					return;
+			if (descs[3] & CPUID_SEF_IBRS) {
+				if (descs[3] & CPUID_SEF_ARCH_CAP) {
+					msr = rdmsr(MSR_IA32_ARCH_CAPABILITIES);
+					if (msr & IA32_ARCH_IBRS_ALL) {
+						v2_mitigation_method =
+						    V2_MITIGATION_INTEL_ENHANCED_IBRS;
+						return;
+					}
 				}
-			}
 #ifdef __x86_64__
-			if (descs[3] & CPUID_SEF_IBRS) {
 				v2_mitigation_method = V2_MITIGATION_INTEL_IBRS;
 				return;
-			}
 #endif
+			}
 		}
 		v2_mitigation_method = V2_MITIGATION_NONE;
 	} else if (cpu_vendor == CPUVENDOR_AMD) {

Reply via email to