Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86 Declare the MSR_VIA_ACE values as macros, and u...



details:   https://anonhg.NetBSD.org/src/rev/946fe219caae
branches:  trunk
changeset: 445714:946fe219caae
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Nov 10 10:52:51 2018 +0000

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

diffstat:

 sys/arch/x86/include/specialreg.h |  6 ++++--
 sys/arch/x86/x86/identcpu.c       |  9 ++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)

diffs (58 lines):

diff -r f991664b93aa -r 946fe219caae sys/arch/x86/include/specialreg.h
--- a/sys/arch/x86/include/specialreg.h Sat Nov 10 09:42:42 2018 +0000
+++ b/sys/arch/x86/include/specialreg.h Sat Nov 10 10:52:51 2018 +0000
@@ -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
diff -r f991664b93aa -r 946fe219caae sys/arch/x86/x86/identcpu.c
--- a/sys/arch/x86/x86/identcpu.c       Sat Nov 10 09:42:42 2018 +0000
+++ b/sys/arch/x86/x86/identcpu.c       Sat Nov 10 10:52:51 2018 +0000
@@ -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 @@
                 *    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 @@
 
                    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);
                    }
-
                }
        }
 



Home | Main Index | Thread Index | Old Index