4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andi Kleen <a...@linux.intel.com>

commit 3f7d875566d8e79c5e0b2c9a413e91b2c29e0854 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 <a...@linux.intel.com>
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
Acked-by: David Woodhouse <d...@amazon.co.uk>
Cc: dave.han...@intel.com
Cc: gre...@linuxfoundation.org
Cc: torva...@linux-foundation.org
Cc: ar...@linux.intel.com
Link: https://lkml.kernel.org/r/20180117225328.15414-1-a...@firstfloor.org
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
 arch/x86/include/asm/nospec-branch.h |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -206,16 +206,17 @@ extern char __indirect_thunk_end[];
 static inline void vmexit_fill_RSB(void)
 {
 #ifdef CONFIG_RETPOLINE
-       unsigned long loops = RSB_CLEAR_LOOPS / 2;
+       unsigned long loops;
 
        asm volatile (ANNOTATE_NOSPEC_ALTERNATIVE
                      ALTERNATIVE("jmp 910f",
                                  __stringify(__FILL_RETURN_BUFFER(%0, 
RSB_CLEAR_LOOPS, %1)),
                                  X86_FEATURE_RETPOLINE)
                      "910:"
-                     : "=&r" (loops), ASM_CALL_CONSTRAINT
-                     : "r" (loops) : "memory" );
+                     : "=r" (loops), ASM_CALL_CONSTRAINT
+                     : : "memory" );
 #endif
 }
+
 #endif /* __ASSEMBLY__ */
 #endif /* __NOSPEC_BRANCH_H__ */


Reply via email to