LKML Archive on
 help / color / Atom feed
From: Andi Kleen <>
	Andi Kleen <>
Subject: [PATCH] x86/retpoline: Optimize inline assembler for vmexit_fill_RSB
Date: Wed, 17 Jan 2018 14:53:28 -0800
Message-ID: <> (raw)

From: Andi Kleen <>

I was looking at the generated assembler for the C fill RSB
inline asm operations, and noticed several issues:

- The C code sets up the loop register, which
is then immediately overwritten in __FILL_RETURN_BUFFER
with the same value again.

- The C code also passes in the iteration count
in another register, which is not used at all.

Remove these two unnecessary operations. Just rely on
the single constant passed to the macro for the iterations.

This eliminates several instructions and avoids unnecessarily
clobbering a register.

Signed-off-by: Andi Kleen <>
 arch/x86/include/asm/nospec-branch.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 1e170fd3dc51..fed8703a28b9 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -204,15 +204,15 @@ enum spectre_v2_mitigation {
 static inline void vmexit_fill_RSB(void)
-	unsigned long loops = RSB_CLEAR_LOOPS / 2;
+	unsigned long loops;
 		      ALTERNATIVE("jmp 910f",
 				  __stringify(__FILL_RETURN_BUFFER(%0, RSB_CLEAR_LOOPS, %1)),
-		      : "=&r" (loops), ASM_CALL_CONSTRAINT
-		      : "r" (loops) : "memory" );
+		      : "=r" (loops), ASM_CALL_CONSTRAINT
+		      : : "memory" );

             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17 22:53 Andi Kleen [this message]
2018-01-18 12:41 ` David Woodhouse
2018-01-19 15:49 ` [tip:x86/pti] " tip-bot for Andi Kleen

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:

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

  git send-email \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on

Archives are clonable:
	git clone --mirror lkml/git/0.git
	git clone --mirror lkml/git/1.git
	git clone --mirror lkml/git/2.git
	git clone --mirror lkml/git/3.git
	git clone --mirror lkml/git/4.git
	git clone --mirror lkml/git/5.git
	git clone --mirror lkml/git/6.git
	git clone --mirror lkml/git/7.git
	git clone --mirror lkml/git/8.git
	git clone --mirror lkml/git/9.git
	git clone --mirror lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ \
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone