Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 Check CPUID.IBRS in addition to ARCH_CAP.IB...



details:   https://anonhg.NetBSD.org/src/rev/5480a1289263
branches:  trunk
changeset: 1005551:5480a1289263
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Dec 12 16:49:20 2019 +0000

description:
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).

diffstat:

 sys/arch/x86/x86/spectre.c |  22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diffs (48 lines):

diff -r 31c71b67ab41 -r 5480a1289263 sys/arch/x86/x86/spectre.c
--- a/sys/arch/x86/x86/spectre.c        Thu Dec 12 16:36:25 2019 +0000
+++ b/sys/arch/x86/x86/spectre.c        Thu Dec 12 16:49:20 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spectre.c,v 1.31 2019/11/12 18:00:13 maxv Exp $        */
+/*     $NetBSD: spectre.c,v 1.32 2019/12/12 16:49:20 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.31 2019/11/12 18:00:13 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.32 2019/12/12 16:49:20 maxv Exp $");
 
 #include "opt_spectre.h"
 
@@ -126,20 +126,20 @@
                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
                        }
-#endif
                }
                v2_mitigation_method = V2_MITIGATION_NONE;
        } else if (cpu_vendor == CPUVENDOR_AMD) {



Home | Main Index | Thread Index | Old Index