From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x226jaiiImEkiqSRvYutevAAO9WY3O+mvYKaqF8YOmLcSz3Zr1qs95U++S0RSF/YfvlC+i6gO ARC-Seal: i=1; a=rsa-sha256; t=1516610577; cv=none; d=google.com; s=arc-20160816; b=eEn/++iidUXrbq5W7CuCtMK2kkDGzMxcVo4lawUEPkdL0GAP5TrkS4ye+zFeP8ZoA9 d8hYgfL2FGHzfCdp3n2/BrvJ9bkfoX29tNywYNt9DJyPrHv8M6kD82O7oRxUCHAae2J4 /Ja/xagSj71PMLE6MsaQBYUpOUJKZqKHYN/wjMmamykQj0OP01QVGu2rtd7QY+oux91n pj4EfRckXKb2ZOcOXHnZ8F4IT4Ll2GHeF+q2vNub5C0tvapUEustFu/7P4jglohLH5av z9iPTsh4w8jYXGp36xy2TsG/ZLRiBReAoQbc/fqmwjSGviIyFYQrCZv6btrZGJFuCwBL lsiw== 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=0JGJQCAGOGua8P0w4ohodrgMcg0XJkoIiMdnstvMG9A=; b=xTx202+f+8OILIEDs1h8hHXhIFlwKuDGHLXkq0oKz1dkx9qv0YDIX/URILitlfVVH1 x0TjONMM6eA8sWNDoir3FYrTeOaO06YMcwe1/o1UuMd7l1sKzOvsCLauBUcZHMosrFgw 7uAiHAkpwFZHajQGbEEt7mI8p8h/QAXd9KQxSC8hQmUnBOO1zCx9BfbAVCCCYDQXMIbn V/qprUFEg5E7DvADs6W8rYlRSXGPvuLDtK4WxytXFbdiJS9sgWHhJMr3AZOMyMQRPK7o TYYfu0JjYizkMwRCmX1HS3WW2uiG50RXf+tpRA5imyzYG0nb8Zylf5rZ7wKCTMTJrvpx ubvw== 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.4 53/53] x86/retpoline: Optimize inline assembler for vmexit_fill_RSB Date: Mon, 22 Jan 2018 09:40:45 +0100 Message-Id: <20180122083912.936060714@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083910.299610926@linuxfoundation.org> References: <20180122083910.299610926@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?1590281453120260797?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.4-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 @@ -183,15 +183,16 @@ 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 (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__ */