[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210208175946.2092374-9-sashal@kernel.org>
Date: Mon, 8 Feb 2021 12:59:46 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Johannes Berg <johannes.berg@...el.com>,
Peter Oberparleiter <oberpar@...ux.ibm.com>,
Arnd Bergmann <arnd@...db.de>, Jessica Yu <jeyu@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH AUTOSEL 4.14 9/9] init/gcov: allow CONFIG_CONSTRUCTORS on UML to fix module gcov
From: Johannes Berg <johannes.berg@...el.com>
[ Upstream commit 55b6f763d8bcb5546997933105d66d3e6b080e6a ]
On ARCH=um, loading a module doesn't result in its constructors getting
called, which breaks module gcov since the debugfs files are never
registered. On the other hand, in-kernel constructors have already been
called by the dynamic linker, so we can't call them again.
Get out of this conundrum by allowing CONFIG_CONSTRUCTORS to be
selected, but avoiding the in-kernel constructor calls.
Also remove the "if !UML" from GCOV selecting CONSTRUCTORS now, since we
really do want CONSTRUCTORS, just not kernel binary ones.
Link: https://lkml.kernel.org/r/20210120172041.c246a2cac2fb.I1358f584b76f1898373adfed77f4462c8705b736@changeid
Signed-off-by: Johannes Berg <johannes.berg@...el.com>
Reviewed-by: Peter Oberparleiter <oberpar@...ux.ibm.com>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Jessica Yu <jeyu@...nel.org>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
init/Kconfig | 1 -
init/main.c | 8 +++++++-
kernel/gcov/Kconfig | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/init/Kconfig b/init/Kconfig
index 20f709ea1eb38..0ab8e16df6461 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -18,7 +18,6 @@ config DEFCONFIG_LIST
config CONSTRUCTORS
bool
- depends on !UML
config IRQ_WORK
bool
diff --git a/init/main.c b/init/main.c
index 603b1ad88cb68..cb433b0519ccd 100644
--- a/init/main.c
+++ b/init/main.c
@@ -713,7 +713,13 @@ asmlinkage __visible void __init start_kernel(void)
/* Call all constructor functions linked into the kernel. */
static void __init do_ctors(void)
{
-#ifdef CONFIG_CONSTRUCTORS
+/*
+ * For UML, the constructors have already been called by the
+ * normal setup code as it's just a normal ELF binary, so we
+ * cannot do it again - but we do need CONFIG_CONSTRUCTORS
+ * even on UML for modules.
+ */
+#if defined(CONFIG_CONSTRUCTORS) && !defined(CONFIG_UML)
ctor_fn_t *fn = (ctor_fn_t *) __ctors_start;
for (; fn < (ctor_fn_t *) __ctors_end; fn++)
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
index 1276aabaab550..2aef7d9e3e5c2 100644
--- a/kernel/gcov/Kconfig
+++ b/kernel/gcov/Kconfig
@@ -3,7 +3,7 @@ menu "GCOV-based kernel profiling"
config GCOV_KERNEL
bool "Enable gcov-based kernel profiling"
depends on DEBUG_FS
- select CONSTRUCTORS if !UML
+ select CONSTRUCTORS
default n
---help---
This option enables gcov-based code profiling (e.g. for code coverage
--
2.27.0
Powered by blists - more mailing lists