From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225cPssrRcyDeBM9VovHdXmTMEZU2hzt/KDPAlOHbIGfmt24DEHegwCb2cPDomRQGxf1u/+F ARC-Seal: i=1; a=rsa-sha256; t=1516610972; cv=none; d=google.com; s=arc-20160816; b=ItMP1GMah9eHofpDo8ZHsJpxsqgJmABVjvtXPjT4s//2UGvx1WMPFStW1zK7Q97P6t iIG8cdZcwD+wTp2HNKeVB/sXMdZ4ru4HxHkzUcA/iGn4Nm9b0L97fKvgoEO7k9mzIETV +j9FguXQ7oigJZ+6VOUTyrFPg0tuNUgziIjUBRrrLA66p/XO8AGVux7lFH7kuAer5yJC mPYqlumQuX0nqe84deNB04Pwkr+tlZCTBoigfpHsQCTyuheeFpprkTSdxtWxYlKgbLoc /Kyeqm1w4bz5a0oyYT+2qIkUlzvHoqOrMatSTz+itirCBF1+0/l+xW7nBzyMhe9K78yB DmFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=oYx6fWpyrRxef70XbBo66xDwsDMh+p8Y72To/DdIBM8=; b=p/4CvCGHZzRzEAQKHcuTs9qOydrnHHGtbT2neNiF622Zs4zdhIBLA6xwCcPT3Od+r6 kTG7xDiPReISU8zs1Vv1bGNUXFMkNu9YyiLO7kqO1e4D4GXkws5ByYfi5yQNg5ULGQEl IJrnCGOrvrEJWe4Pk9N5RI1O84XQeFE/1vjvlmN6aTg1e3gD692DaWfcWmydjFpEvg59 V/FjUrF9aupeR8vTJWOJddFmyxavtjgPaEj2iGtOEmj+cTYCTvPuwp+hsNGBtYRFeAWw 1egbgcfu6NvtwNAedLmnN9XNEBI45AFJJquaYYlrAeWXey45XGyuPU/xxC7eblIIjTKT VkdA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andi Kleen , Thomas Gleixner , David Woodhouse , dave.hansen@intel.com, torvalds@linux-foundation.org, arjan@linux.intel.com Subject: [PATCH 4.9 47/47] x86/retpoline: Optimize inline assembler for vmexit_fill_RSB Date: Mon, 22 Jan 2018 09:45:58 +0100 Message-Id: <20180122083929.082011042@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083925.568134913@linuxfoundation.org> References: <20180122083925.568134913@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590281453120260797?= X-GMAIL-MSGID: =?utf-8?q?1590281867219859663?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andi Kleen 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 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 Signed-off-by: Greg Kroah-Hartman --- 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__ */