From owner-freebsd-hackers@freebsd.org Thu Jun 22 08:49: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 16D6DD86B8D for ; Thu, 22 Jun 2017 08:49:20 +0000 (UTC) (envelope-from karnajitw@gmail.com) Received: from mail-io0-x234.google.com (mail-io0-x234.google.com [IPv6:2607:f8b0:4001:c06::234]) (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 D18F773686 for ; Thu, 22 Jun 2017 08:49:19 +0000 (UTC) (envelope-from karnajitw@gmail.com) Received: by mail-io0-x234.google.com with SMTP id c201so18859493ioe.1 for ; Thu, 22 Jun 2017 01:49:19 -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=9MYZYrzoJrejU0QsRg1PplB5lydL/FUxfYXsAf4v4fg=; b=tzXdcswqCRc2NTgn7Md/FDKpkZiuM0RP0gTGh6ph+PengF65wq9u2BsKG2OSQ1QTJF BzWV1ykrX2oSc9elAf3Nc2gaw4yaps/UIjF+X0CrgZeClM+0FNB2EzYVk2iL4qLQl+ua 3vEl2lRMcQGBXNgTH8tbB9zO/fJCTVxXkw56tzB+TUSNscbTX74phy48ae2uY3Nb1WgS LJYy8irkfyUhvSYjMq+hBuxwBUkQrfUaOOMlb86y9ygcrDLZyIy+3UwqKQpR94c2Y3kA QSRDIyB/M8wJx2sk8CZ+ytsRVnsjxPKdbnSXr8k8lwvprMlEPRcALr/y1+2j6olFvj/3 ZOWA== 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=9MYZYrzoJrejU0QsRg1PplB5lydL/FUxfYXsAf4v4fg=; b=G5OkeD+VwLL62wwpgb3fb28q25veYmhcNeMEe7el7ARNOmEx3RR7RGAMx3fbPY+78h fYcSoOxXMjsgIJXZAgPAuh8viGjEMiSuUPDH8Mt1gI1hwr+3jEa8CF9qpR/afuGjwk5S GS7Qriu1O3xnK+KHfmZq/qSV4miNxUNMpPkORHMpGQJxCaz8XX4whi0Jf2MIkzJ4Yddy t3S3AambxPXfLDi8a3ZP0OghFMqy7817Qc5YIBZ/YY3K/HsUR4vr2c700qUscy8nFVWO shGnxN0+YryFSNT3uvwrg+3COggEkG0AWM992odhcy6Ga7yx0Pl4+25VPhO9kDknDAKP H7ZA== X-Gm-Message-State: AKS2vOxHuBaqkpt8NepU52H2YKbjYYu65nc6ZoQQL2IdBXQQXTNqIuEN U61q3OQ5vAVJjq7EMYp5GbzRP8nYEg== X-Received: by 10.107.160.1 with SMTP id j1mr1263002ioe.78.1498121359126; Thu, 22 Jun 2017 01:49:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.136.131 with HTTP; Thu, 22 Jun 2017 01:49:18 -0700 (PDT) In-Reply-To: References: <20170616132329.GY2088@kib.kiev.ua> From: karnajit wangkhem Date: Thu, 22 Jun 2017 14:19:18 +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: Thu, 22 Jun 2017 11:25:33 +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: Thu, 22 Jun 2017 08:49:20 -0000 Hi, Sorry for reviving this thread again. Will it be possible for this fix to go freebsd 11 and head. The issue in my case is that lldb doesn't work well with expression without this patch. Please guide me in this regard. Regards, Karan On Sat, Jun 17, 2017 at 2:23 PM, karnajit wangkhem wrote: > 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; >> } >> } >> > >