Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp946004ybz; Fri, 1 May 2020 11:25:17 -0700 (PDT) X-Google-Smtp-Source: APiQypKPe66gwAmEUhkAZah76KWSGlQIMtvk6CztLScHFhF4Vj3vSmKm2uJYJ0ns5doO0V8yLbff X-Received: by 2002:aa7:c3d3:: with SMTP id l19mr4587201edr.14.1588357517053; Fri, 01 May 2020 11:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588357517; cv=none; d=google.com; s=arc-20160816; b=RbqGMFtw0VXNbBw6KpPiX9stj9AumPXXO0MMxSsy7zGwpMWiSB3bb2TOD9KnTe4uWl vDwxseSjtw6gX/hsi2BZXFkFwmQFK0GOVdMism39l1dP2XK5ehJscA2kVQWSd0KOFnEn 29rCdS0kljYD0d+nPNUxC41k0RidXyUGvJ3k34rStTyOU5iNbizLS0+uEBK95vncI7Fz KPDbiKulxE3bLaQ1DgfDIzlrZISGbF1naaIg8LlexK+Qo2nNsp1CtSADLdvkcalzWHA3 X6xMyg/ye59Ox9yEY7hj/3pQ7K/86W+LUqx1VG6+7erfps7TgLJP7+hiefS68xnrvvZd BHBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=Dase/MIEzf8YGQK9Io1Qw66Nb0/yWOwU4yf/15DRxWw=; b=FybhLMVlawvjl/+/rSkt0ewyBlJ5YVBxc77vxxwksLmUeh8WIA/m3GG+5u+eauozBy VZIvqdFATxM3E7A2Pd7EaXHrzwN95vMsrfN+4kBibareF3YYHgpCacQAseMs22+DvN7O q4mZbbqdBInlyj6bgA2oCm1YReDB/F85k8TRz9otr5bF3Aa5cct84vZXyDfr0FcYrNR9 bCxSzW1ybucLr1tl/jLHqcomJ9aFASpcEOdhyAgLe0zpJ1YTbhRlSZakGb0yA+nj8KtW FD6nhQjPJF2sz5lYVg2cpbgUID9AqNBM7MTB+fGeeJ8UlPye+iN6CKTG5ZsIVPuIm1en 5mXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v20si1950148edb.355.2020.05.01.11.24.53; Fri, 01 May 2020 11:25:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730743AbgEASWd (ORCPT + 99 others); Fri, 1 May 2020 14:22:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730664AbgEASW2 (ORCPT ); Fri, 1 May 2020 14:22:28 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68BAFC061A0E; Fri, 1 May 2020 11:22:28 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jUaIm-0003eX-A5; Fri, 01 May 2020 20:22:20 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id DEF711C0330; Fri, 1 May 2020 20:22:19 +0200 (CEST) Date: Fri, 01 May 2020 18:22:19 -0000 From: "tip-bot2 for Peter Zijlstra" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] x86/speculation: Change FILL_RETURN_BUFFER to work with objtool Cc: "Peter Zijlstra (Intel)" , Alexandre Chartre , Josh Poimboeuf , x86 , LKML In-Reply-To: <20200428191700.032079304@infradead.org> References: <20200428191700.032079304@infradead.org> MIME-Version: 1.0 Message-ID: <158835733988.8414.1414237916672825411.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the objtool/core branch of tip: Commit-ID: 089dd8e53126ebaf506e2dc0bf89d652c36bfc12 Gitweb: https://git.kernel.org/tip/089dd8e53126ebaf506e2dc0bf89d652c36bfc12 Author: Peter Zijlstra AuthorDate: Tue, 14 Apr 2020 12:36:16 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 30 Apr 2020 20:14:34 +02:00 x86/speculation: Change FILL_RETURN_BUFFER to work with objtool Change FILL_RETURN_BUFFER so that objtool groks it and can generate correct ORC unwind information. - Since ORC is alternative invariant; that is, all alternatives should have the same ORC entries, the __FILL_RETURN_BUFFER body can not be part of an alternative. Therefore, move it out of the alternative and keep the alternative as a sort of jump_label around it. - Use the ANNOTATE_INTRA_FUNCTION_CALL annotation to white-list these 'funny' call instructions to nowhere. - Use UNWIND_HINT_EMPTY to 'fill' the speculation traps, otherwise objtool will consider them unreachable. - Move the RSP adjustment into the loop, such that the loop has a deterministic stack layout. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Alexandre Chartre Acked-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/20200428191700.032079304@infradead.org --- arch/x86/include/asm/nospec-branch.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 7e9a281..b8890e1 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -4,11 +4,13 @@ #define _ASM_X86_NOSPEC_BRANCH_H_ #include +#include #include #include #include #include +#include /* * This should be used immediately before a retpoline alternative. It tells @@ -46,21 +48,25 @@ #define __FILL_RETURN_BUFFER(reg, nr, sp) \ mov $(nr/2), reg; \ 771: \ + ANNOTATE_INTRA_FUNCTION_CALL; \ call 772f; \ 773: /* speculation trap */ \ + UNWIND_HINT_EMPTY; \ pause; \ lfence; \ jmp 773b; \ 772: \ + ANNOTATE_INTRA_FUNCTION_CALL; \ call 774f; \ 775: /* speculation trap */ \ + UNWIND_HINT_EMPTY; \ pause; \ lfence; \ jmp 775b; \ 774: \ + add $(BITS_PER_LONG/8) * 2, sp; \ dec reg; \ - jnz 771b; \ - add $(BITS_PER_LONG/8) * nr, sp; + jnz 771b; #ifdef __ASSEMBLY__ @@ -137,10 +143,8 @@ */ .macro FILL_RETURN_BUFFER reg:req nr:req ftr:req #ifdef CONFIG_RETPOLINE - ANNOTATE_NOSPEC_ALTERNATIVE - ALTERNATIVE "jmp .Lskip_rsb_\@", \ - __stringify(__FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP)) \ - \ftr + ALTERNATIVE "jmp .Lskip_rsb_\@", "", \ftr + __FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP) .Lskip_rsb_\@: #endif .endm