public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nik.borisov@suse.com>
To: stable@vger.kernel.org
Cc: "H. Peter Anvin (Intel)" <hpa@zytor.com>,
	Borislav Petkov <bp@suse.de>,
	Nikolay Borisov <nik.borisov@suse.com>
Subject: [PATCH 1/7] x86/asm: Add _ASM_RIP() macro for x86-64 (%rip) suffix
Date: Mon, 26 Feb 2024 12:12:33 +0200	[thread overview]
Message-ID: <20240226101239.17633-2-nik.borisov@suse.com> (raw)
In-Reply-To: <20240226101239.17633-1-nik.borisov@suse.com>

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

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
Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
---
 arch/x86/include/asm/asm.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
index cd339b88d5d4..9116ef22bc53 100644
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -6,12 +6,13 @@
 # define __ASM_FORM(x)	x
 # define __ASM_FORM_RAW(x)     x
 # define __ASM_FORM_COMMA(x) x,
+# define __ASM_REGPFX			%
 #else
 #include <linux/stringify.h>
-
 # define __ASM_FORM(x)	" " __stringify(x) " "
 # define __ASM_FORM_RAW(x)     __stringify(x)
 # define __ASM_FORM_COMMA(x) " " __stringify(x) ","
+# define __ASM_REGPFX			%%
 #endif
 
 #ifndef __x86_64__
@@ -48,6 +49,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 */
 
-- 
2.34.1


  reply	other threads:[~2024-02-26 10:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 10:12 [PATCH 0/7] 5.4 backport of recent mds improvement patches Nikolay Borisov
2024-02-26 10:12 ` Nikolay Borisov [this message]
2024-02-26 10:12 ` [PATCH 2/7] x86/bugs: Add asm helpers for executing VERW Nikolay Borisov
2024-02-26 10:12 ` [PATCH 3/7] x86/entry_64: Add VERW just before userspace transition Nikolay Borisov
2024-02-26 10:12 ` [PATCH 4/7] x86/entry_32: " Nikolay Borisov
2024-02-26 10:12 ` [PATCH 5/7] x86/bugs: Use ALTERNATIVE() instead of mds_user_clear static key Nikolay Borisov
2024-02-26 10:12 ` [PATCH 6/7] KVM/VMX: Use BT+JNC, i.e. EFLAGS.CF to select VMRESUME vs. VMLAUNCH Nikolay Borisov
2024-02-26 10:12 ` [PATCH 7/7] KVM/VMX: Move VERW closer to VMentry for MDS mitigation Nikolay Borisov
2024-02-26 10:36 ` [PATCH 0/7] 5.4 backport of recent mds improvement patches Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240226101239.17633-2-nik.borisov@suse.com \
    --to=nik.borisov@suse.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox