Skip to content

Commit 5fa8716

Browse files
Andi Kleengregkh
authored andcommitted
x86/retpoline: Optimize inline assembler for vmexit_fill_RSB
commit 3f7d875 upstream. The generated assembler for the C fill RSB inline asm operations has 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. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: David Woodhouse <dwmw@amazon.co.uk> Cc: dave.hansen@intel.com Cc: gregkh@linuxfoundation.org Cc: torvalds@linux-foundation.org Cc: arjan@linux.intel.com Link: https://lkml.kernel.org/r/20180117225328.15414-1-andi@firstfloor.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cd8d78e commit 5fa8716

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

arch/x86/include/asm/nospec-branch.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,17 @@ extern char __indirect_thunk_end[];
206206
static inline void vmexit_fill_RSB(void)
207207
{
208208
#ifdef CONFIG_RETPOLINE
209-
unsigned long loops = RSB_CLEAR_LOOPS / 2;
209+
unsigned long loops;
210210

211211
asm volatile (ANNOTATE_NOSPEC_ALTERNATIVE
212212
ALTERNATIVE("jmp 910f",
213213
__stringify(__FILL_RETURN_BUFFER(%0, RSB_CLEAR_LOOPS, %1)),
214214
X86_FEATURE_RETPOLINE)
215215
"910:"
216-
: "=&r" (loops), ASM_CALL_CONSTRAINT
217-
: "r" (loops) : "memory" );
216+
: "=r" (loops), ASM_CALL_CONSTRAINT
217+
: : "memory" );
218218
#endif
219219
}
220+
220221
#endif /* __ASSEMBLY__ */
221222
#endif /* __NOSPEC_BRANCH_H__ */

0 commit comments

Comments
 (0)