Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1669932ybt; Thu, 25 Jun 2020 11:15:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYV+F9hvA9Hy96q5aB8GOboizMHOjAw0Up/Zwk/3VnR5PbFlpOZaspJtnoLXkD3vvS7Hl7 X-Received: by 2002:a17:907:1104:: with SMTP id qu4mr29571115ejb.382.1593108911710; Thu, 25 Jun 2020 11:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593108911; cv=none; d=google.com; s=arc-20160816; b=jfKwIQ+DKNJV5bntpwOMxx8NQkGqPYmJCJEmenU1php0+ZEkf7w2ZYz3hoQRB+Va/e wqaz55lIehYMBRehjGvx42T0ZSj2D4qS4Db1cA6XAxdDXlmo9LyjqgtkzqWhzdStaY7k uJ60kYQ79d/5m+mVjLUnUJ/0u7fuD+D51eMuEAYTJndrYuDxYhmYEZl0b7juboFk3XXT Oo1AJEz8tCTdT3NWfKkEvlm01v0OckPmCXGc8kxHwoKG7X9HEGh9hvzYHkJqOX2+/cEl nfIbwQvUGLo6YWOOg+PwrtHkiYuq+yOYBb36mQyc3kZXpMjUn4D1r4HAKs3xPVmxwtcB QDIQ== 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=no7YVr00DbKKQ+yaF/NLUAHDlIF83IoT6Cfe6Ue8Rsk=; b=LgKYRWM8cHbO1Pi5RgB/6LePjxU3BDt8TzIEfPGo9rQ2nvvloRawnz4ufnLMxL41yb C8BpghquSVK6hpht5ZvSLy6ENgw+oGWTjfiW4iq2/h8d4m5p9BeRDvqi1efLw5bUOPA5 8RBXP4pYpJCepRmofNJB+tuGpQlDSTKmQLt2hTKY0Q57/YaQgIJekdEG27g4L67w+R4b CSKRPF7SfypC6OEjlo2EtdGusEiKjgWnQie3BZR/QPcHe6M+iiSNuYifUjXvy52jSvPE yBc7QR19UeDtI20UuCQb1Aj8IC4YkiZoDKrjJ6lrRoxgZr0gtlV+TRf3cVO9g/NW5yyE XpmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QWdvdGQM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si6914918ejb.453.2020.06.25.11.14.47; Thu, 25 Jun 2020 11:15:11 -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=@google.com header.s=20161025 header.b=QWdvdGQM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403837AbgFYQPM (ORCPT + 99 others); Thu, 25 Jun 2020 12:15:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389693AbgFYQPL (ORCPT ); Thu, 25 Jun 2020 12:15:11 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AB46C08C5C1 for ; Thu, 25 Jun 2020 09:15:11 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id f3so3514869pgr.2 for ; Thu, 25 Jun 2020 09:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=no7YVr00DbKKQ+yaF/NLUAHDlIF83IoT6Cfe6Ue8Rsk=; b=QWdvdGQMKWLXFCj/e3uSXu3nIed+fEpI9sixMesz0lmaFvY+vhrbPQCL2sfOwX5Xtz dJOd7qtWZudwGhWJ+gbv1sxQvZIkuGk6XpJScPP6djHS3Gjtpwa7FrqRlou+lHRJtZZZ E6lOy4qOE0EckdWmFhkcLT54pDwlj99vXre4+ksDWSXwsjNcFMNF4qwlEGG8e1VqTFDQ xJh5VQeFsuhh9JPP5l68M979tHfFPP91RJEzeejy+3inJ6Ch9ZslROLlJkFXrp0dB7vi CJdzxgSmmDz68iPXfh2R8CxQ1kMKTk1lzBLXZYMYpViAqBc0if/psRGS2Bx8e3vIkdLC XavA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=no7YVr00DbKKQ+yaF/NLUAHDlIF83IoT6Cfe6Ue8Rsk=; b=iagJfwJK722b+HidV35jM/wNi/HTAKVS1V3PLIJeAPHxbBDwSxA4Q/DwdC92dWTVG0 m/lpvokWh5gGugKokZnOOWqCTijmyV0yngJhZvaLhmjTmLbxg33Wr7iqeUVCJfukbKC7 /pkdyuzg6cGxYGG0vjirCOAdJoijr5GwwLs8/yPpq0np89iLbjW/j4ji748syoxWicA0 laoHdBwgsZ33I2x/KmYKKQf+AAw3LH4yAabmwKGd+/YVf1ZXIWT9Y5tj+xRsb+5owlml fnkA1O6wDc3+rUxX5+hpvSh4ayL9xYmkKWXoWDPhn/xRvs961JmjsDsX3DZVlJX1Of64 StLw== X-Gm-Message-State: AOAM532p/hMyiTHLmw/GK9vjEVTUY2hgAiLaJe4Gm5Jc4TFZE1LzFSz9 Cqkl6ECreVVGm0bg7zDgNV3oWw== X-Received: by 2002:a63:395:: with SMTP id 143mr23203113pgd.57.1593101710493; Thu, 25 Jun 2020 09:15:10 -0700 (PDT) Received: from google.com ([2620:15c:201:2:ce90:ab18:83b0:619]) by smtp.gmail.com with ESMTPSA id u12sm8450067pjy.37.2020.06.25.09.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 09:15:09 -0700 (PDT) Date: Thu, 25 Jun 2020 09:15:03 -0700 From: Sami Tolvanen To: Peter Zijlstra Cc: Steven Rostedt , Masahiro Yamada , Will Deacon , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH 04/22] kbuild: lto: fix recordmcount Message-ID: <20200625161503.GB173089@google.com> References: <20200624203200.78870-1-samitolvanen@google.com> <20200624203200.78870-5-samitolvanen@google.com> <20200624212737.GV4817@hirez.programming.kicks-ass.net> <20200624214530.GA120457@google.com> <20200625074530.GW4817@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200625074530.GW4817@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 25, 2020 at 09:45:30AM +0200, Peter Zijlstra wrote: > On Wed, Jun 24, 2020 at 02:45:30PM -0700, Sami Tolvanen wrote: > > On Wed, Jun 24, 2020 at 11:27:37PM +0200, Peter Zijlstra wrote: > > > On Wed, Jun 24, 2020 at 01:31:42PM -0700, Sami Tolvanen wrote: > > > > With LTO, LLVM bitcode won't be compiled into native code until > > > > modpost_link. This change postpones calls to recordmcount until after > > > > this step. > > > > > > > > In order to exclude specific functions from inspection, we add a new > > > > code section .text..nomcount, which we tell recordmcount to ignore, and > > > > a __nomcount attribute for moving functions to this section. > > > > > > I'm confused, you only add this to functions in ftrace itself, which is > > > compiled with: > > > > > > KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) > > > > > > and so should not have mcount/fentry sites anyway. So what's the point > > > of ignoring them further? > > > > > > This Changelog does not explain. > > > > Normally, recordmcount ignores each ftrace.o file, but since we are > > running it on vmlinux.o, we need another way to stop it from looking > > at references to mcount/fentry that are not calls. Here's a comment > > from recordmcount.c: > > > > /* > > * The file kernel/trace/ftrace.o references the mcount > > * function but does not call it. Since ftrace.o should > > * not be traced anyway, we just skip it. > > */ > > > > But I agree, the commit message could use more defails. Also +Steven > > for thoughts about this approach. > > Ah, is thi because recordmcount isn't smart enough to know the > difference between "CALL $mcount" and any other RELA that has mcount? Yes. > At least for x86_64 I can do a really quick take for a recordmcount pass > in objtool, but I suppose you also need this for ARM64 ? Sure, sounds good. arm64 uses -fpatchable-function-entry with clang, so we don't need recordmcount there. Sami