Module Name: src
Committed By: dsl
Date: Sat Jan 25 20:12:53 UTC 2014
Modified Files:
src/sys/arch/i386/i386: process_machdep.c
src/sys/arch/i386/include: npx.h
Log Message:
Change the way the x87 fp register is defined so that the copies between
fsave and fxsave layouts can be done by structure assignments.
To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/i386/i386/process_machdep.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/i386/include/npx.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/i386/i386/process_machdep.c
diff -u src/sys/arch/i386/i386/process_machdep.c:1.78 src/sys/arch/i386/i386/process_machdep.c:1.79
--- src/sys/arch/i386/i386/process_machdep.c:1.78 Sat Jan 25 19:51:31 2014
+++ src/sys/arch/i386/i386/process_machdep.c Sat Jan 25 20:12:53 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.78 2014/01/25 19:51:31 dsl Exp $ */
+/* $NetBSD: process_machdep.c,v 1.79 2014/01/25 20:12:53 dsl Exp $ */
/*-
* Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.78 2014/01/25 19:51:31 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.79 2014/01/25 20:12:53 dsl Exp $");
#include "opt_vm86.h"
#include "opt_ptrace.h"
@@ -95,7 +95,7 @@ void
process_xmm_to_s87(const struct fxsave *sxmm, struct save87 *s87)
{
unsigned int tag, ab_tag;
- const struct fpaccxmm *fx_reg;
+ const struct fpaccfx *fx_reg;
struct fpacc87 *s87_reg;
int i;
@@ -136,11 +136,10 @@ process_xmm_to_s87(const struct fxsave *
s87->s87_dp = sxmm->fx_dp;
/* FP registers (in stack order) */
- fx_reg = sxmm->sv_ac;
+ fx_reg = sxmm->fx_87_ac;
s87_reg = s87->s87_ac;
for (i = 0; i < 8; fx_reg++, s87_reg++, i++)
- memcpy(s87_reg->fp_bytes, fx_reg->fp_bytes,
- sizeof(s87_reg->fp_bytes));
+ *s87_reg = fx_reg->r;
/* Tag word and registers. */
ab_tag = sxmm->fx_tw & 0xff; /* Bits set if valid */
@@ -162,7 +161,7 @@ void
process_s87_to_xmm(const struct save87 *s87, struct fxsave *sxmm)
{
unsigned int tag, ab_tag;
- struct fpaccxmm *fx_reg;
+ struct fpaccfx *fx_reg;
const struct fpacc87 *s87_reg;
int i;
@@ -203,11 +202,10 @@ process_s87_to_xmm(const struct save87 *
sxmm->fx_tw = ab_tag;
/* FP registers (in stack order) */
- fx_reg = sxmm->sv_ac;
+ fx_reg = sxmm->fx_87_ac;
s87_reg = s87->s87_ac;
for (i = 0; i < 8; fx_reg++, s87_reg++, i++)
- memcpy(fx_reg->fp_bytes, s87_reg->fp_bytes,
- sizeof(fx_reg->fp_bytes));
+ fx_reg->r = *s87_reg;
}
int
Index: src/sys/arch/i386/include/npx.h
diff -u src/sys/arch/i386/include/npx.h:1.30 src/sys/arch/i386/include/npx.h:1.31
--- src/sys/arch/i386/include/npx.h:1.30 Sat Jan 25 19:10:56 2014
+++ src/sys/arch/i386/include/npx.h Sat Jan 25 20:12:53 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: npx.h,v 1.30 2014/01/25 19:10:56 christos Exp $ */
+/* $NetBSD: npx.h,v 1.31 2014/01/25 20:12:53 dsl Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -57,16 +57,15 @@ union fp_addr {
} fa_32;
} __packed;
-/* Contents of each floating point accumulator */
+/* The x87 registers are 80 bits (in ST(n) order) */
struct fpacc87 {
-#ifdef dontdef /* too unportable */
- uint32_t fp_mantlo; /* mantissa low (31:0) */
- uint32_t fp_manthi; /* mantissa high (63:32) */
- int fp_exp:15; /* exponent */
- int fp_sgn:1; /* mantissa sign */
-#else
- uint8_t fp_bytes[10];
-#endif
+ uint64_t f87_mantissa; /* mantissa */
+ uint16_t f87_exp_sign; /* exponent and sign */
+} __packed;
+
+/* The x87 registers padded out for fxsave */
+struct fpaccfx {
+ struct fpacc87 r __aligned(16);
};
/*
@@ -96,12 +95,6 @@ struct save87 {
__CTASSERT(sizeof (struct save87) == 108 + 16);
#endif
-/* FPU regsters in the extended save format. */
-struct fpaccxmm {
- uint8_t fp_bytes[10];
- uint8_t fp_rsvd[6];
-};
-
/* SSE/SSE2 registers. */
struct xmmreg {
uint8_t sse_bytes[16];
@@ -118,7 +111,7 @@ struct fxsave {
/*16*/ union fp_addr fx_dp; /* FPU Data pointer */
uint32_t fx_mxcsr; /* MXCSR Register State */
uint32_t fx_mxcsr_mask;
- struct fpaccxmm sv_ac[8]; /* ST/MM regs */
+ struct fpaccfx fx_87_ac[8]; /* 8 x87 registers */
struct xmmreg sv_xmmregs[8]; /* XMM regs */
uint8_t sv_rsvd[16 * 14];
/* 512-bytes --- end of hardware portion of save area */