Skip to contentSkip to conversation

kcov: mark in_softirq_really() as __always_inline

PATCH Applied Arnd Bergmann 4 participants 5 messages Dec 17, 2024 – Dec 18, 2024 KCOV

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kcov: mark in_softirq_really() as __always_inline

From: Arnd Bergmann <[email protected]>

If gcc decides not to inline in_softirq_really(), objtool warns about a function call with UACCESS enabled:

kernel/kcov.o: warning: objtool: __sanitizer_cov_trace_pc+0x1e: call to in_softirq_really() with UACCESS enabled kernel/kcov.o: warning: objtool: check_kcov_mode+0x11: call to in_softirq_really() with UACCESS enabled

Mark this as __always_inline to avoid the problem.

Fixes 7d4df2dad312 ("kcov: properly check for softirq context")
---
 kernel/kcov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcov.c +1 -1
index 28a6be6e64fd..187ba1b80bda 100644
@@ -166,7 +166,7 @@ static void kcov_remote_area_put(struct kcov_remote_area *area,
  * Unlike in_serving_softirq(), this function returns false when called during
  * a hardirq or an NMI that happened in the softirq context.
  */
-static inline bool in_softirq_really(void)
+static __always_inline bool in_softirq_really(void)
 {
 	return in_serving_softirq() && !in_hardirq() && !in_nmi();
 }
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

If gcc decides not to inline in_softirq_really(), objtool warns about a function call with UACCESS enabled:

Quoted 7 lines

kernel/kcov.o: warning: objtool: __sanitizer_cov_trace_pc+0x1e: call to in_softirq_really() with UACCESS enabled kernel/kcov.o: warning: objtool: check_kcov_mode+0x11: call to in_softirq_really() with UACCESS enabled

Mark this as __always_inline to avoid the problem.

Fixes 7d4df2dad312 ("kcov: properly check for softirq context")

__always_inline is the usual approach for code that can be instrumented - but I thought we explicitly never instrument kernel/kcov.c with anything. So I'm rather puzzled why gcc would not inline this function. In any case "inline" guarantees nothing, so:

Quoted 20 lines
---
 kernel/kcov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcov.c +1 -2
index 28a6be6e64fd..187ba1b80bda 100644
@@ -166,7 +166,7 @@ static void kcov_remote_area_put(struct kcov_remote_area *area,
  * Unlike in_serving_softirq(), this function returns false when called during
  * a hardirq or an NMI that happened in the softirq context.
  */
-static inline bool in_softirq_really(void)
+static __always_inline bool in_softirq_really(void)
 {
        return in_serving_softirq() && !in_hardirq() && !in_nmi();
 }
--

2.39.5

#2 lore raw
Quoted 12 lines · Marco Elver
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

If gcc decides not to inline in_softirq_really(), objtool warns about a function call with UACCESS enabled:

kernel/kcov.o: warning: objtool: __sanitizer_cov_trace_pc+0x1e: call to in_softirq_really() with UACCESS enabled kernel/kcov.o: warning: objtool: check_kcov_mode+0x11: call to in_softirq_really() with UACCESS enabled

Mark this as __always_inline to avoid the problem.

Quoted 7 lines
Quoted 2 lines
Fixes 7d4df2dad312 ("kcov: properly check for softirq context")

__always_inline is the usual approach for code that can be instrumented - but I thought we explicitly never instrument kernel/kcov.c with anything. So I'm rather puzzled why gcc would not inline this function. In any case "inline" guarantees nothing, so:

I'm guessing CONFIG_DEBUG_SECTION_MISMATCH was enabled, which enables -fno-inline-functions-called-once which ends up being the cause of a lot of these __always_inline patches.

I had a patch to get rid of that at some point, guess it got lost...

Signature · 1 line
Josh
#3 lore raw
Quoted 21 lines · Josh Poimboeuf
Quoted 12 lines · Marco Elver
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

If gcc decides not to inline in_softirq_really(), objtool warns about a function call with UACCESS enabled:

kernel/kcov.o: warning: objtool: __sanitizer_cov_trace_pc+0x1e: call to in_softirq_really() with UACCESS enabled kernel/kcov.o: warning: objtool: check_kcov_mode+0x11: call to in_softirq_really() with UACCESS enabled

Mark this as __always_inline to avoid the problem.

Quoted 7 lines
Quoted 2 lines
Fixes 7d4df2dad312 ("kcov: properly check for softirq context")

__always_inline is the usual approach for code that can be instrumented - but I thought we explicitly never instrument kernel/kcov.c with anything. So I'm rather puzzled why gcc would not inline this function. In any case "inline" guarantees nothing, so:

Quoted 5 lines

I'm guessing CONFIG_DEBUG_SECTION_MISMATCH was enabled, which enables -fno-inline-functions-called-once which ends up being the cause of a lot of these __always_inline patches.

I had a patch to get rid of that at some point, guess it got lost...

It doesn't seem to be the cause here, I get the warning both with and without CONFIG_DEBUG_SECTION_MISMATCH in random configurations. I've attached one .config that shows the problem without this option in case you want to investigate further.

Arnd

#4 lore raw
Quoted 26 lines · Arnd Bergmann
Quoted 25 lines · Josh Poimboeuf
Quoted 12 lines · Marco Elver
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

If gcc decides not to inline in_softirq_really(), objtool warns about a function call with UACCESS enabled:

kernel/kcov.o: warning: objtool: __sanitizer_cov_trace_pc+0x1e: call to in_softirq_really() with UACCESS enabled kernel/kcov.o: warning: objtool: check_kcov_mode+0x11: call to in_softirq_really() with UACCESS enabled

Mark this as __always_inline to avoid the problem.

Quoted 7 lines
Quoted 2 lines
Fixes 7d4df2dad312 ("kcov: properly check for softirq context")

__always_inline is the usual approach for code that can be instrumented - but I thought we explicitly never instrument kernel/kcov.c with anything. So I'm rather puzzled why gcc would not inline this function. In any case "inline" guarantees nothing, so:

I'm guessing CONFIG_DEBUG_SECTION_MISMATCH was enabled, which enables -fno-inline-functions-called-once which ends up being the cause of a lot of these __always_inline patches.

Quoted 6 lines
Quoted 1 line

I had a patch to get rid of that at some point, guess it got lost...

It doesn't seem to be the cause here, I get the warning both with and without CONFIG_DEBUG_SECTION_MISMATCH in random configurations. I've attached one .config that shows the problem without this option in case you want to investigate further.

Guess I should have looked closer, that function is called more than once, never mind...

Signature · 1 line
Josh