public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] sparc: Prevent stfsr from directly following floating-point instruction
@ 2024-01-18 11:47 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2024-01-18 11:47 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=82a35070ec35616074343b8c4ffe6b1cff7e2793

commit 82a35070ec35616074343b8c4ffe6b1cff7e2793
Author: Daniel Cederman <cederman@gaisler.com>
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 <cederman@gaisler.com>
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-18 11:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-18 11:47 [glibc] sparc: Prevent stfsr from directly following floating-point instruction Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).