Received: by 10.223.176.46 with SMTP id f43csp2652843wra; Mon, 22 Jan 2018 00:57:34 -0800 (PST) X-Google-Smtp-Source: AH8x227TzCnco+pb+OcsuYzTs/yjJQEaDGfg5NGHhBaIWDdaGOhaQazCVWEwnPBqUwAt9bYbGRkn X-Received: by 10.98.16.79 with SMTP id y76mr7829776pfi.111.1516611454591; Mon, 22 Jan 2018 00:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516611454; cv=none; d=google.com; s=arc-20160816; b=ZOQI+Z3Y9YphlkRtrTlqv9uZLje4ZRtvETlEWDniinQ3vDRdaPR2pVkM0jyjRKcuCJ HX0yqLSyV5t7k+CJ3x8NiUX6lelrfsrLflXYMXQ2wuTD7KFgqFMJL358JvbwVORFB63R c4WGGv/YYTtSNh3egO6nZzr6f8krmeejGmSj9KmpVDPHc95SlzfiEte428LyrJLjtB9i 9AWdBgSxzuh4dMIKjzQFldnDy/fUDYdF/XhfaTbKhf4ZDosrPb/6PspsIk4Q7wA6ZyP1 StdGOOGwknTp2paJ6rChvTKs6Wdpkt9A4ic2ymVpuwbXhIDSbna370975FIOm/2WiVeo m15g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=9Kt2I2+XqnkhlfULgoHgz4whi1Nt6p7BSx3I45E1gPs=; b=ovn6df5ZbRS26c6pJmVZoypEoeKhudypUfxINk2LDGdRRhXivTJKIr2ixlEIUw7V+j frcJ0OthmC3wIc4r57wA3tDyeTA0+c5pmopwFONK/1gCzeqW7SUrwYeg11ZfzlQcmHZx 4E8/fzgcB6SrSyhXqDXN1iiXZ7MEAlucAXKiAsqmG83YUO80fY+jJEQmJVZ4NJr+63o+ NS0IBlhYIwU4Dl8iNe6PYl75CHaV+YjEY/TLhyOaEug+LFXFISdjKCb++sbEawdZjJ6r BFhnhBMAfHlhGZsJs0hcbeX6B0rn9IV8VGcZYhjniw6bJv36ea0mqVjYlRYv2YU7wovO BLMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t71si15193361pfj.385.2018.01.22.00.57.20; Mon, 22 Jan 2018 00:57:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753815AbeAVIyb (ORCPT + 99 others); Mon, 22 Jan 2018 03:54:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34280 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753798AbeAVIy3 (ORCPT ); Mon, 22 Jan 2018 03:54:29 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 90ECEF3A; Mon, 22 Jan 2018 08:54:28 +0000 (UTC) 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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__ */