Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Don't embed our own values in the reserved fields o...
details: https://anonhg.NetBSD.org/src/rev/da79d489f13c
branches: trunk
changeset: 357209:da79d489f13c
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Oct 31 12:02:20 2017 +0000
description:
Don't embed our own values in the reserved fields of the XSAVE area, it
really is a bad idea. Move them into the PCB.
diffstat:
sys/arch/amd64/include/pcb.h | 9 +++++----
sys/arch/i386/include/pcb.h | 9 +++++----
sys/arch/x86/include/cpu_extended_state.h | 12 +-----------
sys/arch/x86/x86/fpu.c | 16 ++++++++++------
4 files changed, 21 insertions(+), 25 deletions(-)
diffs (171 lines):
diff -r 82fe6704f49c -r da79d489f13c sys/arch/amd64/include/pcb.h
--- a/sys/arch/amd64/include/pcb.h Tue Oct 31 11:46:45 2017 +0000
+++ b/sys/arch/amd64/include/pcb.h Tue Oct 31 12:02:20 2017 +0000
@@ -1,6 +1,6 @@
-/* $NetBSD: pcb.h,v 1.26 2017/02/23 03:34:22 kamil Exp $ */
+/* $NetBSD: pcb.h,v 1.27 2017/10/31 12:02:20 maxv Exp $ */
-/*-
+/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/*-
+/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
@@ -91,9 +91,10 @@
uint64_t pcb_fs;
uint64_t pcb_gs;
struct dbreg *pcb_dbregs;
+ uint16_t pcb_fpu_dflt_cw;
int pcb_iopl;
- uint32_t pcb_unused[9]; /* unused */
+ uint32_t pcb_unused[8]; /* unused */
struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */
union savefpu pcb_savefpu __aligned(64); /* floating point state */
diff -r 82fe6704f49c -r da79d489f13c sys/arch/i386/include/pcb.h
--- a/sys/arch/i386/include/pcb.h Tue Oct 31 11:46:45 2017 +0000
+++ b/sys/arch/i386/include/pcb.h Tue Oct 31 12:02:20 2017 +0000
@@ -1,6 +1,6 @@
-/* $NetBSD: pcb.h,v 1.56 2017/08/12 12:48:47 maxv Exp $ */
+/* $NetBSD: pcb.h,v 1.57 2017/10/31 12:02:20 maxv Exp $ */
-/*-
+/*
* Copyright (c) 1998, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/*-
+/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
@@ -91,8 +91,9 @@
void *pcb_onfault; /* copyin/out fault recovery */
char *pcb_iomap; /* I/O permission bitmap */
struct dbreg *pcb_dbregs; /* CPU Debug Registers */
+ uint16_t pcb_fpu_dflt_cw;
- int not_used[17];
+ int not_used[16];
/* floating point state */
struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */
diff -r 82fe6704f49c -r da79d489f13c sys/arch/x86/include/cpu_extended_state.h
--- a/sys/arch/x86/include/cpu_extended_state.h Tue Oct 31 11:46:45 2017 +0000
+++ b/sys/arch/x86/include/cpu_extended_state.h Tue Oct 31 12:02:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_extended_state.h,v 1.12 2017/10/31 10:39:13 maxv Exp $ */
+/* $NetBSD: cpu_extended_state.h,v 1.13 2017/10/31 12:02:20 maxv Exp $ */
#ifndef _X86_CPU_EXTENDED_STATE_H_
#define _X86_CPU_EXTENDED_STATE_H_
@@ -120,15 +120,6 @@
__CTASSERT_NOLINT(sizeof(struct fxsave) == 512);
/*
- * The end of the fsave buffer can be used by the operating system
- */
-struct fxsave_os {
- uint8_t fxo_fxsave[512 - 48];
- /* 48 bytes available, NB copied to/from userspace */
- uint16_t fxo_dflt_cw; /* Control word for signal handlers */
-};
-
-/*
* For XSAVE, a 64byte header follows the fxsave data.
*/
struct xsave_header {
@@ -158,7 +149,6 @@
struct save87 sv_87;
struct fxsave sv_xmm;
#ifdef _KERNEL
- struct fxsave_os sv_os;
struct xsave_header sv_xsave_hdr;
#endif
};
diff -r 82fe6704f49c -r da79d489f13c sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c Tue Oct 31 11:46:45 2017 +0000
+++ b/sys/arch/x86/x86/fpu.c Tue Oct 31 12:02:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.16 2017/10/31 11:37:05 maxv Exp $ */
+/* $NetBSD: fpu.c,v 1.17 2017/10/31 12:02:20 maxv Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc. All
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.16 2017/10/31 11:37:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.17 2017/10/31 12:02:20 maxv Exp $");
#include "opt_multiprocessor.h"
@@ -493,21 +493,24 @@
fpu_set_default_cw(struct lwp *l, unsigned int x87_cw)
{
union savefpu *fpu_save = process_fpframe(l);
+ struct pcb *pcb = lwp_getpcb(l);
if (i386_use_fxsave)
fpu_save->sv_xmm.fx_cw = x87_cw;
else
fpu_save->sv_87.s87_cw = x87_cw;
- fpu_save->sv_os.fxo_dflt_cw = x87_cw;
+ pcb->pcb_fpu_dflt_cw = x87_cw;
}
void
fpu_save_area_clear(struct lwp *l, unsigned int x87_cw)
{
union savefpu *fpu_save;
+ struct pcb *pcb;
fpusave_lwp(l, false);
fpu_save = process_fpframe(l);
+ pcb = lwp_getpcb(l);
if (i386_use_fxsave) {
memset(&fpu_save->sv_xmm, 0, x86_fpu_save_size);
@@ -519,13 +522,14 @@
fpu_save->sv_87.s87_tw = 0xffff;
fpu_save->sv_87.s87_cw = x87_cw;
}
- fpu_save->sv_os.fxo_dflt_cw = x87_cw;
+ pcb->pcb_fpu_dflt_cw = x87_cw;
}
void
fpu_save_area_reset(struct lwp *l)
{
union savefpu *fpu_save = process_fpframe(l);
+ struct pcb *pcb = lwp_getpcb(l);
/*
* For signal handlers the register values don't matter. Just reset
@@ -535,10 +539,10 @@
fpu_save->sv_xmm.fx_mxcsr = __INITIAL_MXCSR__;
fpu_save->sv_xmm.fx_mxcsr_mask = __INITIAL_MXCSR_MASK__;
fpu_save->sv_xmm.fx_tw = 0;
- fpu_save->sv_xmm.fx_cw = fpu_save->sv_os.fxo_dflt_cw;
+ fpu_save->sv_xmm.fx_cw = pcb->pcb_fpu_dflt_cw;
} else {
fpu_save->sv_87.s87_tw = 0xffff;
- fpu_save->sv_87.s87_cw = fpu_save->sv_os.fxo_dflt_cw;
+ fpu_save->sv_87.s87_cw = pcb->pcb_fpu_dflt_cw;
}
}
Home |
Main Index |
Thread Index |
Old Index