aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/ia32
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2017-06-24 11:38:31 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2017-06-24 11:38:31 +0000
commitc377ff617b5e20a0ec095130a14c2fa7431553e7 (patch)
treedf61773b4ae448e561c4fd3c92dd805359c5a9a4 /sys/amd64/ia32
parentf7df80f4edbb7cacdcf6f4d448052b933f56aa49 (diff)
downloadsrc-c377ff617b5e20a0ec095130a14c2fa7431553e7.tar.gz
src-c377ff617b5e20a0ec095130a14c2fa7431553e7.zip
Translate between abridged and full x87 tags for compat32
ptrace(PT_GETFPREGS). Sponsored by: The FreeBSD Foundation MFC after: 1 week
Notes
Notes: svn path=/head/; revision=320308
Diffstat (limited to 'sys/amd64/ia32')
-rw-r--r--sys/amd64/ia32/ia32_reg.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/amd64/ia32/ia32_reg.c b/sys/amd64/ia32/ia32_reg.c
index d0e6bfe1318c..0521e954a635 100644
--- a/sys/amd64/ia32/ia32_reg.c
+++ b/sys/amd64/ia32/ia32_reg.c
@@ -156,7 +156,7 @@ fill_fpregs32(struct thread *td, struct fpreg32 *regs)
/* FPU control/status */
penv_87->en_cw = penv_xmm->en_cw;
penv_87->en_sw = penv_xmm->en_sw;
- penv_87->en_tw = penv_xmm->en_tw;
+
/*
* XXX for en_fip/fcs/foo/fos, check if the fxsave format
* uses the old-style layout for 32 bit user apps. If so,
@@ -170,9 +170,13 @@ fill_fpregs32(struct thread *td, struct fpreg32 *regs)
/* Entry into the kernel always sets TF_HASSEGS */
penv_87->en_fos = td->td_frame->tf_ds;
- /* FPU registers */
- for (i = 0; i < 8; ++i)
+ /* FPU registers and tags */
+ penv_87->en_tw = 0xffff;
+ for (i = 0; i < 8; ++i) {
sv_87->sv_ac[i] = sv_fpu->sv_fp[i].fp_acc;
+ if ((penv_xmm->en_tw & (1 << i)) != 0)
+ penv_87->en_tw &= ~(3 << i * 2);
+ }
return (0);
}
@@ -189,15 +193,19 @@ set_fpregs32(struct thread *td, struct fpreg32 *regs)
/* FPU control/status */
penv_xmm->en_cw = penv_87->en_cw;
penv_xmm->en_sw = penv_87->en_sw;
- penv_xmm->en_tw = penv_87->en_tw;
penv_xmm->en_rip = penv_87->en_fip;
/* penv_87->en_fcs and en_fos ignored, see above */
penv_xmm->en_opcode = penv_87->en_opcode;
penv_xmm->en_rdp = penv_87->en_foo;
- /* FPU registers */
- for (i = 0; i < 8; ++i)
+ /* FPU registers and tags */
+ penv_xmm->en_tw = 0;
+ for (i = 0; i < 8; ++i) {
sv_fpu->sv_fp[i].fp_acc = sv_87->sv_ac[i];
+ if ((penv_87->en_tw & (3 << i * 2)) != (3 << i * 2))
+ penv_xmm->en_tw |= 1 << i;
+ }
+
for (i = 8; i < 16; ++i)
bzero(&sv_fpu->sv_fp[i].fp_acc, sizeof(sv_fpu->sv_fp[i].fp_acc));
fpuuserinited(td);