aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorDaniel Cederman <cederman@gaisler.com>2024-01-15 15:53:45 +0100
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-01-18 08:27:44 -0300
commit82a35070ec35616074343b8c4ffe6b1cff7e2793 (patch)
tree652eb6108868dbca0c1156b1ed40a15046f55ca8 /sysdeps
parent3bb1350c3681c5ca330dd92500dc59fba94b37eb (diff)
downloadglibc-82a35070ec35616074343b8c4ffe6b1cff7e2793.zip
glibc-82a35070ec35616074343b8c4ffe6b1cff7e2793.tar.gz
glibc-82a35070ec35616074343b8c4ffe6b1cff7e2793.tar.bz2
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>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/sparc/fpu/fpu_control.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/sysdeps/sparc/fpu/fpu_control.h b/sysdeps/sparc/fpu/fpu_control.h
index dd18789..48368a7 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