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 <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

authored by Andi Kleen and committed by Thomas Gleixner 3f7d8755 98f0fcee

Changed files
+4 -3
arch
x86
include
+4 -3
arch/x86/include/asm/nospec-branch.h
··· 206 206 static inline void vmexit_fill_RSB(void) 207 207 { 208 208 #ifdef CONFIG_RETPOLINE 209 - unsigned long loops = RSB_CLEAR_LOOPS / 2; 209 + unsigned long loops; 210 210 211 211 asm volatile (ANNOTATE_NOSPEC_ALTERNATIVE 212 212 ALTERNATIVE("jmp 910f", 213 213 __stringify(__FILL_RETURN_BUFFER(%0, RSB_CLEAR_LOOPS, %1)), 214 214 X86_FEATURE_RETPOLINE) 215 215 "910:" 216 - : "=&r" (loops), ASM_CALL_CONSTRAINT 217 - : "r" (loops) : "memory" ); 216 + : "=r" (loops), ASM_CALL_CONSTRAINT 217 + : : "memory" ); 218 218 #endif 219 219 } 220 + 220 221 #endif /* __ASSEMBLY__ */ 221 222 #endif /* __NOSPEC_BRANCH_H__ */