Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp594206ybb; Fri, 3 Apr 2020 08:24:12 -0700 (PDT) X-Google-Smtp-Source: APiQypL//aJv+fLspoOi727Kjen0O+iGgmLATanXQ5Em34wY8iDv9Y22TFn/2W0KaerhIt7xUl19 X-Received: by 2002:aca:f384:: with SMTP id r126mr3314914oih.41.1585927451894; Fri, 03 Apr 2020 08:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585927451; cv=none; d=google.com; s=arc-20160816; b=FFuUd5r3WV9NhLJ6isghFM2Cr4WRkVdDJl6NqgtUAs/T1i84QC5C5UeKQyfEQORtDG wKdqccOBCA1sKcquUwst2Nho1Ir4CgjlUhoJJ98HElfXDh2LC0sq7p50D5ri6zrRVgXx Nh5HtENUtayLUmlYVZEmyeKSdP+mjoXgJ3zWmqX96XUyUoHDF5qTnaoCGTBNDmLRd3+T f9HsBA7nTxUJP/229grXHVoki1o7uyP1gFhiAG7ZniZZ5GHDyh9yeHR2nCZtvEjpHogP liY+BJh2CEdcgAaWsrtDHYzkPLkBvJEvFuhpYltptg/sbnDgdYN3dfpvuNqlpjeRHifM qxiA== 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=f40ZvcSFesg6WkXpe37yjNDHPlvg5D7KyMxjtTJXaso=; b=l5RgmlTmPp7mRJ21jKCrp4+hfMIP7aJhulYFJC9V3BWOLaJTdUv4vKFv9E6WdhUUeX SqXglBNu1iMJQjrtIAinJCMUiheG4Xx/QCdpjFUoulUSTDKo64C1wLfUvIa5lRdzq0jo SBJ+jZvBUrjIzvYCmQ3OcmGDsWMbULQpFdyjrC1r1Kv/vK5PoaLDSr5an0fbcczlqemR SptjFgFXfEQiYk/j3pmSvuSdSlg+aLVxecqCCClipGiQox7Sv0V+eBzbNA0L0JQ6Bh8w Rw3q2CpuT+GKQpzFmkEX4xCSu3ES9kE84fJykaZmzTVqbjIePQaVzmfu9XkFAsEqL4vz H1NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GBHDfwYp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d145si3728025oob.68.2020.04.03.08.23.56; Fri, 03 Apr 2020 08:24:11 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GBHDfwYp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404162AbgDCPWV (ORCPT + 99 others); Fri, 3 Apr 2020 11:22:21 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:56991 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404088AbgDCPWV (ORCPT ); Fri, 3 Apr 2020 11:22:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585927340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f40ZvcSFesg6WkXpe37yjNDHPlvg5D7KyMxjtTJXaso=; b=GBHDfwYpOLrzn8UeMBoQ11zAISNPvjMx/iS/vIzFfbJz/IgsEUA6J/MJZIWb/wemhHY3SV 5QII9XLCKe3WIFlgxhZxpH1VM59H/YuCp1N0KZkctS4sM/2WNiSlu05ruMRpT78DiBzWAg e27HZczmvY1jWDpmw5ks/i7bINcsoYM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-YVNTUG_5PbSd6BB-jvKTCw-1; Fri, 03 Apr 2020 11:22:19 -0400 X-MC-Unique: YVNTUG_5PbSd6BB-jvKTCw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB67710CE7A1; Fri, 3 Apr 2020 15:22:17 +0000 (UTC) Received: from treble (ovpn-118-100.rdu2.redhat.com [10.10.118.100]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF46F10027A3; Fri, 3 Apr 2020 15:22:16 +0000 (UTC) Date: Fri, 3 Apr 2020 10:22:14 -0500 From: Josh Poimboeuf To: Julien Thierry Cc: Peter Zijlstra , Alexandre Chartre , x86@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de Subject: Re: [PATCH 4/7] objtool: Add support for return trampoline call Message-ID: <20200403152214.3frjrlhxvodffghg@treble> References: <20200402082220.808-1-alexandre.chartre@oracle.com> <20200402082220.808-5-alexandre.chartre@oracle.com> <20200402154022.GG20730@hirez.programming.kicks-ass.net> <20200403151757.lhhia7pzqptvlqz5@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200403151757.lhhia7pzqptvlqz5@treble> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 03, 2020 at 10:17:57AM -0500, Josh Poimboeuf wrote: > On Fri, Apr 03, 2020 at 09:11:55AM +0100, Julien Thierry wrote: > > > > > > On 4/2/20 4:40 PM, Peter Zijlstra wrote: > > > 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. > > > > > > > Ah, lovely... Maybe that's where SAVE/RESTORE unwind hints could be nice ;) > > . > > > > Otherwise, I don't really have a good suggestion for this... > > Peter, I think my previous idea for UNWIND_HINT_ADJUST stack_add=8 would > work here? And if we're going to need that hint anyway, maybe we could get rid of the nasty arch_exception_frame_size for the IRET thing and just use a hint there after all ;-) -- Josh