Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/amd64 Move the two fields used to save some i387 st...
details: https://anonhg.NetBSD.org/src/rev/eb5b041bbcfe
branches: trunk
changeset: 783608:eb5b041bbcfe
user: dsl <dsl%NetBSD.org@localhost>
date: Mon Dec 31 16:20:17 2012 +0000
description:
Move the two fields used to save some i387 state on the last fpu trap
into their own sub-structure of the pcb (from 'struct savefpu').
They only (seem) to be used in some code that generates core dumps
for 32bit processes (code that might be broken as well!).
'struct safefpu' is now identical to 'struct fxsave64'. One (or both)
needs extending to support AVX - might need to be dynamically sized.
Removed all the __aligned(16) except for the one in struct pcb itself.
Only the copy used for the fsave instruction need be aligned.
diffstat:
sys/arch/amd64/amd64/fpu.c | 9 +++++----
sys/arch/amd64/amd64/netbsd32_machdep.c | 9 ++++-----
sys/arch/amd64/include/fpu.h | 12 ++++++++----
sys/arch/amd64/include/pcb.h | 10 ++++------
4 files changed, 21 insertions(+), 19 deletions(-)
diffs (146 lines):
diff -r ef4a65ac6fb2 -r eb5b041bbcfe sys/arch/amd64/amd64/fpu.c
--- a/sys/arch/amd64/amd64/fpu.c Mon Dec 31 16:05:39 2012 +0000
+++ b/sys/arch/amd64/amd64/fpu.c Mon Dec 31 16:20:17 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.39 2012/07/08 20:14:11 dsl Exp $ */
+/* $NetBSD: fpu.c,v 1.40 2012/12/31 16:20:17 dsl Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. All
@@ -100,7 +100,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.39 2012/07/08 20:14:11 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.40 2012/12/31 16:20:17 dsl Exp $");
#include "opt_multiprocessor.h"
@@ -194,6 +194,9 @@
*/
KASSERT(l == curlwp);
fxsave(sfp);
+ pcb->pcb_savefpu_i387.fp_ex_tw = sfp->fp_fxsave.fx_ftw;
+ pcb->pcb_savefpu_i387.fp_ex_sw = sfp->fp_fxsave.fx_fsw;
+
if (frame->tf_trapno == T_XMM) {
mxcsr = sfp->fp_fxsave.fx_mxcsr;
statbits = mxcsr;
@@ -209,8 +212,6 @@
}
KPREEMPT_ENABLE(l);
- sfp->fp_ex_tw = sfp->fp_fxsave.fx_ftw;
- sfp->fp_ex_sw = sfp->fp_fxsave.fx_fsw;
KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGFPE;
ksi.ksi_addr = (void *)frame->tf_rip;
diff -r ef4a65ac6fb2 -r eb5b041bbcfe sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c Mon Dec 31 16:05:39 2012 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c Mon Dec 31 16:20:17 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.79 2012/07/15 15:17:56 dsl Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.80 2012/12/31 16:20:17 dsl Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.79 2012/07/15 15:17:56 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.80 2012/12/31 16:20:17 dsl Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -568,7 +568,6 @@
netbsd32_process_read_fpregs(struct lwp *l, struct fpreg32 *regs)
{
struct pcb *pcb = lwp_getpcb(l);
- struct savefpu *sf = &pcb->pcb_savefpu;
struct fpreg regs64;
struct save87 *s87 = (struct save87 *)regs;
int error, i;
@@ -598,13 +597,13 @@
s87->sv_ex_tw |=
(xmm_to_s87_tag((uint8_t *)®s64.fxstate.fx_st[i][0], i,
- sf->fp_ex_tw) << (i * 2));
+ pcb->pcb_savefpu_i387.fp_ex_tw) << (i * 2));
memcpy(&s87->sv_ac[i].fp_bytes, ®s64.fxstate.fx_st[i][0],
sizeof(s87->sv_ac[i].fp_bytes));
}
- s87->sv_ex_sw = sf->fp_ex_sw;
+ s87->sv_ex_sw = pcb->pcb_savefpu_i387.fp_ex_sw;
return (0);
}
diff -r ef4a65ac6fb2 -r eb5b041bbcfe sys/arch/amd64/include/fpu.h
--- a/sys/arch/amd64/include/fpu.h Mon Dec 31 16:05:39 2012 +0000
+++ b/sys/arch/amd64/include/fpu.h Mon Dec 31 16:20:17 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.h,v 1.6 2012/12/15 21:50:43 dsl Exp $ */
+/* $NetBSD: fpu.h,v 1.7 2012/12/31 16:20:17 dsl Exp $ */
#ifndef _AMD64_FPU_H_
#define _AMD64_FPU_H_
@@ -7,7 +7,9 @@
* NetBSD/amd64 only uses the extended save/restore format used
* by fxsave/fsrestore, to always deal with the SSE registers,
* which are part of the ABI to pass floating point values.
- * Must be stored in memory on a 16-byte boundary.
+ *
+ * The memory used for the 'fsave' instruction must be 16 byte aligned,
+ * but the definition here isn't aligned to avoid padding elsewhere.
*/
struct fxsave64 {
@@ -30,10 +32,12 @@
struct savefpu {
struct fxsave64 fp_fxsave; /* see above */
+};
+
+struct savefpu_i387 {
uint16_t fp_ex_sw; /* saved status from last exception */
uint16_t fp_ex_tw; /* saved tag from last exception */
-} __aligned(16);
-
+};
/*
* The i387 defaults to Intel extended precision mode and round to nearest,
diff -r ef4a65ac6fb2 -r eb5b041bbcfe sys/arch/amd64/include/pcb.h
--- a/sys/arch/amd64/include/pcb.h Mon Dec 31 16:05:39 2012 +0000
+++ b/sys/arch/amd64/include/pcb.h Mon Dec 31 16:20:17 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcb.h,v 1.17 2010/07/07 01:14:52 chs Exp $ */
+/* $NetBSD: pcb.h,v 1.18 2012/12/31 16:20:17 dsl Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -81,10 +81,6 @@
#define NIOPORTS 1024 /* # of ports we allow to be mapped */
-/*
- * Please note that the pcb_savefpu field in struct below must be
- * on a 16-byte boundary.
- */
struct pcb {
int pcb_flags;
#define PCB_USER_LDT 0x01 /* has user-set LDT */
@@ -96,8 +92,10 @@
uint64_t pcb_rsp;
uint64_t pcb_rbp;
uint64_t pcb_usersp;
- uint64_t pcb_unused; /* unused */
+ uint32_t pcb_unused; /* unused */
+ struct savefpu_i387 pcb_savefpu_i387; /* i387 status on last exception */
struct savefpu pcb_savefpu __aligned(16); /* floating point state */
+ uint32_t pcb_unused_1[4]; /* unused */
void *pcb_onfault; /* copyin/out fault recovery */
struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */
uint64_t pcb_fs;
Home |
Main Index |
Thread Index |
Old Index