lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251219112007.2827302-2-edumazet@google.com>
Date: Fri, 19 Dec 2025 11:20:06 +0000
From: Eric Dumazet <edumazet@...gle.com>
To: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, 
	Dave Hansen <dave.hansen@...ux.intel.com>, Uros Bizjak <ubizjak@...il.com>, 
	Linus Torvalds <torvalds@...ux-foundation.org>, x86@...nel.org, 
	"H . Peter Anvin" <hpa@...or.com>
Cc: linux-kernel <linux-kernel@...r.kernel.org>, Eric Dumazet <eric.dumazet@...il.com>, 
	Eric Dumazet <edumazet@...gle.com>
Subject: [PATCH 1/2] clang: work around asm output constraint problems

Work around clang problems with "=rm" asm constraint.

clang seems to always chose the memory output, while it is almost
always the worst choice.

Add ASM_OUTPUT_RM so that we can replace "=rm" constraint
where it maters for clang, while not penalizing gcc.

Signed-off-by: Eric Dumazet <edumazet@...gle.com>
Suggested-by: Uros Bizjak <ubizjak@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
---
 include/linux/compiler-clang.h | 7 +++++++
 include/linux/compiler_types.h | 6 +++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index 107ce05bd16eb4a2ecb0f8cbf5c9efeab1845a1c..a82db8ab2812b9aa8851bf51daed3f81d2a41979 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -146,6 +146,13 @@
 #define ASM_INPUT_G "ir"
 #define ASM_INPUT_RM "r"
 
+/*
+ * clang has non optimal behavior with "=rm" constraints for asm outputs.
+ * It favors memory operand, forcing additional logic in tail functions
+ * when CONFIG_STACKPROTECTOR_STRONG=y.
+ */
+#define ASM_OUTPUT_RM "=r"
+
 /*
  * Declare compiler support for __typeof_unqual__() operator.
  *
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 1280693766b9dd844ec7ca83053381799be12456..b66aa58dacd595546b17582df03a762dd23cb15c 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -548,13 +548,17 @@ struct ftrace_likely_data {
 
 /*
  * Clang has trouble with constraints with multiple
- * alternative behaviors (mainly "g" and "rm").
+ * alternative behaviors ("g" , "rm" and "=rm").
  */
 #ifndef ASM_INPUT_G
   #define ASM_INPUT_G "g"
   #define ASM_INPUT_RM "rm"
 #endif
 
+#ifndef ASM_OUTPUT_RM
+  #define ASM_OUTPUT_RM "=rm"
+#endif
+
 #ifdef CONFIG_CC_HAS_ASM_INLINE
 #define asm_inline asm __inline
 #else
-- 
2.52.0.322.g1dd061c0dc-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ