Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1417821

[PATCH v2 05/10] x86, asm: change GEN_*_RMWcc() to use CC_SET()/CC_OUT()

From "H. Peter Anvin" <hpa@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v2 05/10] x86, asm: change GEN_*_RMWcc() to use CC_SET()/CC_OUT()
Date 2016-06-08 21:50 +0200
Message-ID <rHREe-4nR-53@gated-at.bofh.it> (permalink)
References <rHRux-4jK-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: "H. Peter Anvin" <hpa@zytor.com>

Change the GEN_*_RMWcc() macros to use the CC_SET()/CC_OUT() macros
defined in <asm/asm.h>, and disable the use of asm goto if
__GCC_ASM_FLAG_OUTPUTS__ is enabled.  This allows gcc to receive the
flags output directly in gcc 6+.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/include/asm/rmwcc.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
index e3264c4..661dd30 100644
--- a/arch/x86/include/asm/rmwcc.h
+++ b/arch/x86/include/asm/rmwcc.h
@@ -1,7 +1,9 @@
 #ifndef _ASM_X86_RMWcc
 #define _ASM_X86_RMWcc
 
-#ifdef CC_HAVE_ASM_GOTO
+#if !defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(CC_HAVE_ASM_GOTO)
+
+/* Use asm goto */
 
 #define __GEN_RMWcc(fullop, var, cc, ...)				\
 do {									\
@@ -19,13 +21,15 @@ cc_label:								\
 #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc)			\
 	__GEN_RMWcc(op " %1, " arg0, var, cc, vcon (val))
 
-#else /* !CC_HAVE_ASM_GOTO */
+#else /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CC_HAVE_ASM_GOTO) */
+
+/* Use flags output or a set instruction */
 
 #define __GEN_RMWcc(fullop, var, cc, ...)				\
 do {									\
 	bool c;								\
-	asm volatile (fullop "; set" #cc " %1"				\
-			: "+m" (var), "=qm" (c)				\
+	asm volatile (fullop ";" CC_SET(cc)				\
+			: "+m" (var), CC_OUT(cc) (c)			\
 			: __VA_ARGS__ : "memory");			\
 	return c;							\
 } while (0)
@@ -36,6 +40,6 @@ do {									\
 #define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc)			\
 	__GEN_RMWcc(op " %2, " arg0, var, cc, vcon (val))
 
-#endif /* CC_HAVE_ASM_GOTO */
+#endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CC_HAVE_ASM_GOTO) */
 
 #endif /* _ASM_X86_RMWcc */
-- 
2.7.3.0.11.gd79db92

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/10] x86: use gcc 6+ asm flag output feature "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 21:40 +0200
  [PATCH v2 10/10] x86, asm: Use CC_SET()/CC_OUT() and static_cpu_has() in archrandom.h "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 21:40 +0200
    [tip:x86/asm] x86, asm: Use CC_SET()/CC_OUT() and static_cpu_has()  in archrandom.h "tip-bot for H. Peter Anvin" <tipbot@zytor.com> - 2016-06-08 22:00 +0200
    Re: [PATCH v2 10/10] x86, asm: Use CC_SET()/CC_OUT() and  static_cpu_has() in archrandom.h Borislav Petkov <bp@alien8.de> - 2016-06-09 17:50 +0200
  [PATCH v2 04/10] x86, asm: define CC_SET() and CC_OUT() macros "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 21:40 +0200
    [tip:x86/asm] x86, asm: define CC_SET() and CC_OUT() macros "tip-bot for H. Peter Anvin" <tipbot@zytor.com> - 2016-06-08 21:50 +0200
  [PATCH v2 06/10] x86, asm: Use CC_SET()/CC_OUT() in <asm/bitops.h> "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 21:50 +0200
  [PATCH v2 02/10] x86, asm: use bool for bitops and other assembly outputs "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 21:50 +0200
  [PATCH v2 08/10] x86, asm: Use CC_SET()/CC_OUT() in <asm/rwsem.h> "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 21:50 +0200
  [PATCH v2 07/10] x86, asm: Use CC_SET()/CC_OUT() in <asm/percpu.h> "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 21:50 +0200
  [PATCH v2 05/10] x86, asm: change GEN_*_RMWcc() to use CC_SET()/CC_OUT() "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 21:50 +0200
  [PATCH v2 03/10] x86, asm: change the GEN_*_RMWcc() macros to not quote the condition "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 21:50 +0200
  Re: [PATCH v2 00/10] x86: use gcc 6+ asm flag output feature "H. Peter Anvin" <hpa@zytor.com> - 2016-06-08 23:40 +0200

csiph-web