Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp554701ybb; Fri, 3 Apr 2020 07:46:09 -0700 (PDT) X-Google-Smtp-Source: APiQypIltIquGzntFXzBsiWxIFRQEwiTXqQFiS5isNkrzGsTwFLvRgHoKHfYoRsGw2FDUZRy1XvK X-Received: by 2002:a05:6830:1495:: with SMTP id s21mr7014603otq.35.1585925169551; Fri, 03 Apr 2020 07:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585925169; cv=none; d=google.com; s=arc-20160816; b=dL02sS6pKDaEH6pLGW+p4EV/gUDiHDSfcBWjtEMekZfh8ijB7V+rlsS7yvQ5yJGQNm 9h+l+NzXPP0kz8SAvZo2wraeDGUd1UX+X2MOvJoLiMeOjZvxHYrmeurnPuVtLid51Guj CkChyts6055kEv3XjYEPrkXcOYpe3Oap/DCbBs2Hnygr0OWCgBJRa+LhuPHBQ66RlWRh rcIKQjCRFRQldDqCBE5UNvh/6dS8bvv0B1KoUJKAcVi80yoeCf+PrhgLlyrRXGcqIeiX wM4d8Pme+R6XoLzEfOL52/WMMuMyV4F+9cBty3oEKu8dTkelN//X1+lKQDot7mzLGMxu j7yA== 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=dzD7eus7lBjgG30NcNG/sOIuLevArnMNUmhmE93sGjg=; b=B9Hqj6qUnLBzWsrtXt7PfpQW7PHRYK9l+WmN+H6FVsdQj4+XUv+7T+HdX1FvwI5GFt yKSfFvd6E3AlrkTeQc8tfZix8B0IQc+eq7iVdY09HXuTGwqVkEIv+kYIp0kAQSboIoC9 ThMJew7bsoP6eev4XAiEUcW+mXt19AG07O2a8/93ddJVDAlVIYfHIlxfmH9Udy0Lg60W azwG1gRSZ/ypuXS8uGlFGYc5oUJHkPxMsvPOdmVRqqDCZIwz2tEdu9LGGvU0JBy7XiBD QxdNZNgtrroy/5isyaPpc4DwSFm5uAycy0uli34Cu2/ZT4IRVWxMFJl0qzRvmBaq9Yxu dA5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NRWpWQ9V; 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 j8si3711781oib.260.2020.04.03.07.45.56; Fri, 03 Apr 2020 07:46:09 -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=NRWpWQ9V; 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 S2391087AbgDCOod (ORCPT + 99 others); Fri, 3 Apr 2020 10:44:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:38965 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727431AbgDCOod (ORCPT ); Fri, 3 Apr 2020 10:44:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585925071; 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=dzD7eus7lBjgG30NcNG/sOIuLevArnMNUmhmE93sGjg=; b=NRWpWQ9VFzHP3rcwbGp4n+rHcnljAYu1nn8M1xbs8O00vFFoveh/cYNW3hko+LtyblCx3X ld86gbrXqHKOpS3BD8bLg2pz1vuyNtTw/QdF+KHjs+xqW4oOH9szwAfbCDGMnhVWQ5+vm+ +cUkWxRaA4WOA97UjqP2DbZ1tqdw2PA= 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-65-NcL3yS1iMNaO6R2a5WJWIg-1; Fri, 03 Apr 2020 10:44:27 -0400 X-MC-Unique: NcL3yS1iMNaO6R2a5WJWIg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4BD488017F5; Fri, 3 Apr 2020 14:44:26 +0000 (UTC) Received: from treble (ovpn-118-100.rdu2.redhat.com [10.10.118.100]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C0D75C1D6; Fri, 3 Apr 2020 14:44:25 +0000 (UTC) Date: Fri, 3 Apr 2020 09:44:23 -0500 From: Josh Poimboeuf To: Julien Thierry Cc: Alexandre Chartre , x86@kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, tglx@linutronix.de Subject: Re: [PATCH 3/7] objtool: Add support for intra-function calls Message-ID: <20200403144423.lqcvdhi54cl3btvj@treble> References: <20200402082220.808-1-alexandre.chartre@oracle.com> <20200402082220.808-4-alexandre.chartre@oracle.com> <20200402154919.2c6shw4hfreagchg@treble> <3d075cb2-8d99-5ab7-4842-efef1964247d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <3d075cb2-8d99-5ab7-4842-efef1964247d@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 09:01:38AM +0100, Julien Thierry wrote: > > > On 4/2/20 4:49 PM, Josh Poimboeuf wrote: > > On Thu, Apr 02, 2020 at 01:53:49PM +0100, Julien Thierry wrote: > > > Hi Alexandre, > > > > > > I ran into the limitation of intra-function call for the arm64 support but > > > didn't take the time to make a clean patch to support them properly. > > > > Can you give an example of where arm64 uses intra-function calls? It > > sounds sketchy to me :-) Is it really needed/useful? > > > > So the most notable/necessary one(s) is the one in tramp_ventry [1]. This > macro is used as the begining of exception handlers for exceptions coming > from userland. It was added as part of the mitigations of spectre (v1???). > > To give some context, x30 is the register that "ret" instruction will use as > return address, "bl" is the equivalent of x86 "call" and sets x30 before > jumping to the target address. (However, it doesn't have a special semantic > for exception returns) > > Note: I believe the comment about the return "stack" is about processor > internal state (speculative thingies and all) rather than the actual stack, > since the stack is untouched by that code. But I don't know the actual > details. Ok. So another Spectre special case. > There are also some in arch/arm64/crypto/crct10dif-ce-core.o , which is > probably full of fast, smart and optimized code I don't understand :) . So I > wouldn't feel confident commenting on whether those intra-function calls are > needed or not. Glancing at that code, there's a macro which has bl to .L__pmull_p8_core, which, because it has a local label prefix, doesn't have an ELF symbol associated with it. I bet changing that branch to "bl __pmull_p8_core" (and removing the unnecessary .L__pmull_p8_core label) would fix the warnings. So IIUC, this is actually a case where the warning found a cleanup, albeit a trivial one. > Last I found is in qcom_link_stack_sanitization() [2], but that's just a > workaround for a very specific hardware. In my local tree I just put the > function as STACK_FRAME_NON_STANDARD. But the code just saves the return > address, has 16 call instructions that just call the instruction after them, > restores the return address and lets the C-function return normally (and it > somehow fixes something for that hardware). Yeah, like Peter said this sounds like x86 RSB stuffing. More Spectre nastiness. So it sounds like the only valid use case for intra-function calls is Spectre BS... So, at the risk of possibly contradicting the past version of myself, my current feeling is that we should annotate such cases, and then warn on non-annotated cases like the crypto example above. There's nothing normal about these Spectre mitigations, so it's ok to add annotations to such craziness. -- Josh