]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/asm: Add _ASM_RIP() macro for x86-64 (%rip) suffix
authorH. Peter Anvin (Intel) <hpa@zytor.com>
Tue, 12 Mar 2024 21:10:40 +0000 (14:10 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:18:47 +0000 (16:18 +0200)
commit f87bc8dc7a7c438c70f97b4e51c76a183313272e upstream.

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.

  [ pawan: resolved merged conflict for __ASM_REGPFX ]

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Link: https://lkml.kernel.org/r/20210910195910.2542662-3-hpa@zytor.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/include/asm/asm.h

index 6dd47c9ec788a1273427baa2d32cebdb7e9b9c98..fbcfec4dc4ccd74d983d84ebad2c6b4d188bde1a 100644 (file)
@@ -6,11 +6,13 @@
 # define __ASM_FORM(x, ...)            x,## __VA_ARGS__
 # define __ASM_FORM_RAW(x, ...)                x,## __VA_ARGS__
 # define __ASM_FORM_COMMA(x, ...)      x,## __VA_ARGS__,
+# define __ASM_REGPFX                  %
 #else
 #include <linux/stringify.h>
 # define __ASM_FORM(x, ...)            " " __stringify(x,##__VA_ARGS__) " "
 # define __ASM_FORM_RAW(x, ...)                    __stringify(x,##__VA_ARGS__)
 # define __ASM_FORM_COMMA(x, ...)      " " __stringify(x,##__VA_ARGS__) ","
+# define __ASM_REGPFX                  %%
 #endif
 
 #define _ASM_BYTES(x, ...)     __ASM_FORM(.byte x,##__VA_ARGS__ ;)
@@ -49,6 +51,9 @@
 #define _ASM_SI                __ASM_REG(si)
 #define _ASM_DI                __ASM_REG(di)
 
+/* Adds a (%rip) suffix on 64 bits only; for immediate memory references */
+#define _ASM_RIP(x)    __ASM_SEL_RAW(x, x (__ASM_REGPFX rip))
+
 #ifndef __x86_64__
 /* 32 bit */