Fri Jun 22 06:22:37 2018 UTC ()
Revert jdolecek's changes related to FXSAVE. They just didn't make any
sense and were trying to hide a real bug, which is, that there is for some
reason a wrong stack alignment that causes FXSAVE to fault in
fpuinit_mxcsr_mask. As seen in current-users@ yesterday, rdi % 16 = 8. And
as seen several months ago, as well.

The rest of the changes in XSAVE are wrong too, but I'll let him fix these
ones.


(maxv)
diff -r1.11 -r1.12 src/sys/arch/x86/include/fpu.h
diff -r1.157 -r1.158 src/sys/arch/x86/x86/cpu.c
diff -r1.41 -r1.42 src/sys/arch/x86/x86/fpu.c
diff -r1.119 -r1.120 src/sys/arch/xen/x86/cpu.c

cvs diff -r1.11 -r1.12 src/sys/arch/x86/include/fpu.h (expand / switch to unified diff)

--- src/sys/arch/x86/include/fpu.h 2018/06/20 20:43:20 1.11
+++ src/sys/arch/x86/include/fpu.h 2018/06/22 06:22:37 1.12
@@ -1,28 +1,28 @@ @@ -1,28 +1,28 @@
1/* $NetBSD: fpu.h,v 1.11 2018/06/20 20:43:20 jdolecek Exp $ */ 1/* $NetBSD: fpu.h,v 1.12 2018/06/22 06:22:37 maxv Exp $ */
2 2
3#ifndef _X86_FPU_H_ 3#ifndef _X86_FPU_H_
4#define _X86_FPU_H_ 4#define _X86_FPU_H_
5 5
6#include <x86/cpu_extended_state.h> 6#include <x86/cpu_extended_state.h>
7 7
8#ifdef _KERNEL 8#ifdef _KERNEL
9 9
10struct cpu_info; 10struct cpu_info;
11struct lwp; 11struct lwp;
12struct trapframe; 12struct trapframe;
13 13
14void fpuinit(struct cpu_info *); 14void fpuinit(struct cpu_info *);
15void fpuinit_mxcsr_mask(bool); 15void fpuinit_mxcsr_mask(void);
16void fpusave_lwp(struct lwp *, bool); 16void fpusave_lwp(struct lwp *, bool);
17void fpusave_cpu(bool); 17void fpusave_cpu(bool);
18 18
19void fpu_eagerswitch(struct lwp *, struct lwp *); 19void fpu_eagerswitch(struct lwp *, struct lwp *);
20 20
21void fpu_set_default_cw(struct lwp *, unsigned int); 21void fpu_set_default_cw(struct lwp *, unsigned int);
22 22
23void fputrap(struct trapframe *); 23void fputrap(struct trapframe *);
24void fpudna(struct trapframe *); 24void fpudna(struct trapframe *);
25 25
26/* Set all to defaults (eg during exec) */ 26/* Set all to defaults (eg during exec) */
27void fpu_save_area_clear(struct lwp *, unsigned int); 27void fpu_save_area_clear(struct lwp *, unsigned int);
28/* Reset control words only - for signal handlers */ 28/* Reset control words only - for signal handlers */

cvs diff -r1.157 -r1.158 src/sys/arch/x86/x86/cpu.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/cpu.c 2018/06/20 20:43:21 1.157
+++ src/sys/arch/x86/x86/cpu.c 2018/06/22 06:22:37 1.158
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpu.c,v 1.157 2018/06/20 20:43:21 jdolecek Exp $ */ 1/* $NetBSD: cpu.c,v 1.158 2018/06/22 06:22:37 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000-2012 NetBSD Foundation, Inc. 4 * Copyright (c) 2000-2012 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 Bill Sommerfeld of RedBack Networks Inc, and by Andrew Doran. 8 * by Bill Sommerfeld of RedBack Networks Inc, and by Andrew Doran.
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.
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE 54 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 * SUCH DAMAGE. 61 * SUCH DAMAGE.
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.157 2018/06/20 20:43:21 jdolecek Exp $"); 65__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.158 2018/06/22 06:22:37 maxv Exp $");
66 66
67#include "opt_ddb.h" 67#include "opt_ddb.h"
68#include "opt_mpbios.h" /* for MPDEBUG */ 68#include "opt_mpbios.h" /* for MPDEBUG */
69#include "opt_mtrr.h" 69#include "opt_mtrr.h"
70#include "opt_multiprocessor.h" 70#include "opt_multiprocessor.h"
71#include "opt_svs.h" 71#include "opt_svs.h"
72 72
73#include "lapic.h" 73#include "lapic.h"
74#include "ioapic.h" 74#include "ioapic.h"
75 75
76#include <sys/param.h> 76#include <sys/param.h>
77#include <sys/proc.h> 77#include <sys/proc.h>
78#include <sys/systm.h> 78#include <sys/systm.h>
@@ -628,27 +628,27 @@ cpu_init(struct cpu_info *ci) @@ -628,27 +628,27 @@ cpu_init(struct cpu_info *ci)
628 * Changing CR4 register may change cpuid values. For example, setting 628 * Changing CR4 register may change cpuid values. For example, setting
629 * CR4_OSXSAVE sets CPUID2_OSXSAVE. The CPUID2_OSXSAVE is in 629 * CR4_OSXSAVE sets CPUID2_OSXSAVE. The CPUID2_OSXSAVE is in
630 * ci_feat_val[1], so update it. 630 * ci_feat_val[1], so update it.
631 * XXX Other than ci_feat_val[1] might be changed. 631 * XXX Other than ci_feat_val[1] might be changed.
632 */ 632 */
633 if (cpuid_level >= 1) { 633 if (cpuid_level >= 1) {
634 u_int descs[4]; 634 u_int descs[4];
635 635
636 x86_cpuid(1, descs); 636 x86_cpuid(1, descs);
637 ci->ci_feat_val[1] = descs[2]; 637 ci->ci_feat_val[1] = descs[2];
638 } 638 }
639 639
640 if (x86_fpu_save >= FPU_SAVE_FXSAVE) { 640 if (x86_fpu_save >= FPU_SAVE_FXSAVE) {
641 fpuinit_mxcsr_mask(true); 641 fpuinit_mxcsr_mask();
642 } 642 }
643 643
644 /* If xsave is enabled, enable all fpu features */ 644 /* If xsave is enabled, enable all fpu features */
645 if (cr4 & CR4_OSXSAVE) 645 if (cr4 & CR4_OSXSAVE)
646 wrxcr(0, x86_xsave_features & XCR0_FPU); 646 wrxcr(0, x86_xsave_features & XCR0_FPU);
647 647
648#ifdef MTRR 648#ifdef MTRR
649 /* 649 /*
650 * On a P6 or above, initialize MTRR's if the hardware supports them. 650 * On a P6 or above, initialize MTRR's if the hardware supports them.
651 */ 651 */
652 if (cpu_feature[0] & CPUID_MTRR) { 652 if (cpu_feature[0] & CPUID_MTRR) {
653 if ((ci->ci_flags & CPUF_AP) == 0) 653 if ((ci->ci_flags & CPUF_AP) == 0)
654 i686_mtrr_init_first(); 654 i686_mtrr_init_first();

cvs diff -r1.41 -r1.42 src/sys/arch/x86/x86/fpu.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/fpu.c 2018/06/20 20:43:21 1.41
+++ src/sys/arch/x86/x86/fpu.c 2018/06/22 06:22:37 1.42
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fpu.c,v 1.41 2018/06/20 20:43:21 jdolecek Exp $ */ 1/* $NetBSD: fpu.c,v 1.42 2018/06/22 06:22:37 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. All 4 * Copyright (c) 2008 The NetBSD Foundation, Inc. All
5 * rights reserved. 5 * rights reserved.
6 * 6 *
7 * This code is derived from software developed for The NetBSD Foundation 7 * This code is derived from software developed for The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
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.
@@ -86,27 +86,27 @@ @@ -86,27 +86,27 @@
86 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 86 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
87 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 87 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
88 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 88 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
89 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 89 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
90 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 90 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
91 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 91 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
92 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 92 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
93 * SUCH DAMAGE. 93 * SUCH DAMAGE.
94 * 94 *
95 * @(#)npx.c 7.2 (Berkeley) 5/12/91 95 * @(#)npx.c 7.2 (Berkeley) 5/12/91
96 */ 96 */
97 97
98#include <sys/cdefs.h> 98#include <sys/cdefs.h>
99__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.41 2018/06/20 20:43:21 jdolecek Exp $"); 99__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.42 2018/06/22 06:22:37 maxv Exp $");
100 100
101#include "opt_multiprocessor.h" 101#include "opt_multiprocessor.h"
102 102
103#include <sys/param.h> 103#include <sys/param.h>
104#include <sys/systm.h> 104#include <sys/systm.h>
105#include <sys/conf.h> 105#include <sys/conf.h>
106#include <sys/cpu.h> 106#include <sys/cpu.h>
107#include <sys/file.h> 107#include <sys/file.h>
108#include <sys/proc.h> 108#include <sys/proc.h>
109#include <sys/kernel.h> 109#include <sys/kernel.h>
110#include <sys/sysctl.h> 110#include <sys/sysctl.h>
111#include <sys/xcall.h> 111#include <sys/xcall.h>
112 112
@@ -227,56 +227,54 @@ static const uint8_t fpetable[128] = { @@ -227,56 +227,54 @@ static const uint8_t fpetable[128] = {
227void 227void
228fpuinit(struct cpu_info *ci) 228fpuinit(struct cpu_info *ci)
229{ 229{
230 230
231 clts(); 231 clts();
232 fninit(); 232 fninit();
233 stts(); 233 stts();
234} 234}
235 235
236/* 236/*
237 * Get the value of MXCSR_MASK supported by the CPU. 237 * Get the value of MXCSR_MASK supported by the CPU.
238 */ 238 */
239void 239void
240fpuinit_mxcsr_mask(bool has_fxsave) 240fpuinit_mxcsr_mask(void)
241{ 241{
242 242#ifndef XEN
243 if (!has_fxsave) { 
244 x86_fpu_mxcsr_mask = __INITIAL_MXCSR_MASK__; 
245 return; 
246 } 
247 
248 union savefpu fpusave __aligned(16); 243 union savefpu fpusave __aligned(16);
249 u_long psl; 244 u_long psl;
250 245
251 memset(&fpusave, 0, sizeof(fpusave)); 246 memset(&fpusave, 0, sizeof(fpusave));
252 247
253 /* Disable interrupts, and enable FPU */ 248 /* Disable interrupts, and enable FPU */
254 psl = x86_read_psl(); 249 psl = x86_read_psl();
255 x86_disable_intr(); 250 x86_disable_intr();
256 clts(); 251 clts();
257 252
258 /* Fill in the FPU area */ 253 /* Fill in the FPU area */
259 fxsave(&fpusave); 254 fxsave(&fpusave);
260 255
261 /* Restore previous state */ 256 /* Restore previous state */
262 stts(); 257 stts();
263 x86_write_psl(psl); 258 x86_write_psl(psl);
264 259
265 if (fpusave.sv_xmm.fx_mxcsr_mask == 0) { 260 if (fpusave.sv_xmm.fx_mxcsr_mask == 0) {
266 x86_fpu_mxcsr_mask = __INITIAL_MXCSR_MASK__; 261 x86_fpu_mxcsr_mask = __INITIAL_MXCSR_MASK__;
267 } else { 262 } else {
268 x86_fpu_mxcsr_mask = fpusave.sv_xmm.fx_mxcsr_mask; 263 x86_fpu_mxcsr_mask = fpusave.sv_xmm.fx_mxcsr_mask;
269 } 264 }
 265#else
 266 x86_fpu_mxcsr_mask = __INITIAL_MXCSR_MASK__;
 267#endif
270} 268}
271 269
272static void 270static void
273fpu_clear_amd(void) 271fpu_clear_amd(void)
274{ 272{
275 /* 273 /*
276 * AMD FPUs do not restore FIP, FDP, and FOP on fxrstor and xrstor 274 * AMD FPUs do not restore FIP, FDP, and FOP on fxrstor and xrstor
277 * when FSW.ES=0, leaking other threads' execution history. 275 * when FSW.ES=0, leaking other threads' execution history.
278 * 276 *
279 * Clear them manually by loading a zero (fldummy). We do this 277 * Clear them manually by loading a zero (fldummy). We do this
280 * unconditionally, regardless of FSW.ES. 278 * unconditionally, regardless of FSW.ES.
281 * 279 *
282 * Before that, clear the ES bit in the x87 status word if it is 280 * Before that, clear the ES bit in the x87 status word if it is

cvs diff -r1.119 -r1.120 src/sys/arch/xen/x86/cpu.c (expand / switch to unified diff)

--- src/sys/arch/xen/x86/cpu.c 2018/06/20 20:43:20 1.119
+++ src/sys/arch/xen/x86/cpu.c 2018/06/22 06:22:37 1.120
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpu.c,v 1.119 2018/06/20 20:43:20 jdolecek Exp $ */ 1/* $NetBSD: cpu.c,v 1.120 2018/06/22 06:22:37 maxv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, 5 * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by RedBack Networks Inc. 9 * by RedBack Networks Inc.
10 * 10 *
11 * Author: Bill Sommerfeld 11 * Author: Bill Sommerfeld
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions 14 * modification, are permitted provided that the following conditions
@@ -55,27 +55,27 @@ @@ -55,27 +55,27 @@
55 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 55 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE 57 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE. 64 * SUCH DAMAGE.
65 */ 65 */
66 66
67#include <sys/cdefs.h> 67#include <sys/cdefs.h>
68__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.119 2018/06/20 20:43:20 jdolecek Exp $"); 68__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.120 2018/06/22 06:22:37 maxv Exp $");
69 69
70#include "opt_ddb.h" 70#include "opt_ddb.h"
71#include "opt_multiprocessor.h" 71#include "opt_multiprocessor.h"
72#include "opt_mpbios.h" /* for MPDEBUG */ 72#include "opt_mpbios.h" /* for MPDEBUG */
73#include "opt_mtrr.h" 73#include "opt_mtrr.h"
74#include "opt_xen.h" 74#include "opt_xen.h"
75 75
76#include "lapic.h" 76#include "lapic.h"
77#include "ioapic.h" 77#include "ioapic.h"
78 78
79#include <sys/param.h> 79#include <sys/param.h>
80#include <sys/proc.h> 80#include <sys/proc.h>
81#include <sys/systm.h> 81#include <sys/systm.h>
@@ -554,28 +554,27 @@ cpu_init(struct cpu_info *ci) @@ -554,28 +554,27 @@ cpu_init(struct cpu_info *ci)
554 if (cpu_feature[1] & CPUID2_OSXSAVE) 554 if (cpu_feature[1] & CPUID2_OSXSAVE)
555 cr4 |= CR4_OSXSAVE; 555 cr4 |= CR4_OSXSAVE;
556 else { 556 else {
557 x86_xsave_features = 0; 557 x86_xsave_features = 0;
558 x86_fpu_save = FPU_SAVE_FXSAVE; 558 x86_fpu_save = FPU_SAVE_FXSAVE;
559 } 559 }
560 560
561 if (cr4) { 561 if (cr4) {
562 cr4 |= rcr4(); 562 cr4 |= rcr4();
563 lcr4(cr4); 563 lcr4(cr4);
564 } 564 }
565 565
566 if (x86_fpu_save >= FPU_SAVE_FXSAVE) { 566 if (x86_fpu_save >= FPU_SAVE_FXSAVE) {
567 /* XXX fxsave() faults on Xen with no-xsave flag, why? */ 567 fpuinit_mxcsr_mask();
568 fpuinit_mxcsr_mask((cr4 & CR4_OSXSAVE) != 0); 
569 } 568 }
570 569
571 /* 570 /*
572 * Changing CR4 register may change cpuid values. For example, setting 571 * Changing CR4 register may change cpuid values. For example, setting
573 * CR4_OSXSAVE sets CPUID2_OSXSAVE. The CPUID2_OSXSAVE is in 572 * CR4_OSXSAVE sets CPUID2_OSXSAVE. The CPUID2_OSXSAVE is in
574 * ci_feat_val[1], so update it. 573 * ci_feat_val[1], so update it.
575 * XXX Other than ci_feat_val[1] might be changed. 574 * XXX Other than ci_feat_val[1] might be changed.
576 */ 575 */
577 if (cpuid_level >= 1) { 576 if (cpuid_level >= 1) {
578 u_int descs[4]; 577 u_int descs[4];
579 578
580 x86_cpuid(1, descs); 579 x86_cpuid(1, descs);
581 ci->ci_feat_val[1] = descs[2]; 580 ci->ci_feat_val[1] = descs[2];