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 Changing CR4 register may change cpuid valu...



details:   https://anonhg.NetBSD.org/src/rev/9f70466adbd9
branches:  trunk
changeset: 828949:9f70466adbd9
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Jan 11 09:18:16 2018 +0000

description:
Changing CR4 register may change cpuid values. For example, setting
CR4_OSXSAVE sets CPUID2_OSXSAVE. The CPUID2_OSXSAVE is in ci_feat_val[1],
so update it after changing CR4.

diffstat:

 sys/arch/x86/x86/cpu.c |  17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r b99eff514836 -r 9f70466adbd9 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Thu Jan 11 09:00:04 2018 +0000
+++ b/sys/arch/x86/x86/cpu.c    Thu Jan 11 09:18:16 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.144 2018/01/07 16:10:16 maxv Exp $   */
+/*     $NetBSD: cpu.c,v 1.145 2018/01/11 09:18:16 msaitoh Exp $        */
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.144 2018/01/07 16:10:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.145 2018/01/11 09:18:16 msaitoh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -623,6 +623,19 @@
                lcr4(cr4);
        }
 
+       /*
+        * Changing CR4 register may change cpuid values. For example, setting
+        * CR4_OSXSAVE sets CPUID2_OSXSAVE. The CPUID2_OSXSAVE is in
+        * ci_feat_val[1], so update it.
+        * XXX Other than ci_feat_val[1] might be changed.
+        */
+       if (cpuid_level >= 1) {
+               u_int descs[4];
+
+               x86_cpuid(1, descs);
+               ci->ci_feat_val[1] = descs[2];
+       }
+
        if (x86_fpu_save >= FPU_SAVE_FXSAVE) {
                fpuinit_mxcsr_mask();
        }



Home | Main Index | Thread Index | Old Index