Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4109166pxk; Tue, 29 Sep 2020 14:48:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYO7sChfvvj+qtXIEQ7p0oqrOKT85yVG6NoPYeT3Ob1y3v9ud9+Yr5KgFA/y0Vt1Cex0gw X-Received: by 2002:a17:907:118c:: with SMTP id uz12mr5905442ejb.321.1601416106269; Tue, 29 Sep 2020 14:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601416106; cv=none; d=google.com; s=arc-20160816; b=SKYVl+d3s2Bcw1ta5n4uHDrEzJ7mHnoYeMzWn2Xb2JZVLIVtCF5CM+iwZBv4POTVKk bV8l5LZTm6GEzv0qt1hA67g7oo82W1KW0Zpt81mNenY70xVZWx34d6C9LYCyFtcHhsoV pqZmNStXI1CYAUwR4oX7Rnj/hTnjrpPCZOX3pOybO340O0jZioX/IcaEEXo+RV3oy/q6 dm1nmB5OmFwwFmXIufx/0BiBBy8k44I7WrKZcSrBSwQ43ESkkMCDjqPv2qIuHGJP02QU NeeLOcWnat/o3CGojbW5m0D0deR1RXW4vBqzlYXBs5dL2mlsrw9nnzJh6YVGKe0cAd8h 5sOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=19SL9ILYFnZ21fbCFqMg6UAhhhxZhQrjD+s35+X1B+w=; b=vLV9ZCFB0IRBZf7QtkOJ6WaSLJ2MePFAL+0T7WPQCmW0jOdVSbKP2YIiBa+7bzwqvD bcveLq9TmV5cvwkx/W2jTkedjU45BWfJxfItqs/rJn3tiQ5a3nMt8RppNWbGCwFRwKi0 PhN1/k9tRO+WR067IsjsDMV+2XYL7zrJHU5RVIeeHiFn+cf++YeNwgbRnueIGy/a63Bt TqD0NDtPxs5hT8aVkIINr2UcMsG3E3i3DacJIFeY3ZtZNyqLmaa13Zufzou8FBPzc3VO k6DtSCW14YweP+rgX2uclvtHp4ZMgVv+v49QyTsFEKykbrmBJb84ul0bHKbTPg7nA3qC 5uoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dgV6SDo9; 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 jp1si3612904ejb.371.2020.09.29.14.48.03; Tue, 29 Sep 2020 14:48:26 -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=dgV6SDo9; 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 S1728596AbgI2Vqv (ORCPT + 99 others); Tue, 29 Sep 2020 17:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728479AbgI2Vqs (ORCPT ); Tue, 29 Sep 2020 17:46:48 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4B25C0613E1 for ; Tue, 29 Sep 2020 14:46:47 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id n19so4329764pjt.1 for ; Tue, 29 Sep 2020 14:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=19SL9ILYFnZ21fbCFqMg6UAhhhxZhQrjD+s35+X1B+w=; b=dgV6SDo9/nGgyVMUAcMHx0gvXIYyOXF6ty1/3uITkICbHspZeHQbvHxGwlJqzzv9XW 4V5LMwCn5zT2oQ8f4LzGfojh5OquEucov8kBAZlsAbKj8gS7+rq5Zf2MIFybCbJwmh+A b2F8LeTYsJjCidyUsKW6BDyg8O8Sinw+WaY1c0mDlAt5XShrnPVlrIVqksLlFRGU1Dp8 A8Bl7ulvb9diUaImQKfi6sNHBwVH8SiGCv69MXqgXzBQsCNHc9rP0hmPStj/ZcNkXD/B KaKtBNLUeB6r12MkOyu4JMGxpeLWC59hDNbjZmRjkjPVuauMgp1y6CR+/HcBDH41STN0 Kwbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=19SL9ILYFnZ21fbCFqMg6UAhhhxZhQrjD+s35+X1B+w=; b=QVTRpDRujck+UC1fnSeELXdMKVOyayMCMzCNSYv1O8GyjPee1cMNRCtJG96fKTOuTh awOKO+tgKHDj32TvkzgKxhyxsb90lsdwMD5EC9pcf2O5o1qIwS0fPknOOtlY2KBTZdJH z9/TUWfn14hsN9a2Eh8i9AhjGrAFYpn0J0nBAXeF5rIUo749ZNIc8nRmfwT694KYzD5O QbpoOQAQqSC5G8xsg6hXXIqG0hsbC59Naku93/MT1Z69inqLtOUpMdRx3p8qO40+iPzV MZGeBss22AMbL/VZ9Fo4yIHi0s2RVKSnSFmWeu2x8C3rLNt7VgQuaF6FrAz2MESr2yCr 9/cg== X-Gm-Message-State: AOAM531/iLAHVIxifd43ijkxly+TiVXUvRx/L91EjhN/ZI7DK69nAKaT z1NCB90ZP0G2QHbx1oYsx8Tt/EaR4BbmCQ5C8fM= Sender: "samitolvanen via sendgmr" X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) (user=samitolvanen job=sendgmr) by 2002:a17:90a:c907:: with SMTP id v7mr5593265pjt.204.1601416007270; Tue, 29 Sep 2020 14:46:47 -0700 (PDT) Date: Tue, 29 Sep 2020 14:46:09 -0700 In-Reply-To: <20200929214631.3516445-1-samitolvanen@google.com> Message-Id: <20200929214631.3516445-8-samitolvanen@google.com> Mime-Version: 1.0 References: <20200929214631.3516445-1-samitolvanen@google.com> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [PATCH v4 07/29] tracing: add support for objtool mcount From: Sami Tolvanen To: Masahiro Yamada , Will Deacon , Steven Rostedt Cc: Peter Zijlstra , 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, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change adds build support for using objtool to generate __mcount_loc sections. Signed-off-by: Sami Tolvanen --- Makefile | 12 ++++++++++-- kernel/trace/Kconfig | 13 +++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 77e4f0a9495e..9717005e41c4 100644 --- a/Makefile +++ b/Makefile @@ -850,6 +850,9 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_CC endif endif endif +ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL + CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT +endif ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT ifdef CONFIG_HAVE_C_RECORDMCOUNT BUILD_C_RECORDMCOUNT := y @@ -1209,11 +1212,16 @@ uapi-asm-generic: PHONY += prepare-objtool prepare-resolve_btfids prepare-objtool: $(objtool_target) ifeq ($(SKIP_STACK_VALIDATION),1) +objtool-lib-prompt := "please install libelf-dev, libelf-devel or elfutils-libelf-devel" +ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL + @echo "error: Cannot generate __mcount_loc for CONFIG_DYNAMIC_FTRACE=y, $(objtool-lib-prompt)" >&2 + @false +endif ifdef CONFIG_UNWINDER_ORC - @echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 + @echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, $(objtool-lib-prompt)" >&2 @false else - @echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 + @echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, $(objtool-lib-prompt)" >&2 endif endif diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 927ad004888a..89263210ab26 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -51,6 +51,11 @@ config HAVE_NOP_MCOUNT help Arch supports the gcc options -pg with -mrecord-mcount and -nop-mcount +config HAVE_OBJTOOL_MCOUNT + bool + help + Arch supports objtool --mcount + config HAVE_C_RECORDMCOUNT bool help @@ -605,10 +610,18 @@ config FTRACE_MCOUNT_USE_CC depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY depends on FTRACE_MCOUNT_RECORD +config FTRACE_MCOUNT_USE_OBJTOOL + def_bool y + depends on HAVE_OBJTOOL_MCOUNT + depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY + depends on !FTRACE_MCOUNT_USE_CC + depends on FTRACE_MCOUNT_RECORD + config FTRACE_MCOUNT_USE_RECORDMCOUNT def_bool y depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY depends on !FTRACE_MCOUNT_USE_CC + depends on !FTRACE_MCOUNT_USE_OBJTOOL depends on FTRACE_MCOUNT_RECORD config TRACING_MAP -- 2.28.0.709.gb0816b6eb0-goog