From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id a3067fe3 for ; Mon, 20 Jan 2020 17:38:18 +0000 (UTC) Received: (qmail 23799 invoked by uid 550); 20 Jan 2020 17:38:17 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 23781 invoked from network); 20 Jan 2020 17:38:16 -0000 Date: Mon, 20 Jan 2020 12:38:04 -0500 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20200120173804.GM30412@brightrain.aerifal.cx> References: <20200116161427.GO30412@brightrain.aerifal.cx> <20200116193343.GP30412@brightrain.aerifal.cx> <20200117145350.GR30412@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: Rich Felker Subject: Re: [musl] Considering x86-64 fenv.s to C On Mon, Jan 20, 2020 at 04:32:32PM +1100, Damian McGuckin wrote: > On Fri, 17 Jan 2020, Rich Felker wrote: > > >Note that this approach is not compatible with trapping > >exceptions, but we don't support them anyway. > > When an FNSTENV instruction is executed, all pending exceptions are > essentially lost (either the x87 FPU status register is cleared or > all exceptions are masked). I don't follow what you're saying here and suspect you have a misunderstanding of some of the terms involved. "Pending" does not mean status flags that are already set. It's a concept from the original 387 that's irrelevant in later cpu models, whereby an exception may have already happened on the fpu but still be in transit to the cpu. Executing fwait first, or fstenv rather than fnstenv, will ensure that you don't miss anything even on the original 387. > I think that this means either it wipes the exception bits in the > status register or it wipes out the bits of the control register > which handle which exceptions are trapped. > > Am I wrong. Yes. > Because MUSL does not support trapping exceptions, we do not need to > restore the control word. > > But do we need to copy the lost exceptions flags in the x87 register > back into the SSE register, well at least where we have an SSE. > > Mind you, on an i386 without an SSE, you cannot restore them! Again, I don't follow. Rich