Skip to content

Commit f87bc8d

Browse files
H. Peter Anvin (Intel)suryasaimadhu
authored andcommitted
x86/asm: Add _ASM_RIP() macro for x86-64 (%rip) suffix
Add a macro _ASM_RIP() to add a (%rip) suffix on 64 bits only. This is useful for immediate memory references where one doesn't want gcc to possibly use a register indirection as it may in the case of an "m" constraint. Signed-off-by: H. Peter Anvin (Intel) <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 6880fa6 commit f87bc8d

File tree

1 file changed

+5
-0
lines changed
  • arch/x86/include/asm

1 file changed

+5
-0
lines changed

arch/x86/include/asm/asm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
# define __ASM_FORM(x, ...) x,## __VA_ARGS__
77
# define __ASM_FORM_RAW(x, ...) x,## __VA_ARGS__
88
# define __ASM_FORM_COMMA(x, ...) x,## __VA_ARGS__,
9+
# define __ASM_REGPFX %
910
#else
1011
#include <linux/stringify.h>
1112
# define __ASM_FORM(x, ...) " " __stringify(x,##__VA_ARGS__) " "
1213
# define __ASM_FORM_RAW(x, ...) __stringify(x,##__VA_ARGS__)
1314
# define __ASM_FORM_COMMA(x, ...) " " __stringify(x,##__VA_ARGS__) ","
15+
# define __ASM_REGPFX %%
1416
#endif
1517

1618
#define _ASM_BYTES(x, ...) __ASM_FORM(.byte x,##__VA_ARGS__ ;)
@@ -49,6 +51,9 @@
4951
#define _ASM_SI __ASM_REG(si)
5052
#define _ASM_DI __ASM_REG(di)
5153

54+
/* Adds a (%rip) suffix on 64 bits only; for immediate memory references */
55+
#define _ASM_RIP(x) __ASM_SEL_RAW(x, x (__ASM_REGPFX rip))
56+
5257
#ifndef __x86_64__
5358
/* 32 bit */
5459

0 commit comments

Comments
 (0)