Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1863876ybb; Thu, 2 Apr 2020 08:41:52 -0700 (PDT) X-Google-Smtp-Source: APiQypJOXRzs9OjV5UA34bJ3gvuh2yvyktRwsvKGAvuCsPLsogtK2ECfE7TCxdruyv7jZTPpM6Up X-Received: by 2002:a05:6830:55:: with SMTP id d21mr2960794otp.29.1585842111933; Thu, 02 Apr 2020 08:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585842111; cv=none; d=google.com; s=arc-20160816; b=Ut5cxeM8QX9LGiYeRtNcttpDa7sVy+1xfgcgeqCzinlD7sHbDhLFIuy3F2oKBuQCbI sYPKw9GGng9qI1Frq28Ky1oQ9EH2swkOBZaJ898twZsFF/8jnn4GsOMmProCj8s+jShw /5RES9meFhor4cCBdXjCtRTIGq4KaLgvD9aycpCwhAuTiAEmx7g1vBcmhQXcWPR3zM5c Uoc2CfeCmWb9z+ihj1xCttu+nJ5aQDabTsXb7yB/djWUns4sCBmk4lMfvjXbzfMNebR4 Sn8WSud+eF+p88JlzYBavtujTOvyAC+bxQu6qhBZO7z7jjF1iSjysgjeeSvUCwOEAHrK SE6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=esjjBZxKnGNy+IIHWT7KnlJCrv+OC0h6w5d5h2JWV7c=; b=mS3/kfknWmMDhuuMXbgZUqTe6+OH5iySTkwHXYJIrCHYH+NNFlTzoMzGyIWImg1siX /J5fU5mpIYgGfV261ZUbFQdrxtZT+h3Ubl9fv2QJuwHYQOZeLMa3yu/f7tXAd90BWB9L J8Z/4OSp5IPg0nOwyOhWrsh3+c9R9kqDtrz4lR1rWQxWLPNjXLnauVM4Zp3ylTUvLueX kTI/ni8e5DKYgQJyOSv0FbWFA/+jaDfgV4N53EnwWdShrdlV+h2jzQj3jtVNguvselpF ay+l3M2ea08N+Zpq5Kj7YF7nyNCtWkj/fVgHN9CAffn+EjZNefhbAEGM+ieAfPmAG/J/ cCFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Ar1cQ7cc; 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 i6si2400241oor.75.2020.04.02.08.41.36; Thu, 02 Apr 2020 08:41:51 -0700 (PDT) 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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Ar1cQ7cc; 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 S2389416AbgDBPk2 (ORCPT + 99 others); Thu, 2 Apr 2020 11:40:28 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:33142 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388972AbgDBPk1 (ORCPT ); Thu, 2 Apr 2020 11:40:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=esjjBZxKnGNy+IIHWT7KnlJCrv+OC0h6w5d5h2JWV7c=; b=Ar1cQ7ccV2xZGXsK/bV7FKiDyY n4ihXvv0gfo/dEQWwHTG9Xsy+1cskV86+pyGqRkswFzaUB5ubPEUinmc69JVK0/T0YEfS0cZ9m/W4 k52nbYod9CIaa1U2XhbmtjuD3nNXS7PUwSoNz0MkAqTWluVbBIJ3RMqkGTPvv5oEXkdkfYQhuQPS8 64IF49iZupFeDD4DI9HYjfGsGqpiPV9lkP2eptc1sawEnYmFCFgYK5zwEKVWzkpCVa8vtYq6Iuo7d y3crhlCEQ/0u8zDGRtPlP5hLydCRKB7yfI8WnBsJ+jyvXvmF2jdSQv1ZtSfE0U6amjuXPTwTlXY4d 8svU6Xkg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jK1xA-0003kO-GG; Thu, 02 Apr 2020 15:40:24 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C3A48306089; Thu, 2 Apr 2020 17:40:22 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id AE9B92B0DED96; Thu, 2 Apr 2020 17:40:22 +0200 (CEST) Date: Thu, 2 Apr 2020 17:40:22 +0200 From: Peter Zijlstra To: Julien Thierry Cc: Alexandre Chartre , x86@kernel.org, linux-kernel@vger.kernel.org, jpoimboe@redhat.com, tglx@linutronix.de Subject: Re: [PATCH 4/7] objtool: Add support for return trampoline call Message-ID: <20200402154022.GG20730@hirez.programming.kicks-ass.net> References: <20200402082220.808-1-alexandre.chartre@oracle.com> <20200402082220.808-5-alexandre.chartre@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 02, 2020 at 04:31:05PM +0100, Julien Thierry wrote: > My understanding is that once you find an intra-function call, either you > hit a return, ending the branch, so the return should undo the modification > the intra-function call did (whether is it a retpoline return or not). > Otherwise, the intra-function call branch will need to reach an end in some > way (e.g. hitting a CONTEXT_SWITCH instruction, calling a > dead_end_function). > > Am I missing something? The thing is basically doing: mov $n, cx 1: call 2f 2: dec cx jnz 1b add 8*n, sp So it does N calls to self, then subtracts N words from the stack. The reason being that the CPU has a return-stack-buffer for predicting returns, and call/ret being naturally paired, that works. The above is a software flush of the RSB.