Module Name:    src
Committed By:   maxv
Date:           Sat Nov 10 10:52:52 UTC 2018

Modified Files:
        src/sys/arch/x86/include: specialreg.h
        src/sys/arch/x86/x86: identcpu.c

Log Message:
Declare the MSR_VIA_ACE values as macros, and use a consistent naming,
similar to the rest of the file.

I'm wondering if I'm not fixing a huge bug here. The ECX8 value we were
using was wrong: ECX8 is bit 1, not bit 0. Bit 0 is ALTINST, an alternate
ISA, which is now known to be backdoored.

So it looks like we were explicitly enabling the backdoor.

Not tested, because I don't have a VIA cpu.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/arch/x86/include/specialreg.h
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/x86/x86/identcpu.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/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.130 src/sys/arch/x86/include/specialreg.h:1.131
--- src/sys/arch/x86/include/specialreg.h:1.130	Mon Aug 20 08:53:48 2018
+++ src/sys/arch/x86/include/specialreg.h	Sat Nov 10 10:52:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.130 2018/08/20 08:53:48 msaitoh Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.131 2018/11/10 10:52:51 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -796,7 +796,9 @@
 #define MSR_VIA_RNG_NOISE_B	0x00000100
 #define MSR_VIA_RNG_2NOISE	0x00000300
 #define MSR_VIA_ACE		0x00001107
-#define MSR_VIA_ACE_ENABLE	0x10000000
+#define 	VIA_ACE_ALTINST	0x00000001
+#define 	VIA_ACE_ECX8	0x00000002
+#define 	VIA_ACE_ENABLE	0x10000000
 
 /*
  * VIA "Eden" MSRs

Index: src/sys/arch/x86/x86/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.80 src/sys/arch/x86/x86/identcpu.c:1.81
--- src/sys/arch/x86/x86/identcpu.c:1.80	Sat Nov 10 09:42:42 2018
+++ src/sys/arch/x86/x86/identcpu.c	Sat Nov 10 10:52:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: identcpu.c,v 1.80 2018/11/10 09:42:42 maxv Exp $	*/
+/*	$NetBSD: identcpu.c,v 1.81 2018/11/10 10:52:52 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.80 2018/11/10 09:42:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.81 2018/11/10 10:52:52 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -505,7 +505,7 @@ cpu_probe_winchip(struct cpu_info *ci)
 		 *    bit in the FCR MSR.
 		 */
 		ci->ci_feat_val[0] |= CPUID_CX8;
-		wrmsr(MSR_VIA_FCR, rdmsr(MSR_VIA_FCR) | 0x00000001);
+		wrmsr(MSR_VIA_FCR, rdmsr(MSR_VIA_FCR) | VIA_ACE_ECX8);
 		break;
 	}
 }
@@ -598,9 +598,8 @@ cpu_probe_c3(struct cpu_info *ci)
 
 		    if (ace_enable) {
 			msr = rdmsr(MSR_VIA_ACE);
-			wrmsr(MSR_VIA_ACE, msr | MSR_VIA_ACE_ENABLE);
+			wrmsr(MSR_VIA_ACE, msr | VIA_ACE_ENABLE);
 		    }
-
 		}
 	}
 

Reply via email to