From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756074AbeASPv2 (ORCPT ); Fri, 19 Jan 2018 10:51:28 -0500 Received: from terminus.zytor.com ([65.50.211.136]:42263 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756058AbeASPvP (ORCPT ); Fri, 19 Jan 2018 10:51:15 -0500 Date: Fri, 19 Jan 2018 07:49:06 -0800 From: tip-bot for Andi Kleen Message-ID: Cc: hpa@zytor.com, mingo@kernel.org, ak@linux.intel.com, tglx@linutronix.de, dwmw@amazon.co.uk, linux-kernel@vger.kernel.org Reply-To: tglx@linutronix.de, ak@linux.intel.com, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, dwmw@amazon.co.uk In-Reply-To: <20180117225328.15414-1-andi@firstfloor.org> References: <20180117225328.15414-1-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/retpoline: Optimize inline assembler for vmexit_fill_RSB Git-Commit-ID: 3f7d875566d8e79c5e0b2c9a413e91b2c29e0854 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 3f7d875566d8e79c5e0b2c9a413e91b2c29e0854 Gitweb: https://git.kernel.org/tip/3f7d875566d8e79c5e0b2c9a413e91b2c29e0854 Author: Andi Kleen AuthorDate: Wed, 17 Jan 2018 14:53:28 -0800 Committer: Thomas Gleixner CommitDate: Fri, 19 Jan 2018 16:31:30 +0100 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 Signed-off-by: Thomas Gleixner Acked-by: David Woodhouse 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 --- arch/x86/include/asm/nospec-branch.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 19ba5ad..4ad4108 100644 --- 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__ */