From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x2242exab2W4yvveZo2ijss2F3ra1b02ng7lzHEhBwWXmMUb1/yZRHCF6d0rwgJrmVukk6nea ARC-Seal: i=1; a=rsa-sha256; t=1516611270; cv=none; d=google.com; s=arc-20160816; b=VY/mmZewV7j1stoVfUhv5t+J74Dp066YOdeh+m89xrgA/4/9jATmSWhXJFjrfWKyXU KN65WQnb8dTvzlIJ1Wfr5t9890/mTbZeEOr6pVMhJ5pPLKhNyRaJLIa8H03r+WEhOjFI RBWNqHN7Zq7eyiBNWvqAaEEqKl75zXAtrHyqnRc9L0yVnG8jZsI9oTyQBDhuHhuJABSg z9+4NxEYFUBxz44sxlPg8XrvSBn9hH5ScrYOEnaUfMRxSFhWW1aCxmtMeD1EsuS7oA6O HS/C+pc9cHpKdPHx/Q4Uhpn/4BuEomRwK1JbYVC7iKo/Apds9htM/XCehKGCN5el7qey eL1w== 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=9Kt2I2+XqnkhlfULgoHgz4whi1Nt6p7BSx3I45E1gPs=; b=LexxU0qfAvjixrrMS2z6yv4tnc71ABDbrsxM+7ttPOEXeqy2H+vQgTCimdcUJXOMSN I5HDJefLfIPMYx73iz5zSQ6WSBDPh2kojF51ChWsenb6q5Ap6ifvIn00sQ4ZU8Oo6/0j 1b45W7DCp2y0ZYlx280qsVKcndurBqejYrbxgTtynHNGmWAStKmiJkY7Wjr9ODNSzh9z oezdzgzU1HY7KKsrPH+DLqgWFZ6HJNb27FahEzH3oTlThsfYm7kAtZi4pT6yfP6pxN3Y ITKSrmcY030dtbnbhb8656D0yDx90lZfJAxDgAKwb5kUlkPSm/G3FZoTACGINZ0gbhwh UjFg== 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.14 86/89] x86/retpoline: Optimize inline assembler for vmexit_fill_RSB Date: Mon, 22 Jan 2018 09:46:06 +0100 Message-Id: <20180122084003.115601729@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083954.683903493@linuxfoundation.org> References: <20180122083954.683903493@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?1590282179584205399?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-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__ */