Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp603686ybb; Fri, 3 Apr 2020 08:33:05 -0700 (PDT) X-Google-Smtp-Source: APiQypJuJbRwvf0uRklcW5YXQDWnk5TntlQ2NRMYRJEMN3Hh3fsGDWuf5IHvlz6pi/KtyUNGW7vY X-Received: by 2002:a4a:3bd7:: with SMTP id s206mr7072929oos.89.1585927985013; Fri, 03 Apr 2020 08:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585927985; cv=none; d=google.com; s=arc-20160816; b=KMg1SJQk7AE0M+UMPgO9Dzs1CPm9p3WP5qj/0CD/BsiNb7EAERWxbhSJnB7M/mTaky biOsCjBwvgCF2EN4D+yHqG53RMpfPsu/B6cmPUkqek8Yb8WMy3dTMrO8An+5Q9HddZRb IWJe1wdH6f41BezN66xqjpP63Yxd9ttXW4UP2xCRX53fQVnht3bHM8PJhr8qw1mC5jmg n3qWdQRG+PZtXCTtx4REgDxOtGwkEfs3XGDy2AvaBh8+dMa3uuXHb/DMt1mEve7zQJL5 NkEanWdxg1/8ULzbJvaued0h5E6Vn2oOZ05NQMq9I+fGDiySsCeOVU9dNoGA0ZDzL0pj 2fbg== 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=wX+8AzXpUy9HNfAx/Y9ZR0Uh1eYbs9htUS3q1RBw3UQ=; b=GD9J8Gr65DtV3UFViZRcrVbqtYCn/T0bBawvprZLRvRWyDnqy6PaGrjDufmGwCvuXH XECdRuyItGPiAOZHMT9+cyqGZuGDYwlcL/pjewSy0Ivrvwohu1xPqQWtu1vIIl/v/F8F 1vOyAw2LmGPn7B5h4gEO7OrXcdZ3CWZuxLxKqAjHS8y8IQEuhywm+JN0uWzcL9mXRGh1 ldbAJClzDN6L1ysA+r3Bt6vIKg4+0sNLK8cksOp2H3lKwD9t4Qjj1ZkjOi/r4BF3Mg1Q Wiych40aL0cH/kHwna2MVoFGqqu1z701wuQYlpPgrDeqxXZ3XCICdipxVNbgtY+PELPa rO5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fBPZr1m7; 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 79si4005936oty.232.2020.04.03.08.32.51; Fri, 03 Apr 2020 08:33:05 -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=fBPZr1m7; 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 S2404257AbgDCPcd (ORCPT + 99 others); Fri, 3 Apr 2020 11:32:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37930 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404003AbgDCPcd (ORCPT ); Fri, 3 Apr 2020 11:32:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585927952; 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=wX+8AzXpUy9HNfAx/Y9ZR0Uh1eYbs9htUS3q1RBw3UQ=; b=fBPZr1m71KWsb8iI5jX9J42qPXhWSEdJxLn+wPEurH8L/vBuE8b5vlcXp8yEWYkb4JGHi5 5OzZ3K0ULokGsMhn4lMCG8qJ5DSSnkuwcBNwChv3LvnCjuaq0+NeXm+FnSBZ46vpOyTcCA OpBFnROaVrDvb/9/0xxcQ+dEfeIREMo= 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-457-2-NUm0cIPsSiHEn2Um8Y3A-1; Fri, 03 Apr 2020 11:32:30 -0400 X-MC-Unique: 2-NUm0cIPsSiHEn2Um8Y3A-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 D9FB21405; Fri, 3 Apr 2020 15:32:28 +0000 (UTC) Received: from treble (ovpn-118-100.rdu2.redhat.com [10.10.118.100]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04463100EBA6; Fri, 3 Apr 2020 15:32:26 +0000 (UTC) Date: Fri, 3 Apr 2020 10:32:25 -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: <20200403153225.jgakhibh2mhkvc5n@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> <20200403152214.3frjrlhxvodffghg@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200403152214.3frjrlhxvodffghg@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:22:14AM -0500, Josh Poimboeuf wrote: > 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 ;-) Actually, never mind -- I guess it wouldn't work because of inconsistent stack states and all that... -- Josh