Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp114681ybt; Thu, 25 Jun 2020 16:50:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyovefBI52IXyo6p+4KMKJAHzd7DWUDfxCgmPAl6toHoTTVhrdpnDj3cpsEFiqiqBanudFl X-Received: by 2002:a17:907:9c6:: with SMTP id bx6mr217060ejc.43.1593129040651; Thu, 25 Jun 2020 16:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593129040; cv=none; d=google.com; s=arc-20160816; b=M0/lCIg6sfbG0U53ME5PJpz54FUSLGZg40Wf9B5H8B9cTVGig75tv9zERNTf4gnUbD 2zlNHgrA3b74+TjbTloTjzTzFmrEmEahAKhRcob4vqcjUd95gRqcgQN9NCWMQGqAQmdQ 3slPKRWFn14l954rHNVgFq6w/0ODuLl66ZroNJ0OQAnWnxZMww/a6Dsm0vpgu8cdAySr RxBbhpfib7ns8O7oPmucapDb7fCkTnGUHGBI7jsH+CYW1miQiQ0RssU7qrni4d7sztvj QCUgpZloLv9JnPNev1+uBZPQVkfBMlZ2s8dr54GXbcLhyKX9xu5bLshyVMfyni1P4stx H7pg== 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=jrKbnig9QFRhNV6K+9Xoewg6ga8WAeyx+cHHuuAPHlw=; b=UufHAngLhxt5yKFU51d1OtgTEwko2XajXTfwTJPkVMYQAnLfFSK4Q0PodVWKLhf3BA qIf3Ds2lIs652H1CJ5YXW56AmUqZtqhmnonQjr1QevwqIZgEmpgV8dSnmAdPqNhWOElF xETGNGWs/fXFhR1xjHe5b+3I/iM8Eqr9e/6cppU4rpyqdpu0+peDDoFJSI/KUcYWag7+ ksrDKqDnU2f1aP207t7UATHVEizuk/xHGFnqAE0y75nOdPelcm+tqmG5hai5qAlvyNlA v+/loUtNIMHxTt1tZ/gWcW81PeCl9GVlvBcd2QP7Cehpp2XrwpIFBpizIQIf3YbsnOOg qhDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vjDkS1ct; 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 dm17si20988873ejc.707.2020.06.25.16.50.17; Thu, 25 Jun 2020 16:50:40 -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=vjDkS1ct; 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 S2407565AbgFYWkw (ORCPT + 99 others); Thu, 25 Jun 2020 18:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405127AbgFYWkv (ORCPT ); Thu, 25 Jun 2020 18:40:51 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C57FC08C5C1 for ; Thu, 25 Jun 2020 15:40:51 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id f6so30206pjq.5 for ; Thu, 25 Jun 2020 15:40:51 -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=jrKbnig9QFRhNV6K+9Xoewg6ga8WAeyx+cHHuuAPHlw=; b=vjDkS1ct1augvE723FB1+5WPfwzfajqrtAMZRYo0dTgN5aCXnRVc3P9qUPioCfxE8z zC7awdkoztnyQMH6KrmbAZB+gM3wWozXAHd+5NlrM3zI27aeWEvQfCn5USOdaH1puVqn n+mQi5qyO3ediG9Fy54lBVH83MmSL8Q2+fhkZaaYmruol7QRBk3j2qUtL3wKRM4CV0O8 azUuw9K3+1ptvV6oCv9rk3Jq7Xiiwx3xcCAujAANMFcNjec9DVvR2cW5QPifyHeO10Cg wZRh3A465gRs3JRICOc49N6SHyq0l8hzKjlz8ZyjwxNNSR3yFRHh1hd8rpoRIRuIIfw5 Pg0g== 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=jrKbnig9QFRhNV6K+9Xoewg6ga8WAeyx+cHHuuAPHlw=; b=QAmx0HimXVrNhuLKJIvmywqYKbwk/8uUWgnmukuJEutfBFDnqrR1ShC1xHFDLKAxBg o+iDEaD8hAESIx6vHdv49pKUwMxMeyRK93nRlBiRge5NOrwBQcjLv7trssETpxQS0WO/ dOMOBLhIrHE3HDnzDGiqvvdmFoKw4WodpBSgwxInBL/LpuyxDunbwHIRcOhd/Ml5KJZn OO1482HO4TGxOQWKNnnxmh7qMT/3DEZrdtAHjPA6g1pvZFSdcTSiy1qpkY0lp0BZseGY IBD7EJAOQHylJWxb1/qm9sS9BsMacoikySfWd3eFArSgP/UY6jr2RzOuJXxIlJUxJL9v /5/w== X-Gm-Message-State: AOAM5305Zdto0luYK/8yzLgfjtj1AjfbISBbW0lSx8pOEd63OSy84EA7 jz7QRkj89T6OL00kSwL6YRFXZA== X-Received: by 2002:a17:90a:7c4e:: with SMTP id e14mr256081pjl.52.1593124850158; Thu, 25 Jun 2020 15:40:50 -0700 (PDT) Received: from google.com ([2620:15c:201:2:ce90:ab18:83b0:619]) by smtp.gmail.com with ESMTPSA id k92sm9112547pje.30.2020.06.25.15.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 15:40:49 -0700 (PDT) Date: Thu, 25 Jun 2020 15:40:42 -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, Josh Poimboeuf , mhelsley@vmware.com Subject: Re: [RFC][PATCH] objtool,x86_64: Replace recordmcount with objtool Message-ID: <20200625224042.GA169781@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> <20200625161503.GB173089@google.com> <20200625200235.GQ4781@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200625200235.GQ4781@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 10:02:35PM +0200, Peter Zijlstra wrote: > On Thu, Jun 25, 2020 at 09:15:03AM -0700, Sami Tolvanen wrote: > > On Thu, Jun 25, 2020 at 09:45:30AM +0200, Peter Zijlstra wrote: > > > > 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. > > This is on top of my local pile: > > git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git master > > which notably includes the static_call series. > > Not boot tested, but it generates the required sections and they look > more or less as expected, ymmv. > > --- > arch/x86/Kconfig | 1 - > scripts/Makefile.build | 3 ++ > scripts/link-vmlinux.sh | 2 +- > tools/objtool/builtin-check.c | 9 ++--- > tools/objtool/builtin.h | 2 +- > tools/objtool/check.c | 81 +++++++++++++++++++++++++++++++++++++++++++ > tools/objtool/check.h | 1 + > tools/objtool/objtool.h | 1 + > 8 files changed, 91 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index a291823f3f26..189575c12434 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -174,7 +174,6 @@ config X86 > select HAVE_EXIT_THREAD > select HAVE_FAST_GUP > select HAVE_FENTRY if X86_64 || DYNAMIC_FTRACE > - select HAVE_FTRACE_MCOUNT_RECORD > select HAVE_FUNCTION_GRAPH_TRACER > select HAVE_FUNCTION_TRACER > select HAVE_GCC_PLUGINS This breaks DYNAMIC_FTRACE according to kernel/trace/ftrace.c: #ifndef CONFIG_FTRACE_MCOUNT_RECORD # error Dynamic ftrace depends on MCOUNT_RECORD #endif And the build errors after that seem to confirm this. It looks like we might need another flag to skip recordmcount. Anyway, since objtool is run before recordmcount, I just left this unchanged for testing and ignored the recordmcount warnings about __mcount_loc already existing. Something is a bit off still though, I see this at boot: ------------[ ftrace bug ]------------ ftrace failed to modify [] __tracepoint_iter_initcall_level+0x0/0x40 actual: 0f:1f:44:00:00 Initializing ftrace call sites ftrace record flags: 0 (0) expected tramp: ffffffff81056500 ------------[ cut here ]------------ Otherwise, this looks pretty good. Sami