Date: Sat, 17 Jun 2017 14:23:19 +0530 From: karnajit wangkhem <karnajitw@gmail.com> To: Konstantin Belousov <kostikbel@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Undesirable FPU tag word value after PT_SETFPREGS on i386 Message-ID: <CAB6rxaQwK3iqE3=qgp8hEyQ0jY-D5-ZfoQ0hdePnxr0aWEFidw@mail.gmail.com> In-Reply-To: <20170616132329.GY2088@kib.kiev.ua> References: <CAB6rxaSiG9zJMAjjBEKBimK_j6GaNaVXWuxH0civ1n0C0ZXF1w@mail.gmail.com> <20170616132329.GY2088@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
Thanks that worked... $ ./a.out Child has stopped... FPU TAG = ffff FPU TAG = ffff Send continue to child process a.out test.c Child exited Before: $ ./fpu Process has not terminated, but has stopped... Send continue to child process Enter d = 4.4 Process has not terminated, but has stopped... Send continue to child process d = 4.400000 : e = nan : f = nan Child exited normally Now: $ ./fpu Process has not terminated, but has stopped... Enter d = Send continue to child process 4.4 Process has not terminated, but has stopped... Send continue to child process d = 4.400000 : e = 7.900000 : f = 10.400000 Child exited normally Regards, Karan On Fri, Jun 16, 2017 at 6:53 PM, Konstantin Belousov <kostikbel@gmail.com> wrote: > On Fri, Jun 16, 2017 at 03:19:35PM +0530, karnajit wangkhem wrote: > > Hi All, > > > > Please help me understand why NaN is reported after PT_SETFPREGS. As a > > result of this, if the inferior process contains an float operations, > they > > result in NaN. > > This behavior is not seen in case of 32/64 bit binary on amd64. > > > > My env > > kern.ostype: FreeBSD > > kern.osrelease: 11.0-RELEASE-p1 > > kern.version: FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 03:40:55 UTC > > 2016 > > root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC > > hw.machine_arch: i386 > > > > Result of the below program on an i386 box > > FPU TAG = ffff > > FPU TAG = fe00 -> 11 11 11 10 00 00 00 00 > > FreeBSD 11 started translating between abridged and full FPU tags, but > the translation appeared to be broken. Try this. > > diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c > index 5ca1ee507fe..de29adc4101 100644 > --- a/sys/i386/isa/npx.c > +++ b/sys/i386/isa/npx.c > @@ -1108,7 +1108,7 @@ npx_fill_fpregs_xmm1(struct savexmm *sv_xmm, struct > save87 *sv_87) > sv_87->sv_ac[i] = sv_xmm->sv_fp[i].fp_acc; > if ((penv_xmm->en_tw & (1 << i)) != 0) > /* zero and special are set as valid */ > - penv_87->en_tw &= ~(3 << i); > + penv_87->en_tw &= ~(3 << i * 2); > } > } > > @@ -1143,7 +1143,7 @@ npx_set_fpregs_xmm(struct save87 *sv_87, struct > savexmm *sv_xmm) > penv_xmm->en_tw = 0; > for (i = 0; i < 8; ++i) { > sv_xmm->sv_fp[i].fp_acc = sv_87->sv_ac[i]; > - if ((penv_87->en_tw && (3 << i)) != (3 << i)) > + if ((penv_87->en_tw & (3 << i * 2)) != (3 << i * 2)) > penv_xmm->en_tw |= 1 << i; > } > } >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAB6rxaQwK3iqE3=qgp8hEyQ0jY-D5-ZfoQ0hdePnxr0aWEFidw>