From owner-freebsd-hackers@freebsd.org Sat Jun 17 08:53:20 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED9D8BF5702 for ; Sat, 17 Jun 2017 08:53:20 +0000 (UTC) (envelope-from karnajitw@gmail.com) Received: from mail-io0-x22e.google.com (mail-io0-x22e.google.com [IPv6:2607:f8b0:4001:c06::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B5AAA6BE for ; Sat, 17 Jun 2017 08:53:20 +0000 (UTC) (envelope-from karnajitw@gmail.com) Received: by mail-io0-x22e.google.com with SMTP id t87so41966955ioe.0 for ; Sat, 17 Jun 2017 01:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fkJO6okXJTwX5kJ6UhyZHQIPer1pZlcTpSHNJAx8fT0=; b=EOZxvVx+jhpRpszHmUsiFvNtwg8HfEqYC5Ia72TCqRcgbks29kglmMWyTpcW2yJDAb 7HsIHg9Oc3m3erRJRK+W/1FtU4iEU8ymZr0LpWhxz9RsJZVB3yySetACNPVbNxqWWgGv yLyNUC6L/XYAnE7sbIGZl5RGYZDEeIWEqqq+reMWFna937YPPb/+Wq7o42iMZM23G8iu Ugqg+IUno5JPVAvM+EzObPrbYLe1g0Roa9BltpSiblJKI3Cic+QuOM5YC+5AsDD+bnbJ LnqZzgmcnii4ylq4mpG6+wQDmNp7sFqZr7kE4reHOtJE9P5Vf4EQHm1k5s2zXYrJJlig ujxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fkJO6okXJTwX5kJ6UhyZHQIPer1pZlcTpSHNJAx8fT0=; b=dWIigK22iYjuxC5d05rKjWzdLZWAZO3/DLPF/0G5juiET0Rq1JkuEXfxd0PGQPGB2d 59c4GMl9qCAx3TufatT29CvhbkWNe2mwfsw3XKqN6p1x4HfT6XPlhbMlME11+SOzRh0A mbE7oKUrzl3ZS589W5qyPMZLejxESp4lOXIcu3AZbo6ZUn0GlggMblctjooLKAMIvRtA 2yKqzpWSy4h5lnLsq4WmJukvO/SNoZpSBW36utKzxk3+Q8FbKI8iSksibyL87IPGAc6M JK9GLN7xjjyrhjS64SBv2PbN1g179yd0SB9Ctz0Ya5jlqwLhrRwr+dtB4u0WjkCeiGUt zKOg== X-Gm-Message-State: AKS2vOyKDt7chzVKBc3fKPtce+286OGvq1tn6MhONScDckt+SqFjDEJ3 y6KjZFbwlYnrl2Ukvk8/c/KalIXbbA== X-Received: by 10.107.156.17 with SMTP id f17mr1280220ioe.9.1497689599992; Sat, 17 Jun 2017 01:53:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.136.131 with HTTP; Sat, 17 Jun 2017 01:53:19 -0700 (PDT) In-Reply-To: <20170616132329.GY2088@kib.kiev.ua> References: <20170616132329.GY2088@kib.kiev.ua> From: karnajit wangkhem Date: Sat, 17 Jun 2017 14:23:19 +0530 Message-ID: Subject: Re: Undesirable FPU tag word value after PT_SETFPREGS on i386 To: Konstantin Belousov Cc: freebsd-hackers@freebsd.org X-Mailman-Approved-At: Sat, 17 Jun 2017 12:17:21 +0000 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jun 2017 08:53:21 -0000 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 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; > } > } >