From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [81.169.146.162]) by sourceware.org (Postfix) with ESMTPS id 5F90D3858D33 for ; Mon, 30 Oct 2023 15:21:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F90D3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=clisp.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=clisp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5F90D3858D33 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=81.169.146.162 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1698679307; cv=pass; b=rpchnwth5EMPbgzhDS7m98SbOfYczniaX6U1QOobRNTwLkrdCkUpRca0MA4W8jJLUEcB9TvuitRa1fq0TuHQGvFxy6dyytpCr39GPcS7FOEinz7UJgyI687YO2UpkHPuESq/hFrETo14HQ8qT0GgDKfzNbjY8RuRxsrsB40ypI0= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1698679307; c=relaxed/simple; bh=CHPfx2KxbUcIDNg3q4ptFVoS4HyzBDq6LFhjQ5PRCms=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=MuPxpFL466b/Xvdf+94GxvZoAb4gcholna5bexG/57XV14LNBue7SWlVSCyVmXDv/rf5KQkYqhWGWsFaU51Q+XocWASHT3c6jaqir2PKJTuESr1QlHmDsUy+rpp/uN6rwelhwt5rm4GqGspvMzDVBVMrqpEiPHmNX5mbUKSX/LI= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1698679303; cv=none; d=strato.com; s=strato-dkim-0002; b=KKAVGCLcKKY1OYKykza+04Dc/9C+F8gsiNUciY1eSsaQeS9JU+BVPEm4jjQBStnx8s bvnkYECWaoUpdsUxoBVhlyA4XTnAJpIw6r868w2vOWx2A2nJQBTL+RXrjxS2IkEjiB0E Ws37B4Te+EP5XrdMnPvherzlzHYeZG4aZv4hFW4SpZJQIA8L/VmRdDwS6zOhLCqGPMsr kkTTycLi3X7JCcTpp1Xukby1Lm7AbCEV77pPPit7ByNqyZs02euzb07A+BGywz4bxgf8 3tpa6n0o5F4GkbDnYArBzaRv4vo1HD0ZZ05UGSOl8V3jBAwib3Af6XPM7ps2U8ftosPu ehXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1698679303; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:To:From:Cc:Date:From: Subject:Sender; bh=JvOxS7kPhy/Uhtd4Z5bpIGe/9Gl1CviIHJzZrSUgfPE=; b=kiEyxQ/lj1Gk4EW+tS5NJlohwZF9UNKMPRe6rWpd9ce0JTLJ2492vqlmS6Ae14OA83 D+yD6k9jtp0tzGVmGdreSIitKsDxqjTH1vulx1XUAhAZ9cPuwi/WSwZRkmZW+kpqIu3p quH7Pbt7Pc6EhDnWyis+muJOnXZWuDwV/SlFHIM+7yVf1X5HimlAUT3sPtxQHm4lGQDM Rzu29InyFNPx5Z9vzgTIGGNGC06LgD4FzqEQQvtSjhTltP2tckACi0JBAi3cD6aCq+ce T/+6uVBhSFgfKZGMf9XKATZ/ga2kN7PiiSbQOB6aJ0V3dh3o5iPsyBpybyxGMm9Bp+Cx 4e2g== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1698679303; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:To:From:Cc:Date:From: Subject:Sender; bh=JvOxS7kPhy/Uhtd4Z5bpIGe/9Gl1CviIHJzZrSUgfPE=; b=pX0OgnYQpcWvRcw1PWTHJY98d0ERgtigpqmUvQ+PDaMtUG5uOhsPOgSkH1pWMO6w+p 9qIVPfRDL4/tIkC+HFfSBlu5B2Dm6WNqR/hkumrOE2jKtCirYwe0jKVEHtkB4vQyuTUV lXRcRq0QhKhxjGSCf1bWc5D2DoG4C24FF98dHDhZj0lpnWeLfAX4LN/3SSsenZpXVdTW j3J+4Rv34zVVj6rOI+OD8TxXUIiG0liNCO4pxLnwktfgq2VUFZHmt+31wjN9pTMpo86U Ftdso7csUO0XPynnSygTjwb+GUt1xhzszqaU83XtFk/nwxGM4FVYOZ6yAHP9ZgehpXVR k2zg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1698679303; s=strato-dkim-0003; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:To:From:Cc:Date:From: Subject:Sender; bh=JvOxS7kPhy/Uhtd4Z5bpIGe/9Gl1CviIHJzZrSUgfPE=; b=FOClVfRk/sehgTezCR3xdCzWT0VTDFGAPvo0BfMraR4Lao6VE4eDhL+tdQbppBtI9t ZP7nuBRD8J+nkOTEFKDw== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPFjaCHgFzkC+zeDJgocaurNG/i+w==" Received: from nimes.localnet by smtp.strato.de (RZmta 49.9.1 AUTH) with ESMTPSA id ecf079z9UFLhN7h (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 30 Oct 2023 16:21:43 +0100 (CET) From: Bruno Haible To: libc-alpha@sourceware.org, Adhemerval Zanella Subject: Re: [PATCH v2 2/3] i686: Do not raise exception traps on fesetexcept (BZ 30989) Date: Mon, 30 Oct 2023 16:21:42 +0100 Message-ID: <5280730.l52yBJDM9G@nimes> In-Reply-To: <20231024113716.3911015-3-adhemerval.zanella@linaro.org> References: <20231024113716.3911015-1-adhemerval.zanella@linaro.org> <20231024113716.3911015-3-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart22535632.Yz81rIOvuz" Content-Transfer-Encoding: 7Bit X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a multi-part message in MIME format. --nextPart22535632.Yz81rIOvuz Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hi Adhemerval, In the error case, the new code mistakenly masks all floating-point exceptions (i.e. as if someone had called fedisableexcept (FE_ALL_EXCEPT)). This is because the FNSTENV instruction is documented as "Saves the current FPU operating environment at the memory location specified with the destination operand, and then masks all floating-point exceptions." The mistake came from my initial proposed fix of BZ 30990. Sorry about that. Here's a proposed fix, on top of your patch. I've verified that the sequence of instructions __asm__ ("fnstenv %0" : "=m" (*&temp)); __asm__ volatile ("fldcw %0" : : "m" (*&temp.__control_word)); does restore the exceptions trapping bits. Bruno --nextPart22535632.Yz81rIOvuz Content-Disposition: attachment; filename="BZ30989-fnstenv-fix.diff" Content-Transfer-Encoding: quoted-printable Content-Type: text/x-patch; charset="UTF-8"; name="BZ30989-fnstenv-fix.diff" diff --git a/sysdeps/i386/fpu/fesetexcept.c b/sysdeps/i386/fpu/fesetexcept.c index 6eeb5ab5b0..8c93264b0c 100644 =2D-- a/sysdeps/i386/fpu/fesetexcept.c +++ b/sysdeps/i386/fpu/fesetexcept.c @@ -46,15 +46,20 @@ fesetexcept (int excepts) fenv_t temp; =20 __asm__ ("fnstenv %0" : "=3Dm" (*&temp)); + /* Note: fnstenv masks all floating-point exceptions until the fldenv + or fldcw below. */ =20 /* Clear or set relevant flags. */ temp.__status_word |=3D temp.__status_word & excepts; =20 if ((~temp.__control_word) & excepts) =2D /* Setting the exception flags may trigger a trap (at the next =2D floating-point instruction, but that does not matter). =2D ISO C23 (7.6.4.4) does not allow it. */ =2D return -1; + { + /* Setting the exception flags may trigger a trap (at the next + floating-point instruction, but that does not matter). + ISO C23 =C2=A7 7.6.4.4 does not allow it. */ + __asm__ volatile ("fldcw %0" : : "m" (*&temp.__control_word)); + return -1; + } =20 /* Store the new status word (along with the rest of the environment= ). */ __asm__ ("fldenv %0" : : "m" (*&temp)); --nextPart22535632.Yz81rIOvuz--