From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) by sourceware.org (Postfix) with ESMTPS id 33F3E3858D28 for ; Mon, 15 Jan 2024 14:53:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33F3E3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=gaisler.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gaisler.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33F3E3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705330433; cv=none; b=mSBq/pPrcaEUL6DtN5rB+RuHja9I6aZkfZInPMqYzZvOI2Yqtpqe9yj4U18CJSFCGHWIHJ484//2sQSr6xLqKt1QQd+8t5I8ry2nv/Vh4Ba7w7xii3iXA+M2XfhGMrPgjepnrVzt7u7ZuRKoTY0czzUSBLfdbfO1HDmDrzHzSUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705330433; c=relaxed/simple; bh=K+u7svuS0FLfazGpX8Uk+1xEWuostMlqGIxED9iDeRs=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=P+Eew+rg9lezvI/9P/ESx49gygbLObtbh3AGLbrlfjDI2BZfoCVtdjYilBpvW5jFm2RRtXfTVVO5igohD9VcOvFGscf+s2Lsqm3cON63y4KlfvCqmhZdeWySmKJjUGifja1fxE1/sv9ATdRunizuq7gR2A3119Hlc0RMhraA72U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4TDFWz2ZfTz681D; Mon, 15 Jan 2024 15:53:51 +0100 (CET) Received: from cederman.got.gaisler.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4TDFWz0gC2z684S; Mon, 15 Jan 2024 15:53:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=unoeuro; t=1705330431; bh=2W6VOYSmKNZmt0zwVpqjjHnjKEUwSWCXhCLtmVUnVjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cPiy0PK+fs+4/1sS4Rn18bAM6ufitW1BreP4D8yWpWYmflpDrFgYlEisl7INhujd4 IPHPA1GJe4y5G1Z60dZPD3KOHOIP5XePyhoGtPpy1/xPH0LNvywhpIGpz9GFK59ipA IRT8wOpph5YSEbKFYYJ2dOkHn/rEgJd7m59ht2vY= From: Daniel Cederman To: libc-alpha@sourceware.org Cc: daniel@gaisler.com, andreas@gaisler.com Subject: [PATCH v2 2/2] sparc: Prevent stfsr from directly following floating-point instruction Date: Mon, 15 Jan 2024 15:53:45 +0100 Message-Id: <20240115145345.3389246-3-cederman@gaisler.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240115145345.3389246-1-cederman@gaisler.com> References: <20240115145345.3389246-1-cederman@gaisler.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: On LEON, if the stfsr instruction is immediately following a floating-point operation instruction in a running program, with no other instruction in between the two, the stfsr might behave as if the order was reversed between the two instructions and the stfsr occurred before the floating-point operation. Add a nop instruction before the stfsr to prevent this from happening. Signed-off-by: Daniel Cederman --- sysdeps/sparc/fpu/fpu_control.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sysdeps/sparc/fpu/fpu_control.h b/sysdeps/sparc/fpu/fpu_control.h index dd18789573..48368a7ce1 100644 --- a/sysdeps/sparc/fpu/fpu_control.h +++ b/sysdeps/sparc/fpu/fpu_control.h @@ -61,7 +61,12 @@ typedef unsigned long int fpu_control_t; # define _FPU_GETCW(cw) __asm__ __volatile__ ("stx %%fsr,%0" : "=m" (*&cw)) # define _FPU_SETCW(cw) __asm__ __volatile__ ("ldx %0,%%fsr" : : "m" (*&cw)) #else -# define _FPU_GETCW(cw) __asm__ __volatile__ ("st %%fsr,%0" : "=m" (*&cw)) +# ifdef __leon__ + /* Prevent stfsr from being placed directly after other fp instruction. */ +# define _FPU_GETCW(cw) __asm__ __volatile__ ("nop; st %%fsr,%0" : "=m" (*&cw)) +# else +# define _FPU_GETCW(cw) __asm__ __volatile__ ("st %%fsr,%0" : "=m" (*&cw)) +# endif # define _FPU_SETCW(cw) __asm__ __volatile__ ("ld %0,%%fsr" : : "m" (*&cw)) #endif -- 2.40.1