Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2882921pxa; Tue, 25 Aug 2020 06:07:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXu9BvVv+3DQEEOQg1mFrzIrNgzEUZqUMNPQs4XEdvDYOOGUhrXKGSMsbDdlI1jN8MT88H X-Received: by 2002:a17:906:394c:: with SMTP id g12mr9366480eje.255.1598360854111; Tue, 25 Aug 2020 06:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598360854; cv=none; d=google.com; s=arc-20160816; b=w8w88HKssGfnur8L+xyEgAIvtHbTbU+k7PR3iRnmJ/sKXaCiQCpgFZGbXnw/BZcCTl t+W39O6gAvTL5zlgNHpkIGUFVz2gGnoMA+jPUHev+ELR/3kcPlku+ksZdKrO06Q5oTBv p3Ph4GIgJiC8QJsbGwrVgQtJDD9d8vKlo3BxgneDXHiNUkafOuqKtir3TqwJ8T7yu5GY UwIV7no1jznsiwECVbx4hJ1WglwdVo1AoUl9nAqtRVUnRdmknB/PqNieZVzkSGmkDQnu NFI7WewKg4gwgfvGQ1I1RSLHZ1HqARo2Qc9X/M9x6j9CpYkA0ZkvVX89A5wHAJAlA/5d /+Mg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=CiFYE8jzaodhVA5L8Zma5x1CexylW0/iR0TiifPXNJU=; b=g+Atl/BnTY53RBUT3la6EtwfQz8mDdVyIy/C2RAOb+i8+/4FtdZpT2JxDGAsn9wOi1 mV4EdzrJ7lq32MVLeXgd8B8s9HrR0VkLqzJmddKbyAppYuVN0zp6+jzNI62ip3A+ydIW /fDCtBW4luY0C8utfa+bNn9dBqQfyUgkxselLcGjtuUx8SOlqNxMQU/kBYsLch3oqhCq 2p2F9MZNy91uwrQTcvza8I0vzwVu7naY5Q1qj8zWLhyVs0Z9NdBe71Vzf/YFkyAzXET0 m26Rs6V/m0ui21xRupdj1CdU7XnQywg64RKlD995wSxXsKPJTNlhFIcyf/9AD7QKthBQ P1hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tgoyj9Ug; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz6si10235355edb.350.2020.08.25.06.07.11; Tue, 25 Aug 2020 06:07:34 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tgoyj9Ug; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726953AbgHYMby (ORCPT + 99 others); Tue, 25 Aug 2020 08:31:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23102 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbgHYMbx (ORCPT ); Tue, 25 Aug 2020 08:31:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598358711; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CiFYE8jzaodhVA5L8Zma5x1CexylW0/iR0TiifPXNJU=; b=Tgoyj9Ug0JDpFUwEgqWJTuiVMzCPRowmQGAsMTwExrIl6UjlmHrG+en/b2CmEjzTjXtrvE 7GRmBF5VCQWSqp0ZevLfjtliHYMgvukSN1hc4RPpOB/2KUPV3Gi6ARb9DzFMn5Z+UbHraG itiREyb/fC52HqpuzFxX0VIdrNgTY38= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-163-kGxfKyW5PS66R_ibxxfTOA-1; Tue, 25 Aug 2020 08:31:49 -0400 X-MC-Unique: kGxfKyW5PS66R_ibxxfTOA-1 Received: by mail-wm1-f69.google.com with SMTP id z1so666368wmf.9 for ; Tue, 25 Aug 2020 05:31:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CiFYE8jzaodhVA5L8Zma5x1CexylW0/iR0TiifPXNJU=; b=I806nqQ9qd6RZ35I59pJ8EOLTxeKSjz6+fwfHYTFQFjz3LSIMsrZeuR27uytziMOCn /dh2bIiD9YHFbix+VZ0E0T8LDgggVkbcfSzBg/86/MBDsRy+yVsR4ZGrVr9/yc46uMf+ ZOXKNn0V1DhJnocU5goayIxqxd/A4l06mTKX9K3UKCqSabUZyDSJwd1oe8/b6pOGoDFA lfP+E69rBbt+IY0uyoFgkArdiyGjf73WOOsSRfq8op/GfOytkJl50mZiWdGZGyiKzFUg jI6k4phc84FUqX+SIF+0Y1I0GIJQb6nJJ17v3c/ErrKIjEYmHZgiahJK8a8LHps6aroB e9nw== X-Gm-Message-State: AOAM5334YwI3f4E1VOvLryts1dmuRkwKp0uHk+SaFTm2YcruQatKrRZ0 215SWGzS0Ugr6C1sZWLfrIxzj/xhX7IlzZBxGFgC3MTUNNJqg+uwUeby/G2vgCfGrO5aotZo1AW VbTbnZBQm1Le4OMqKtL96O27n X-Received: by 2002:a05:600c:2242:: with SMTP id a2mr1919348wmm.116.1598358708495; Tue, 25 Aug 2020 05:31:48 -0700 (PDT) X-Received: by 2002:a05:600c:2242:: with SMTP id a2mr1919332wmm.116.1598358708301; Tue, 25 Aug 2020 05:31:48 -0700 (PDT) Received: from ?IPv6:2a01:cb14:499:3d00:cd47:f651:9d80:157a? ([2a01:cb14:499:3d00:cd47:f651:9d80:157a]) by smtp.gmail.com with ESMTPSA id j7sm5927284wmj.38.2020.08.25.05.31.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Aug 2020 05:31:47 -0700 (PDT) Subject: Re: [PATCH v2 9/9] objtool: Abstract unwind hint reading To: Josh Poimboeuf Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mbenes@suse.cz, raphael.gault@arm.com, benh@kernel.crashing.org References: <20200730094652.28297-1-jthierry@redhat.com> <20200730094652.28297-10-jthierry@redhat.com> <20200730150341.udqnykbw7yfsjvin@treble> <1a078563-001d-c666-d2f5-9291f0efd35a@redhat.com> <20200731140441.cpzr4lrlkcrmoz2c@treble> <6a314dba-4086-717b-d226-6c292240a3e9@redhat.com> <20200803213506.hlbpdlitom7sjtqo@treble> From: Julien Thierry Message-ID: <8fe8199e-a2f3-513f-6cdf-c61d7936dede@redhat.com> Date: Tue, 25 Aug 2020 13:31:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200803213506.hlbpdlitom7sjtqo@treble> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/3/20 10:35 PM, Josh Poimboeuf wrote: > On Mon, Aug 03, 2020 at 01:13:14PM +0100, Julien Thierry wrote: >> >> >> On 7/31/20 3:04 PM, Josh Poimboeuf wrote: >>> On Fri, Jul 31, 2020 at 08:00:58AM +0100, Julien Thierry wrote: >>>>>> + cfa->offset = hint->sp_offset; >>>>>> + insn->cfi.hint_type = hint->type; >>>>>> + insn->cfi.end = hint->end; >>>>>> + >>>>>> + insn->cfi.sp_only = hint->type == ORC_TYPE_REGS || hint->type == ORC_TYPE_REGS_IRET; >>>>> >>>>> What does "sp" mean here in sp_only? >>>>> >>>> >>>> Stack pointer, like in CFI_SP. When objtool encounters one of these hints, >>>> it starts to only track the stack frame with the stack pointer (no BP, no >>>> drap register, no move to temporary registers). Just trying to make some >>>> sense of this corner case. >>> >>> I think that's not quite right, because ORC_TYPE_CALL could also be >>> "sp_only" in some cases, by that definition. >>> >> >> But in that case the code will still track when/if the CFI becomes pointed >> to by BP. >> >>> The call to update_cfi_state_regs() is really regs-specific, not >>> sp-specific. >>> >> >> I must admit I don't really understand what "regs" is and why exactly such >> an exception in stack state tracking is made where only operations to SP are >> taken into account. > > "regs" is a special type of stack frame, usually for asm entry code, > where the frame is actually an instance of 'struct pt_regs'. So if > there's a variable associated it with it, maybe it should have "regs" in > the name. > > Though I think non-x86 arches will also have regs frames, so would it > make sense to just make the unwind hint types a global multiarch thing? > They could be renamed to UNWIND_HINT_TYPE_REGS{_PARTIAL}. Then there > wouldn't really be a need for the "sp_only" thing. > If having regs frame means having a pt_regs on the stack when procedure calls/return, then yes this will probably be the case on most archs (it is for arm64 at least. However in that case, arm64 still builds a stack frame and sets the frame pointer, so only handling SP operations doesn't make much sense for arm64. Also, things like ORC_TYPE_REGS_IRET don't have a use for arm64 (but maybe for other non-x86 arches it does?) In the end that's why I left the unwind hint types as arch defined. It seems like every arch will have their specific semantics they might want to let objtool know about. -- Julien Thierry