Fri Aug 30 13:29:17 2019 UTC ()
 Use macro.


(msaitoh)
diff -r1.29 -r1.30 src/sys/arch/x86/x86/spectre.c

cvs diff -r1.29 -r1.30 src/sys/arch/x86/x86/spectre.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/spectre.c 2019/06/01 06:54:28 1.29
+++ src/sys/arch/x86/x86/spectre.c 2019/08/30 13:29:17 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: spectre.c,v 1.29 2019/06/01 06:54:28 maxv Exp $ */ 1/* $NetBSD: spectre.c,v 1.30 2019/08/30 13:29:17 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2018-2019 NetBSD Foundation, Inc. 4 * Copyright (c) 2018-2019 NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Maxime Villard. 8 * by Maxime Villard.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * Mitigations for the SpectreV2, SpectreV4 and MDS CPU flaws. 33 * Mitigations for the SpectreV2, SpectreV4 and MDS CPU flaws.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.29 2019/06/01 06:54:28 maxv Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.30 2019/08/30 13:29:17 msaitoh Exp $");
38 38
39#include "opt_spectre.h" 39#include "opt_spectre.h"
40 40
41#include <sys/param.h> 41#include <sys/param.h>
42#include <sys/systm.h> 42#include <sys/systm.h>
43#include <sys/cpu.h> 43#include <sys/cpu.h>
44#include <sys/sysctl.h> 44#include <sys/sysctl.h>
45#include <sys/xcall.h> 45#include <sys/xcall.h>
46 46
47#include <machine/cpufunc.h> 47#include <machine/cpufunc.h>
48#include <machine/cpuvar.h> 48#include <machine/cpuvar.h>
49#include <machine/specialreg.h> 49#include <machine/specialreg.h>
50#include <machine/frameasm.h> 50#include <machine/frameasm.h>
@@ -425,27 +425,27 @@ v4_detect_method(void) @@ -425,27 +425,27 @@ v4_detect_method(void)
425 v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F15H; 425 v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F15H;
426 return; 426 return;
427 case 0x16: 427 case 0x16:
428 v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F16H; 428 v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F16H;
429 return; 429 return;
430 case 0x17: 430 case 0x17:
431 v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F17H; 431 v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F17H;
432 return; 432 return;
433 default: 433 default:
434 if (cpu_info_primary.ci_max_ext_cpuid < 0x80000008) { 434 if (cpu_info_primary.ci_max_ext_cpuid < 0x80000008) {
435 break; 435 break;
436 } 436 }
437 x86_cpuid(0x80000008, descs); 437 x86_cpuid(0x80000008, descs);
438 if (descs[1] & __BIT(26)) { 438 if (descs[1] & CPUID_CAPEX_SSB_NO) {
439 /* Not vulnerable to SpectreV4. */ 439 /* Not vulnerable to SpectreV4. */
440 v4_mitigation_method = V4_MITIGATION_AMD_SSB_NO; 440 v4_mitigation_method = V4_MITIGATION_AMD_SSB_NO;
441 return; 441 return;
442 } 442 }
443 443
444 break; 444 break;
445 } 445 }
446 } 446 }
447 447
448 v4_mitigation_method = V4_MITIGATION_NONE; 448 v4_mitigation_method = V4_MITIGATION_NONE;
449} 449}
450 450
451static void 451static void