Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Convert the amd64 build to use x86/cpu_extended_state.h ...
details: https://anonhg.NetBSD.org/src/rev/b8b2993aa515
branches: trunk
changeset: 326625:b8b2993aa515
user: dsl <dsl%NetBSD.org@localhost>
date: Fri Feb 07 22:40:22 2014 +0000
description:
Convert the amd64 build to use x86/cpu_extended_state.h so that the fpu
definitions match those of i386.
Mostly just structure and field renames, in addition:
1) process_xmm_to_s87() and process_s87_to_xmm() moved into
x86/convert_xmm_s87.c so they can be used by amd64's netbsd32 code.
2) The linux signal code simplified to use a structure copy for ths fxsave
data - it matches the hardware definition and won't change.
diffstat:
sys/arch/amd64/amd64/fpu.c | 16 +-
sys/arch/amd64/amd64/machdep.c | 16 +-
sys/arch/amd64/amd64/netbsd32_machdep.c | 100 ++-------------
sys/arch/amd64/amd64/process_machdep.c | 22 +-
sys/arch/amd64/conf/files.amd64 | 3 +-
sys/arch/amd64/include/fpu.h | 65 +---------
sys/arch/amd64/include/netbsd32_machdep.h | 29 +----
sys/arch/amd64/include/pcb.h | 4 +-
sys/arch/amd64/include/reg.h | 21 +--
sys/arch/i386/conf/files.i386 | 3 +-
sys/arch/i386/i386/process_machdep.c | 121 +------------------
sys/arch/i386/include/npx.h | 4 +-
sys/arch/x86/include/cpu_extended_state.h | 10 +-
sys/arch/x86/x86/convert_xmm_s87.c | 155 ++++++++++++++++++++++++
sys/arch/xen/conf/files.xen | 3 +-
sys/compat/linux/arch/amd64/linux_machdep.c | 51 ++-----
sys/compat/linux/arch/amd64/linux_machdep.h | 4 +-
sys/compat/linux32/arch/amd64/linux32_machdep.c | 10 +-
18 files changed, 240 insertions(+), 397 deletions(-)
diffs (truncated from 1107 to 300 lines):
diff -r 087a59dbe5d4 -r b8b2993aa515 sys/arch/amd64/amd64/fpu.c
--- a/sys/arch/amd64/amd64/fpu.c Fri Feb 07 21:52:46 2014 +0000
+++ b/sys/arch/amd64/amd64/fpu.c Fri Feb 07 22:40:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.45 2014/02/04 21:09:23 dsl Exp $ */
+/* $NetBSD: fpu.c,v 1.46 2014/02/07 22:40:22 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.45 2014/02/04 21:09:23 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.46 2014/02/07 22:40:22 dsl Exp $");
#include "opt_multiprocessor.h"
@@ -179,7 +179,7 @@
{
struct lwp *l = curlwp;
struct pcb *pcb = lwp_getpcb(l);
- struct savefpu *sfp = &pcb->pcb_savefpu;
+ union savefpu *sfp = &pcb->pcb_savefpu;
uint32_t mxcsr, statbits;
ksiginfo_t ksi;
@@ -194,7 +194,7 @@
fxsave(sfp);
if (frame->tf_trapno == T_XMM) {
- mxcsr = sfp->fp_fxsave.fx_mxcsr;
+ mxcsr = sfp->sv_xmm.fx_mxcsr;
statbits = mxcsr;
mxcsr &= ~0x3f;
x86_ldmxcsr(&mxcsr);
@@ -203,10 +203,10 @@
fninit();
fwait();
- cw = sfp->fp_fxsave.fx_fcw;
+ cw = sfp->sv_xmm.fx_cw;
fldcw(&cw);
fwait();
- statbits = sfp->fp_fxsave.fx_fsw;
+ statbits = sfp->sv_xmm.fx_sw;
}
KPREEMPT_ENABLE(l);
@@ -300,9 +300,9 @@
pcb->pcb_fpcpu = ci;
if ((l->l_md.md_flags & MDL_USEDFPU) == 0) {
fninit();
- cw = pcb->pcb_savefpu.fp_fxsave.fx_fcw;
+ cw = pcb->pcb_savefpu.sv_xmm.fx_cw;
fldcw(&cw);
- mxcsr = pcb->pcb_savefpu.fp_fxsave.fx_mxcsr;
+ mxcsr = pcb->pcb_savefpu.sv_xmm.fx_mxcsr;
x86_ldmxcsr(&mxcsr);
l->l_md.md_flags |= MDL_USEDFPU;
} else {
diff -r 087a59dbe5d4 -r b8b2993aa515 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Fri Feb 07 21:52:46 2014 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Fri Feb 07 22:40:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.201 2014/01/09 00:57:25 dholland Exp $ */
+/* $NetBSD: machdep.c,v 1.202 2014/02/07 22:40:22 dsl Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.201 2014/01/09 00:57:25 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.202 2014/02/07 22:40:22 dsl Exp $");
/* #define XENDEBUG_LOW */
@@ -1341,11 +1341,11 @@
l->l_md.md_flags &= ~MDL_USEDFPU;
pcb->pcb_flags = 0;
if (pack->ep_osversion >= 699002600)
- pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_NPXCW__;
+ pcb->pcb_savefpu.sv_xmm.fx_cw = __NetBSD_NPXCW__;
else
- pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_COMPAT_NPXCW__;
- pcb->pcb_savefpu.fp_fxsave.fx_mxcsr = __INITIAL_MXCSR__;
- pcb->pcb_savefpu.fp_fxsave.fx_mxcsr_mask = __INITIAL_MXCSR_MASK__;
+ pcb->pcb_savefpu.sv_xmm.fx_cw = __NetBSD_COMPAT_NPXCW__;
+ pcb->pcb_savefpu.sv_xmm.fx_mxcsr = __INITIAL_MXCSR__;
+ pcb->pcb_savefpu.sv_xmm.fx_mxcsr_mask = __INITIAL_MXCSR_MASK__;
l->l_proc->p_flag &= ~PK_32;
@@ -1939,7 +1939,7 @@
if (pcb->pcb_fpcpu) {
fpusave_lwp(l, true);
}
- memcpy(mcp->__fpregs, &pcb->pcb_savefpu.fp_fxsave,
+ memcpy(mcp->__fpregs, &pcb->pcb_savefpu.sv_xmm,
sizeof (mcp->__fpregs));
*flags |= _UC_FPU;
}
@@ -1995,7 +1995,7 @@
fpusave_lwp(l, false);
if ((flags & _UC_FPU) != 0) {
- memcpy(&pcb->pcb_savefpu.fp_fxsave, mcp->__fpregs,
+ memcpy(&pcb->pcb_savefpu.sv_xmm, mcp->__fpregs,
sizeof (mcp->__fpregs));
l->l_md.md_flags |= MDL_USEDFPU;
}
diff -r 087a59dbe5d4 -r b8b2993aa515 sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c Fri Feb 07 21:52:46 2014 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c Fri Feb 07 22:40:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.88 2014/01/25 05:09:59 christos Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.89 2014/02/07 22:40:22 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.88 2014/01/25 05:09:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.89 2014/02/07 22:40:22 dsl Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -143,11 +143,11 @@
l->l_md.md_flags |= MDL_COMPAT32; /* Force iret not sysret */
pcb->pcb_flags = PCB_COMPAT32;
if (pack->ep_osversion >= 699002600)
- pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_NPXCW__;
+ pcb->pcb_savefpu.sv_xmm.fx_cw = __NetBSD_NPXCW__;
else
- pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_COMPAT_NPXCW__;
- pcb->pcb_savefpu.fp_fxsave.fx_mxcsr = __INITIAL_MXCSR__;
- pcb->pcb_savefpu.fp_fxsave.fx_mxcsr_mask = __INITIAL_MXCSR_MASK__;
+ pcb->pcb_savefpu.sv_xmm.fx_cw = __NetBSD_COMPAT_NPXCW__;
+ pcb->pcb_savefpu.sv_xmm.fx_mxcsr = __INITIAL_MXCSR__;
+ pcb->pcb_savefpu.sv_xmm.fx_mxcsr_mask = __INITIAL_MXCSR_MASK__;
p->p_flag |= PK_32;
@@ -530,68 +530,12 @@
return (0);
}
-/*
- * XXX-cube (20060311): This doesn't seem to work fine.
- */
-static int
-xmm_to_s87_tag(const uint8_t *fpac, int regno, uint8_t tw)
-{
- static const uint8_t empty_significand[8] = { 0 };
- int tag;
- uint16_t exponent;
-
- if (tw & (1U << regno)) {
- exponent = fpac[8] | (fpac[9] << 8);
- switch (exponent) {
- case 0x7fff:
- tag = 2;
- break;
-
- case 0x0000:
- if (memcmp(empty_significand, fpac,
- sizeof(empty_significand)) == 0)
- tag = 1;
- else
- tag = 2;
- break;
-
- default:
- if ((fpac[7] & 0x80) == 0)
- tag = 2;
- else
- tag = 0;
- break;
- }
- } else
- tag = 3;
-
- return (tag);
-}
-
int
netbsd32_process_read_fpregs(struct lwp *l, struct fpreg32 *regs, size_t *sz)
{
struct fpreg regs64;
- struct save87 *s87 = (struct save87 *)regs;
+ int error;
size_t fp_size;
- int error, i;
-
- union fp_addr {
- uint64_t fa_64; /* Linear address for 64bit systems */
- struct {
- uint32_t fa_off; /* Linear address for 32 bit */
- uint16_t fa_seg; /* Code/data (etc) segment */
- uint16_t fa_pad;
- } fa_32;
- } fa;
-
- /*
- * NOTE: This 'struct fpreg32' is just char[108] and is shorter
- * than 'struct save87'.
- * If we write to the extra fields we trash the stack when writing
- * process coredumps (see coredump_note() in core_elf32.c).
- * This code must not set sv_env.en_tw or s87->sv_ex_sw.
- */
/*
* All that stuff makes no sense in i386 code :(
@@ -601,26 +545,8 @@
error = process_read_fpregs(l, ®s64, &fp_size);
if (error)
return error;
-
- s87->sv_env.en_cw = regs64.fxstate.fx_fcw;
- s87->sv_env.en_sw = regs64.fxstate.fx_fsw;
- fa.fa_64 = regs64.fxstate.fx_rip;
- s87->sv_env.en_fip = fa.fa_32.fa_off;
- s87->sv_env.en_fcs = fa.fa_32.fa_seg;
- s87->sv_env.en_opcode = regs64.fxstate.fx_fop;
- fa.fa_64 = regs64.fxstate.fx_rdp;
- s87->sv_env.en_foo = fa.fa_32.fa_off;
- s87->sv_env.en_fos = fa.fa_32.fa_seg;
-
- s87->sv_env.en_tw = 0;
- for (i = 0; i < 8; i++) {
- s87->sv_env.en_tw |=
- (xmm_to_s87_tag((uint8_t *)®s64.fxstate.fx_st[i][0], i,
- regs64.fxstate.fx_ftw) << (i * 2));
-
- memcpy(&s87->sv_ac[i].fp_bytes, ®s64.fxstate.fx_st[i][0],
- sizeof(s87->sv_ac[i].fp_bytes));
- }
+ __CTASSERT(sizeof *regs == sizeof (struct save87));
+ process_xmm_to_s87(®s64.fxstate, (struct save87 *)regs);
return (0);
}
@@ -897,8 +823,8 @@
if (pcb->pcb_fpcpu != NULL) {
fpusave_lwp(l, false);
}
- memcpy(&pcb->pcb_savefpu.fp_fxsave, &mcp->__fpregs,
- sizeof (pcb->pcb_savefpu.fp_fxsave));
+ memcpy(&pcb->pcb_savefpu.sv_xmm, &mcp->__fpregs,
+ sizeof (pcb->pcb_savefpu.sv_xmm));
/* If not set already. */
l->l_md.md_flags |= MDL_USEDFPU;
}
@@ -957,8 +883,8 @@
if (pcb->pcb_fpcpu) {
fpusave_lwp(l, true);
}
- memcpy(&mcp->__fpregs, &pcb->pcb_savefpu.fp_fxsave,
- sizeof (pcb->pcb_savefpu.fp_fxsave));
+ memcpy(&mcp->__fpregs, &pcb->pcb_savefpu.sv_xmm,
+ sizeof (pcb->pcb_savefpu.sv_xmm));
*flags |= _UC_FPU;
}
}
diff -r 087a59dbe5d4 -r b8b2993aa515 sys/arch/amd64/amd64/process_machdep.c
--- a/sys/arch/amd64/amd64/process_machdep.c Fri Feb 07 21:52:46 2014 +0000
+++ b/sys/arch/amd64/amd64/process_machdep.c Fri Feb 07 22:40:22 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.25 2014/01/04 00:10:02 dsl Exp $ */
+/* $NetBSD: process_machdep.c,v 1.26 2014/02/07 22:40:22 dsl Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.25 2014/01/04 00:10:02 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.26 2014/02/07 22:40:22 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -69,7 +69,7 @@
#include <machine/fpu.h>
static inline struct trapframe *process_frame(struct lwp *);
-static inline struct fxsave64 *process_fpframe(struct lwp *);
+static inline struct fxsave *process_fpframe(struct lwp *);
#if 0
static inline int verr_gdt(struct pmap *, int sel);
static inline int verr_ldt(struct pmap *, int sel);
@@ -82,12 +82,12 @@
return (l->l_md.md_regs);
}
-static inline struct fxsave64 *
Home |
Main Index |
Thread Index |
Old Index