powerpc/kbuild: move -mprofile-kernel check to Kconfig
authorNicholas Piggin <npiggin@gmail.com>
Wed, 30 May 2018 12:19:22 +0000 (22:19 +1000)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 11 Jun 2018 00:16:29 +0000 (09:16 +0900)
This eliminates the workaround that requires disabling
-mprofile-kernel by default in Kconfig.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
arch/powerpc/Kconfig
arch/powerpc/Makefile
arch/powerpc/include/asm/module.h
arch/powerpc/kernel/module_64.c
arch/powerpc/kernel/trace/ftrace.c
arch/powerpc/tools/gcc-check-mprofile-kernel.sh

index 737d333d4df2b530e75337d6f438a886737443ae..7b96e4c48cbd0c7c6091d644e2157cb3f829e276 100644 (file)
@@ -459,23 +459,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 HOTPLUG_CPU
        bool "Support for enabling/disabling CPUs"
index 9b52e42e581b21cd3fb5574e46bf1a90948b028e..bd06a3ccda312a0a645cd0dbff887924f691d2ce 100644 (file)
@@ -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)
index d8374f984f39945e4f12451270962777bd0befeb..d61b0818e2676695a64c57f5e53c4af285a67065 100644 (file)
@@ -14,7 +14,7 @@
 #include <asm-generic/module.h>
 
 
-#ifdef CC_USING_MPROFILE_KERNEL
+#ifdef CONFIG_MPROFILE_KERNEL
 #define MODULE_ARCH_VERMAGIC_FTRACE    "mprofile-kernel "
 #else
 #define MODULE_ARCH_VERMAGIC_FTRACE    ""
index 1b7419579820fb54817cfbcdc2004a4a2a43dae5..b8d61e019d06189f74d56114c23aa3637d1579b7 100644 (file)
@@ -466,7 +466,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_mprofile_mcount_callsite(const char *name, u32 *instruction)
 {
        if (strcmp("_mcount", name))
@@ -753,7 +753,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)
 
index c076a32093fdd90c03209735113d2948a91903c4..4bfbb54dee517de53fd4e9e09c4d0ae1a2cdfdae 100644 (file)
@@ -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)
 {
index a7dd0e5d9f98485bdecf93663f069a8cfd52067d..137f3376ac2bb05a3debbcdbe913594dbd7f54a8 100755 (executable)
@@ -24,5 +24,4 @@ echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
     2> /dev/null | grep -q "_mcount" && \
     exit 1
 
-echo "OK"
 exit 0