Skip to content

Commit 3f7d875

Browse files
Andi KleenKAGA-KOKO
authored andcommitted
x86/retpoline: Optimize inline assembler for vmexit_fill_RSB
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: David Woodhouse <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 98f0fce commit 3f7d875

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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)