Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3868408ybb; Tue, 31 Mar 2020 13:43:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKPMkukM8fZMFQn3UNo3eYN3CcCq6GB1gFZ8F0BDuqy1vbOTXpbtW5JlKJpqxGBQNN5jwGc X-Received: by 2002:aca:dc44:: with SMTP id t65mr563701oig.176.1585687391178; Tue, 31 Mar 2020 13:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585687391; cv=none; d=google.com; s=arc-20160816; b=RQicPB72bK3dOoeNPYQGq1DK/+xlyMWX66fMmzmkJYYke6JHOyNFUd8gTKWrVxuA+r YIqGJD89Ip462MLj87EyIOhssHtTNl/LQtaIQX0YTl7LQYzTFtFgQc4daDtc3ae5bcdR NhYT51UvXfig6E5qNeNRrTXnN31+bRljQ5BdD3r5s0QOONBUFsw98rwqcGbdT4OExjzS dSODAdv++4YLUghxZ4ltG221qnn96MAUGqt8MOD6YW/Ij9VklANLB61umcTDNm9GJ5e1 KaX9cM++aDasBuN2irnx3O2pUhjKocZuEZMtS+RI4aFxTNvnoqQZ2N1Kik4GFEcwL3DJ yEKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6tH+zODD2TY2pB32niBjLq/y3AZwAV0LHkQ0NlUifq8=; b=TcDAGpBRfN2BoxMO+gGgPU4JXDj20g5IKviB7BWC8QPfSG+OoWynFFFRbp314oMh9C r2rczJz+d2B5egoloqEFVQUc+sMGhQCdYhfGnXpeR6LCK+7TsLWb2dvR6fKJqPenL54H 4dzX8Ktw4W8Ys515QF42E7M1WvpPiLE763oR/KPMY87k4SHPGQp2B5eHNNTLlO+jOfMi /XtEc+ikHuJWlZoA6M3Aet80wd8ZHd/+E9zodQWp5PwdYeKwpmfiX4/Xl9u5K68ucadQ /qDl16uN+qRQXdOsUSgWH5pnBpL13i4LrS6xHTksn47d6zsiUb+eFHDfNMx7aXXcwSec MCuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gB69s7S5; 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 94si7606340oti.94.2020.03.31.13.42.56; Tue, 31 Mar 2020 13:43: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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gB69s7S5; 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 S1728493AbgCaUk6 (ORCPT + 99 others); Tue, 31 Mar 2020 16:40:58 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38358 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727852AbgCaUk6 (ORCPT ); Tue, 31 Mar 2020 16:40:58 -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=6tH+zODD2TY2pB32niBjLq/y3AZwAV0LHkQ0NlUifq8=; b=gB69s7S5OwB45mm/PZKHmhMo4W kxWuFeo47HVg2/SumgcIlbH3J3gCLNoi5H4Qx+12uT8nhmrghvzzAndedpoANR8dX9VLYmdVQJXQL T4SrmZqD1eX51M5gVjUg2Rn3SOs+EMkExA7k6KHVoOykgaoC57FnGbGoSDTirKCIokKLuy4mhfa/f mpQcTkd9HjviMuNsQRF6BeyQMyipCkBnkrL6l9t8SZP09VbsX6UHaYlZhsdbmmn/DoW9LE90ubHtQ Md7CBlwUYNfcH8bQT5YPVDtTYFamCDL1EmTkqcrxWmyFuQaU3Ta676Uqf8YANfMSDgKmNZ2adnf3G 0hKtcjDw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJNgo-0003iR-1h; Tue, 31 Mar 2020 20:40:50 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id D918A98354A; Tue, 31 Mar 2020 22:40:47 +0200 (CEST) Date: Tue, 31 Mar 2020 22:40:47 +0200 From: Peter Zijlstra To: Josh Poimboeuf Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, x86@kernel.org, mhiramat@kernel.org, mbenes@suse.cz, Steven Rostedt Subject: Re: [RFC][PATCH] objtool,ftrace: Implement UNWIND_HINT_RET_OFFSET Message-ID: <20200331204047.GF2452@worktop.programming.kicks-ass.net> References: <20200326113049.GD20696@hirez.programming.kicks-ass.net> <20200326135620.tlmof5fa7p5wct62@treble> <20200326154938.GO20713@hirez.programming.kicks-ass.net> <20200326195718.GD2452@worktop.programming.kicks-ass.net> <20200327010001.i3kebxb4um422ycb@treble> <20200330170200.GU20713@hirez.programming.kicks-ass.net> <20200330190205.k5ssixd5hpshpjjq@treble> <20200330200254.GV20713@hirez.programming.kicks-ass.net> <20200331111652.GH20760@hirez.programming.kicks-ass.net> <20200331202315.zialorhlxmml6ec7@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200331202315.zialorhlxmml6ec7@treble> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 31, 2020 at 03:23:15PM -0500, Josh Poimboeuf wrote: > On Tue, Mar 31, 2020 at 01:16:52PM +0200, Peter Zijlstra wrote: > > Subject: objtool,ftrace: Implement UNWIND_HINT_RET_OFFSET > > > > This replaces the SAVE/RESTORE hints with a RET_OFFSET hint that applies > > to the following instructions: > > > > - any instruction that terminates a function, like: RETURN and sibling > > calls. It allows the stack-frame to be off by @sp_offset, ie. it > > allows stuffing the return stack. > > > > - EXCEPTION_RETURN (a new INSN_type that splits IRET out of > > CONTEXT_SWITCH) and here it denotes a @sp_offset sized POP and makes > > the instruction continue. > > Looking closer, I see how my UNWIND_HINT_ADJUST idea doesn't work for > the ftrace_regs_caller() case. The ORC data is actually correct there. > So basically we need a way to tell objtool to be quiet. Right. > I now understand what you're trying to do with the RET_TAIL thing, and I > guess it's ok for the ftrace case. But I'd rather an UNWIND_HINT_IGNORE > before the tail cail, which would tell objtool to just silence the tail > call warning. It's simpler for the user to understand, it's simpler > logic in objtool, and I think an "ignore warnings for the next insn" > hint would be more generally applicable anyway. I like how this is specific on how far the stack can be off, as opposed so say 'ignore any warning on this instruction'. Because by saying this RET should be +8, we'll still get a warning when this is not the case (and in fact I should strengthen the patch to implement that). Also, you don't want to suppress any other valid warning at that instruction. Furthermore, I really don't think we ought to worry about ease-of-use here, there's really not that many people writing x86 assembly. > But also... the RET_OFFSET usage for sync_core() *really* bugs me. Fair enough. > I know you said it's like an indirect tail call with a bigger frame, but > that's kind of stretching it because the function frame is still there. > > And objtool doesn't treat it like a tail call at all. In fact, it > handles it *completely* differently from the normal ret-tail-call case. > Instead of silencing a tail call warning, it adjusts the stack offset > and continues the code path. > > This basically adds *two* new hint types, while trying to call them the > same thing. There's no overlapping functionality between them in > objtool, other than the use of the same insn->ret_offset variable. But > it's two distinct functionalities, depending on the context (return/tail > vs IRETQ). I'm not against adding a second/separate hint for this. In fact, I almost considered teaching objtool how to interpret the whole IRET frame so that we can do it without hints. It's just that that's too much code for this one case. HINT_IRET_SELF ?