Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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) <hpa@zytor.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210910195910.2542662-3-hpa@zytor.com

authored by

H. Peter Anvin (Intel) and committed by
Borislav Petkov
f87bc8dc 6880fa6c

+5
+5
arch/x86/include/asm/asm.h
··· 6 6 # define __ASM_FORM(x, ...) x,## __VA_ARGS__ 7 7 # define __ASM_FORM_RAW(x, ...) x,## __VA_ARGS__ 8 8 # define __ASM_FORM_COMMA(x, ...) x,## __VA_ARGS__, 9 + # define __ASM_REGPFX % 9 10 #else 10 11 #include <linux/stringify.h> 11 12 # define __ASM_FORM(x, ...) " " __stringify(x,##__VA_ARGS__) " " 12 13 # define __ASM_FORM_RAW(x, ...) __stringify(x,##__VA_ARGS__) 13 14 # define __ASM_FORM_COMMA(x, ...) " " __stringify(x,##__VA_ARGS__) "," 15 + # define __ASM_REGPFX %% 14 16 #endif 15 17 16 18 #define _ASM_BYTES(x, ...) __ASM_FORM(.byte x,##__VA_ARGS__ ;) ··· 50 48 #define _ASM_BP __ASM_REG(bp) 51 49 #define _ASM_SI __ASM_REG(si) 52 50 #define _ASM_DI __ASM_REG(di) 51 + 52 + /* Adds a (%rip) suffix on 64 bits only; for immediate memory references */ 53 + #define _ASM_RIP(x) __ASM_SEL_RAW(x, x (__ASM_REGPFX rip)) 53 54 54 55 #ifndef __x86_64__ 55 56 /* 32 bit */