From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 2AB703858CDA; Thu, 18 Jan 2024 11:47:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AB703858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1705578475; bh=BpVMz6viWOztpnOll2ZKTdaWgLA0mc7ETVbaHpIeW3E=; h=From:To:Subject:Date:From; b=GkmCfdsfi1ThrFaKwdWd0w5kquKiex/OX6KdlVsACa3FoE0DZt15vs7t+tSe6P2gx BHjoiqiXR553dcZC6ZNgCne0qvYD9Mr1s7K2bprmorvxbHSOKRRdhgALW7Z+I3oaZM 1tuK1CUWcCm6XywdGXmLQ/8+umFTuF7u+bmhLhqo= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] sparc: Prevent stfsr from directly following floating-point instruction X-Act-Checkin: glibc X-Git-Author: Daniel Cederman X-Git-Refname: refs/heads/master X-Git-Oldrev: 3bb1350c3681c5ca330dd92500dc59fba94b37eb X-Git-Newrev: 82a35070ec35616074343b8c4ffe6b1cff7e2793 Message-Id: <20240118114755.2AB703858CDA@sourceware.org> Date: Thu, 18 Jan 2024 11:47:55 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=82a35070ec35616074343b8c4ffe6b1cff7e2793 commit 82a35070ec35616074343b8c4ffe6b1cff7e2793 Author: Daniel Cederman Date: Mon Jan 15 15:53:45 2024 +0100 sparc: Prevent stfsr from directly following floating-point instruction 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 Reviewed-by: Adhemerval Zanella Diff: --- 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