Module Name: src Committed By: maxv Date: Thu Dec 12 16:49:20 UTC 2019
Modified Files: src/sys/arch/x86/x86: spectre.c Log Message: 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.31 -r1.32 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.31 src/sys/arch/x86/x86/spectre.c:1.32 --- src/sys/arch/x86/x86/spectre.c:1.31 Tue Nov 12 18:00:13 2019 +++ src/sys/arch/x86/x86/spectre.c Thu Dec 12 16:49:20 2019 @@ -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 @@ 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) {