linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: vfp: use asm volatile for FP control register accesses
@ 2024-03-18  9:30 Ard Biesheuvel
  2024-03-26 23:55 ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Ard Biesheuvel @ 2024-03-18  9:30 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux, arnd, nathan, linus.walleij, Ard Biesheuvel, stable

From: Ard Biesheuvel <ardb@kernel.org>

Clang may reorder FP control register reads and writes, due to the fact
that the inline asm() blocks in the read/write wrappers are not volatile
qualified, and the compiler has no idea that these reads and writes may
have side effects.

In particular, reads of FPSCR may generate an UNDEF exception if a
floating point exception is pending, and the FP emulation code in
VFP_bounce() explicitly clears FP exceptions temporarily in order to be
able to perform the emulation on behalf of user space. This requires
that the writes to FPEXC are never reordered with respect to accesses to
other FP control registers, such as FPSCR.

So use asm volatile for both the read and the write helpers.

Cc: <stable@kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/vfp/vfpinstr.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/vfp/vfpinstr.h b/arch/arm/vfp/vfpinstr.h
index 3c7938fd40aa..c4ac778e6fc9 100644
--- a/arch/arm/vfp/vfpinstr.h
+++ b/arch/arm/vfp/vfpinstr.h
@@ -66,14 +66,14 @@
 
 #define fmrx(_vfp_) ({			\
 	u32 __v;			\
-	asm(".fpu	vfpv2\n"	\
+	asm volatile(".fpu vfpv2\n"	\
 	    "vmrs	%0, " #_vfp_	\
 	    : "=r" (__v) : : "cc");	\
 	__v;				\
  })
 
 #define fmxr(_vfp_,_var_)		\
-	asm(".fpu	vfpv2\n"	\
+	asm volatile(".fpu vfpv2\n"	\
 	    "vmsr	" #_vfp_ ", %0"	\
 	   : : "r" (_var_) : "cc")
 
-- 
2.39.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-27 14:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-18  9:30 [PATCH] ARM: vfp: use asm volatile for FP control register accesses Ard Biesheuvel
2024-03-26 23:55 ` Nathan Chancellor
2024-03-27  7:05   ` Ard Biesheuvel
2024-03-27  7:31     ` Ard Biesheuvel
2024-03-27 14:41     ` Nathan Chancellor

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 NNTP newsgroup(s).