Skip to content

Commit 700b7c5

Browse files
jbeulichIngo Molnar
authored andcommitted
x86/asm: Improve how GEN_*_SUFFIXED_RMWcc() specify clobbers
Commit: df34052 ("x86/asm: Add suffix macro for GEN_*_RMWcc()") ... introduced "suffix" RMWcc operations, adding bogus clobber specifiers: For one, on x86 there's no point explicitly clobbering "cc". In fact, with GCC properly fixed, this results in an overlap being detected by the compiler between outputs and clobbers. Furthermore it seems bad practice to me to have clobber specification and use of the clobbered register(s) disconnected - it should rather be at the invocation place of that GEN_{UN,BIN}ARY_SUFFIXED_RMWcc() macros that the clobber is specified which this particular invocation needs. Drop the "cc" clobber altogether and move the "cx" one to refcount.h. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/5A8AF1F802000078001A91E1@prv-mh.provo.novell.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 3b3a926 commit 700b7c5

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

arch/x86/include/asm/refcount.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ static __always_inline __must_check
6767
bool refcount_sub_and_test(unsigned int i, refcount_t *r)
6868
{
6969
GEN_BINARY_SUFFIXED_RMWcc(LOCK_PREFIX "subl", REFCOUNT_CHECK_LT_ZERO,
70-
r->refs.counter, "er", i, "%0", e);
70+
r->refs.counter, "er", i, "%0", e, "cx");
7171
}
7272

7373
static __always_inline __must_check bool refcount_dec_and_test(refcount_t *r)
7474
{
7575
GEN_UNARY_SUFFIXED_RMWcc(LOCK_PREFIX "decl", REFCOUNT_CHECK_LT_ZERO,
76-
r->refs.counter, "%0", e);
76+
r->refs.counter, "%0", e, "cx");
7777
}
7878

7979
static __always_inline __must_check

arch/x86/include/asm/rmwcc.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#ifndef _ASM_X86_RMWcc
33
#define _ASM_X86_RMWcc
44

5-
#define __CLOBBERS_MEM "memory"
6-
#define __CLOBBERS_MEM_CC_CX "memory", "cc", "cx"
5+
#define __CLOBBERS_MEM(clb...) "memory", ## clb
76

87
#if !defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(CC_HAVE_ASM_GOTO)
98

@@ -40,18 +39,19 @@ do { \
4039
#endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) || !defined(CC_HAVE_ASM_GOTO) */
4140

4241
#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
43-
__GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM)
42+
__GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM())
4443

45-
#define GEN_UNARY_SUFFIXED_RMWcc(op, suffix, var, arg0, cc) \
44+
#define GEN_UNARY_SUFFIXED_RMWcc(op, suffix, var, arg0, cc, clobbers...)\
4645
__GEN_RMWcc(op " " arg0 "\n\t" suffix, var, cc, \
47-
__CLOBBERS_MEM_CC_CX)
46+
__CLOBBERS_MEM(clobbers))
4847

4948
#define GEN_BINARY_RMWcc(op, var, vcon, val, arg0, cc) \
5049
__GEN_RMWcc(op __BINARY_RMWcc_ARG arg0, var, cc, \
51-
__CLOBBERS_MEM, vcon (val))
50+
__CLOBBERS_MEM(), vcon (val))
5251

53-
#define GEN_BINARY_SUFFIXED_RMWcc(op, suffix, var, vcon, val, arg0, cc) \
52+
#define GEN_BINARY_SUFFIXED_RMWcc(op, suffix, var, vcon, val, arg0, cc, \
53+
clobbers...) \
5454
__GEN_RMWcc(op __BINARY_RMWcc_ARG arg0 "\n\t" suffix, var, cc, \
55-
__CLOBBERS_MEM_CC_CX, vcon (val))
55+
__CLOBBERS_MEM(clobbers), vcon (val))
5656

5757
#endif /* _ASM_X86_RMWcc */

0 commit comments

Comments
 (0)