From patchwork Wed May 30 12:19:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10438877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 05128601E9 for ; Wed, 30 May 2018 12:19:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2B7A289C9 for ; Wed, 30 May 2018 12:19:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D743F289CB; Wed, 30 May 2018 12:19:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5672B289D2 for ; Wed, 30 May 2018 12:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752850AbeE3MTs (ORCPT ); Wed, 30 May 2018 08:19:48 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:38355 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752838AbeE3MTr (ORCPT ); Wed, 30 May 2018 08:19:47 -0400 Received: by mail-pl0-f68.google.com with SMTP id c11-v6so10995559plr.5 for ; Wed, 30 May 2018 05:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=byQoq2ek1uYtsomiq3y8uCzfoaHgIK3SVfP1XmzJWHM=; b=mFCjotjMyDWMzNQ+KNkFNYcWfa7Zo7Ex+b9j1/ojuh/1ECa22gwOtOGM3peC7dgl4A gnrvGAOHhf3jZ79p9ikJTnGu8YcN+hKj9yLn5KvUqPHwwVaKTrXMyK1g+B5X0EibLk67 CuzC5a+NsFyMdVB0BoV8VMgymR/nCqa6tpZmZc/jAQWHGzO7hpkJ16IruSo7p0/LBCRD BkpaqfUwwAb4tWM6lOwlc7sNP9zfKA0HEbmFg2aQFu0QCDZEly1+TlzB53/Q5VhmI+5k qGH0yKdw0Za19fT349xGBkvJIZ3b2khI1AREY620yVVp66k2y/tTn5xdUSpoiqwjxE7N 00FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=byQoq2ek1uYtsomiq3y8uCzfoaHgIK3SVfP1XmzJWHM=; b=Q3D7kOTkxnQ6T+nJ6kmof6UQVsLhX4cIyosuuwNz2HBZvX1Gn49LNQ68mpdIqpK9Zs vw6WdM7jJFvIUgWmXaqoS0JqmcBuAUhOYdTr3Otj4AHtww8GEwnVaGBVgNHMA4C48w+3 UpdCICQgwqkZacKJtHas97QsZhnRlmz0EpnJ5L3Uw5HvUYQDRnEFq4/Yg7OcCfOE6iBB dqylC2Z+DbUzN4ZDpIkwnIFwHrRV1gIbBEi97J7TjTgSDoj682+0aOOnE9wxlcRdz521 3LGIZAlngUSVdQ1bmUf8CK9MvG55IPiLK9J/6r7aqJ08HxzvO3aX7KBeVDFKgK/vrjJD qzMw== X-Gm-Message-State: ALKqPwenqiXIQJ8YE8DEuWYZNttUksf/mcquYJHXwpHxJjTE5gfvWpI4 uUsnij21nqKPc6T1Ed7AhhQVig== X-Google-Smtp-Source: ADUXVKLD+QAMZ7kwlfwpsDJLWjs9aFYR9jM5C0K1W6EKbk6Sz9+QI570ak60ILtU6t4S+QUw6VR1hw== X-Received: by 2002:a17:902:31a4:: with SMTP id x33-v6mr2641835plb.355.1527682786355; Wed, 30 May 2018 05:19:46 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id g13-v6sm61518085pfm.67.2018.05.30.05.19.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 05:19:45 -0700 (PDT) From: Nicholas Piggin To: linux-kbuild@vger.kernel.org Cc: Nicholas Piggin , linuxppc-dev@lists.ozlabs.org, Masahiro Yamada , Segher Boessenkool Subject: [PATCH v5 4/4] powerpc/kbuild: move -mprofile-kernel check to Kconfig Date: Wed, 30 May 2018 22:19:22 +1000 Message-Id: <20180530121922.22122-5-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530121922.22122-1-npiggin@gmail.com> References: <20180530121922.22122-1-npiggin@gmail.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This eliminates the workaround that requires disabling -mprofile-kernel by default in Kconfig. [ Note: this depends on https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kconfig-shell-v3 ] Signed-off-by: Nicholas Piggin --- arch/powerpc/Kconfig | 16 +--------------- arch/powerpc/Makefile | 13 +------------ arch/powerpc/include/asm/module.h | 2 +- arch/powerpc/kernel/module_64.c | 4 ++-- arch/powerpc/kernel/trace/ftrace.c | 6 +++--- arch/powerpc/tools/gcc-check-mprofile-kernel.sh | 1 - 6 files changed, 8 insertions(+), 34 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 0cc41146bc51..736fe35a657d 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -461,23 +461,9 @@ config LD_HEAD_STUB_CATCH If unsure, say "N". -config DISABLE_MPROFILE_KERNEL - bool "Disable use of mprofile-kernel for kernel tracing" - depends on PPC64 && CPU_LITTLE_ENDIAN - default y - help - Selecting this options disables use of the mprofile-kernel ABI for - kernel tracing. That will cause options such as live patching - (CONFIG_LIVEPATCH) which depend on CONFIG_DYNAMIC_FTRACE_WITH_REGS to - be disabled also. - - If you have a toolchain which supports mprofile-kernel, then you can - disable this. Otherwise leave it enabled. If you're not sure, say - "Y". - config MPROFILE_KERNEL depends on PPC64 && CPU_LITTLE_ENDIAN - def_bool !DISABLE_MPROFILE_KERNEL + def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__) config IOMMU_HELPER def_bool PPC64 diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 6faf1d6ad9dd..8eda91e0b8df 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -161,18 +161,7 @@ CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64 endif ifdef CONFIG_MPROFILE_KERNEL - ifeq ($(shell $(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__),OK) - CC_FLAGS_FTRACE := -pg -mprofile-kernel - KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL - else - # If the user asked for mprofile-kernel but the toolchain doesn't - # support it, emit a warning and deliberately break the build later - # with mprofile-kernel-not-supported. We would prefer to make this an - # error right here, but then the user would never be able to run - # oldconfig to change their configuration. - $(warning Compiler does not support mprofile-kernel, set CONFIG_DISABLE_MPROFILE_KERNEL) - CC_FLAGS_FTRACE := -mprofile-kernel-not-supported - endif + CC_FLAGS_FTRACE := -pg -mprofile-kernel endif CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell) diff --git a/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h index 4f6573934792..c38b125b7a57 100644 --- a/arch/powerpc/include/asm/module.h +++ b/arch/powerpc/include/asm/module.h @@ -14,7 +14,7 @@ #include -#ifdef CC_USING_MPROFILE_KERNEL +#ifdef CONFIG_MPROFILE_KERNEL #define MODULE_ARCH_VERMAGIC_FTRACE "mprofile-kernel " #else #define MODULE_ARCH_VERMAGIC_FTRACE "" diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c index a2636c250b7b..55bccc315e1a 100644 --- a/arch/powerpc/kernel/module_64.c +++ b/arch/powerpc/kernel/module_64.c @@ -462,7 +462,7 @@ static unsigned long stub_for_addr(const Elf64_Shdr *sechdrs, return (unsigned long)&stubs[i]; } -#ifdef CC_USING_MPROFILE_KERNEL +#ifdef CONFIG_MPROFILE_KERNEL static bool is_early_mcount_callsite(u32 *instruction) { /* @@ -746,7 +746,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, #ifdef CONFIG_DYNAMIC_FTRACE -#ifdef CC_USING_MPROFILE_KERNEL +#ifdef CONFIG_MPROFILE_KERNEL #define PACATOC offsetof(struct paca_struct, kernel_toc) diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index 4741fe112f05..b2272308225a 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -144,7 +144,7 @@ __ftrace_make_nop(struct module *mod, return -EINVAL; } -#ifdef CC_USING_MPROFILE_KERNEL +#ifdef CONFIG_MPROFILE_KERNEL /* When using -mkernel_profile there is no load to jump over */ pop = PPC_INST_NOP; @@ -188,7 +188,7 @@ __ftrace_make_nop(struct module *mod, pr_err("Expected %08x found %08x\n", PPC_INST_LD_TOC, op); return -EINVAL; } -#endif /* CC_USING_MPROFILE_KERNEL */ +#endif /* CONFIG_MPROFILE_KERNEL */ if (patch_instruction((unsigned int *)ip, pop)) { pr_err("Patching NOP failed.\n"); @@ -324,7 +324,7 @@ int ftrace_make_nop(struct module *mod, * They should effectively be a NOP, and follow formal constraints, * depending on the ABI. Return false if they don't. */ -#ifndef CC_USING_MPROFILE_KERNEL +#ifndef CONFIG_MPROFILE_KERNEL static int expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1) { diff --git a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh index a7dd0e5d9f98..137f3376ac2b 100755 --- a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh +++ b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh @@ -24,5 +24,4 @@ echo -e "#include \nnotrace int func() { return 0; }" | \ 2> /dev/null | grep -q "_mcount" && \ exit 1 -echo "OK" exit 0