* [PATCH 0/3] x86: Address various objtool complaints
@ 2022-05-02 11:07 Peter Zijlstra
2022-05-02 11:07 ` [PATCH 1/3] objtool: Mark __ubsan_handle_builtin_unreachable() as noreturn Peter Zijlstra
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Peter Zijlstra @ 2022-05-02 11:07 UTC (permalink / raw)
To: x86, jpoimboe; +Cc: linux-kernel, peterz, elver, jbaron, rostedt, ardb
Courtesy of 0-day:
fs/ntfs3/ntfs3.prelink.o: warning: objtool: ni_read_frame() falls through to next function ni_readpage_cmpr.cold()
vmlinux.o: warning: objtool: enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x28: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x24: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: exit_to_user_mode+0x14: call to static_key_count.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_exit_to_user_mode+0x2d: call to static_key_count.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_exit_to_user_mode+0x1b: call to static_key_count.constprop.0() leaves .noinstr.text section
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/3] objtool: Mark __ubsan_handle_builtin_unreachable() as noreturn
2022-05-02 11:07 [PATCH 0/3] x86: Address various objtool complaints Peter Zijlstra
@ 2022-05-02 11:07 ` Peter Zijlstra
2022-05-02 11:07 ` [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends Peter Zijlstra
2022-05-02 11:07 ` [PATCH 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds Peter Zijlstra
2 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2022-05-02 11:07 UTC (permalink / raw)
To: x86, jpoimboe
Cc: linux-kernel, peterz, elver, jbaron, rostedt, ardb, kernel test robot
fs/ntfs3/ntfs3.prelink.o: warning: objtool: ni_read_frame() falls through to next function ni_readpage_cmpr.cold()
That is in fact:
000000000000124a <ni_read_frame.cold>:
124a: 44 89 e0 mov %r12d,%eax
124d: 0f b6 55 98 movzbl -0x68(%rbp),%edx
1251: 48 c7 c7 00 00 00 00 mov $0x0,%rdi 1254: R_X86_64_32S .data+0x1380
1258: 48 89 c6 mov %rax,%rsi
125b: e8 00 00 00 00 call 1260 <ni_read_frame.cold+0x16> 125c: R_X86_64_PLT32 __ubsan_handle_shift_out_of_bounds-0x4
1260: 48 8d 7d cc lea -0x34(%rbp),%rdi
1264: e8 00 00 00 00 call 1269 <ni_read_frame.cold+0x1f> 1265: R_X86_64_PLT32 __tsan_read4-0x4
1269: 8b 45 cc mov -0x34(%rbp),%eax
126c: e9 00 00 00 00 jmp 1271 <ni_read_frame.cold+0x27> 126d: R_X86_64_PC32 .text+0x19109
1271: 48 8b 75 a0 mov -0x60(%rbp),%rsi
1275: 48 63 d0 movslq %eax,%rdx
1278: 48 c7 c7 00 00 00 00 mov $0x0,%rdi 127b: R_X86_64_32S .data+0x13a0
127f: 89 45 88 mov %eax,-0x78(%rbp)
1282: e8 00 00 00 00 call 1287 <ni_read_frame.cold+0x3d> 1283: R_X86_64_PLT32 __ubsan_handle_shift_out_of_bounds-0x4
1287: 8b 45 88 mov -0x78(%rbp),%eax
128a: e9 00 00 00 00 jmp 128f <ni_read_frame.cold+0x45> 128b: R_X86_64_PC32 .text+0x19098
128f: 48 c7 c7 00 00 00 00 mov $0x0,%rdi 1292: R_X86_64_32S .data+0x11f0
1296: e8 00 00 00 00 call 129b <ni_readpage_cmpr.cold> 1297: R_X86_64_PLT32 __ubsan_handle_builtin_unreachable-0x4
000000000000129b <ni_readpage_cmpr.cold>:
Tell objtool that __ubsan_handle_builtin_unreachable() is a noreturn.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220502091514.GB479834@worktop.programming.kicks-ass.net
---
tools/objtool/check.c | 1 +
1 file changed, 1 insertion(+)
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -184,6 +184,7 @@ static bool __dead_end_function(struct o
"do_group_exit",
"stop_this_cpu",
"__invalid_creds",
+ "__ubsan_handle_builtin_unreachable",
};
if (!func)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends
2022-05-02 11:07 [PATCH 0/3] x86: Address various objtool complaints Peter Zijlstra
2022-05-02 11:07 ` [PATCH 1/3] objtool: Mark __ubsan_handle_builtin_unreachable() as noreturn Peter Zijlstra
@ 2022-05-02 11:07 ` Peter Zijlstra
2022-05-02 11:54 ` Marco Elver
` (2 more replies)
2022-05-02 11:07 ` [PATCH 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds Peter Zijlstra
2 siblings, 3 replies; 13+ messages in thread
From: Peter Zijlstra @ 2022-05-02 11:07 UTC (permalink / raw)
To: x86, jpoimboe
Cc: linux-kernel, peterz, elver, jbaron, rostedt, ardb, kernel test robot
vmlinux.o: warning: objtool: enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x28: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x24: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/include/asm/cpufeature.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -51,7 +51,7 @@ extern const char * const x86_power_flag
extern const char * const x86_bug_flags[NBUGINTS*32];
#define test_cpu_cap(c, bit) \
- test_bit(bit, (unsigned long *)((c)->x86_capability))
+ arch_test_bit(bit, (unsigned long *)((c)->x86_capability))
/*
* There are 32 bits/features in each mask word. The high bits
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
2022-05-02 11:07 [PATCH 0/3] x86: Address various objtool complaints Peter Zijlstra
2022-05-02 11:07 ` [PATCH 1/3] objtool: Mark __ubsan_handle_builtin_unreachable() as noreturn Peter Zijlstra
2022-05-02 11:07 ` [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends Peter Zijlstra
@ 2022-05-02 11:07 ` Peter Zijlstra
2022-05-02 11:23 ` Marco Elver
2022-05-02 13:09 ` [PATCH v2 " Peter Zijlstra
2 siblings, 2 replies; 13+ messages in thread
From: Peter Zijlstra @ 2022-05-02 11:07 UTC (permalink / raw)
To: x86, jpoimboe
Cc: linux-kernel, peterz, elver, jbaron, rostedt, ardb, kernel test robot
When building x86_64 with JUMP_LABEL=n it's possible for
instrumentation to sneak into noinstr:
vmlinux.o: warning: objtool: exit_to_user_mode+0x14: call to static_key_count.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_exit_to_user_mode+0x2d: call to static_key_count.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_exit_to_user_mode+0x1b: call to static_key_count.constprop.0() leaves .noinstr.text section
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/jump_label.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -256,9 +256,9 @@ extern void static_key_disable_cpuslocke
#include <linux/atomic.h>
#include <linux/bug.h>
-static inline int static_key_count(struct static_key *key)
+static __always_inline int static_key_count(struct static_key *key)
{
- return atomic_read(&key->enabled);
+ return READ_ONCE_NOCHECK(&key->enabled.count);
}
static __always_inline void jump_label_init(void)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
2022-05-02 11:07 ` [PATCH 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds Peter Zijlstra
@ 2022-05-02 11:23 ` Marco Elver
2022-05-02 13:01 ` Peter Zijlstra
2022-05-02 13:09 ` [PATCH v2 " Peter Zijlstra
1 sibling, 1 reply; 13+ messages in thread
From: Marco Elver @ 2022-05-02 11:23 UTC (permalink / raw)
To: Peter Zijlstra
Cc: x86, jpoimboe, linux-kernel, jbaron, rostedt, ardb, kernel test robot
On Mon, 2 May 2022 at 13:12, Peter Zijlstra <peterz@infradead.org> wrote:
>
> When building x86_64 with JUMP_LABEL=n it's possible for
> instrumentation to sneak into noinstr:
>
> vmlinux.o: warning: objtool: exit_to_user_mode+0x14: call to static_key_count.constprop.0() leaves .noinstr.text section
> vmlinux.o: warning: objtool: syscall_exit_to_user_mode+0x2d: call to static_key_count.constprop.0() leaves .noinstr.text section
> vmlinux.o: warning: objtool: irqentry_exit_to_user_mode+0x1b: call to static_key_count.constprop.0() leaves .noinstr.text section
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> include/linux/jump_label.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/include/linux/jump_label.h
> +++ b/include/linux/jump_label.h
> @@ -256,9 +256,9 @@ extern void static_key_disable_cpuslocke
> #include <linux/atomic.h>
> #include <linux/bug.h>
>
> -static inline int static_key_count(struct static_key *key)
> +static __always_inline int static_key_count(struct static_key *key)
> {
> - return atomic_read(&key->enabled);
> + return READ_ONCE_NOCHECK(&key->enabled.count);
> }
Did arch_atomic_read() not work? Or should this also be unchecked in
instrumented functions?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends
2022-05-02 11:07 ` [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends Peter Zijlstra
@ 2022-05-02 11:54 ` Marco Elver
2022-05-02 18:47 ` Josh Poimboeuf
2022-05-30 10:38 ` [tip: objtool/urgent] " tip-bot2 for Peter Zijlstra
2 siblings, 0 replies; 13+ messages in thread
From: Marco Elver @ 2022-05-02 11:54 UTC (permalink / raw)
To: Peter Zijlstra
Cc: x86, jpoimboe, linux-kernel, jbaron, rostedt, ardb, kernel test robot
On Mon, May 02, 2022 at 01:07PM +0200, Peter Zijlstra wrote:
> vmlinux.o: warning: objtool: enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
> vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x28: call to __kcsan_check_access() leaves .noinstr.text section
> vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x24: call to __kcsan_check_access() leaves .noinstr.text section
> vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Marco Elver <elver@google.com>
And should fix the same issue for other sanitizers that get instrumented
test_bit() via asm-generic/bitops/instrumented-*.h, not just KCSAN.
> ---
> arch/x86/include/asm/cpufeature.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/arch/x86/include/asm/cpufeature.h
> +++ b/arch/x86/include/asm/cpufeature.h
> @@ -51,7 +51,7 @@ extern const char * const x86_power_flag
> extern const char * const x86_bug_flags[NBUGINTS*32];
>
> #define test_cpu_cap(c, bit) \
> - test_bit(bit, (unsigned long *)((c)->x86_capability))
> + arch_test_bit(bit, (unsigned long *)((c)->x86_capability))
>
> /*
> * There are 32 bits/features in each mask word. The high bits
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
2022-05-02 11:23 ` Marco Elver
@ 2022-05-02 13:01 ` Peter Zijlstra
0 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2022-05-02 13:01 UTC (permalink / raw)
To: Marco Elver
Cc: x86, jpoimboe, linux-kernel, jbaron, rostedt, ardb, kernel test robot
On Mon, May 02, 2022 at 01:23:49PM +0200, Marco Elver wrote:
> On Mon, 2 May 2022 at 13:12, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > When building x86_64 with JUMP_LABEL=n it's possible for
> > instrumentation to sneak into noinstr:
> >
> > vmlinux.o: warning: objtool: exit_to_user_mode+0x14: call to static_key_count.constprop.0() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: syscall_exit_to_user_mode+0x2d: call to static_key_count.constprop.0() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: irqentry_exit_to_user_mode+0x1b: call to static_key_count.constprop.0() leaves .noinstr.text section
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > ---
> > include/linux/jump_label.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > --- a/include/linux/jump_label.h
> > +++ b/include/linux/jump_label.h
> > @@ -256,9 +256,9 @@ extern void static_key_disable_cpuslocke
> > #include <linux/atomic.h>
> > #include <linux/bug.h>
> >
> > -static inline int static_key_count(struct static_key *key)
> > +static __always_inline int static_key_count(struct static_key *key)
> > {
> > - return atomic_read(&key->enabled);
> > + return READ_ONCE_NOCHECK(&key->enabled.count);
> > }
>
> Did arch_atomic_read() not work? Or should this also be unchecked in
> instrumented functions?
Urgh, also I think the above is broken for me forgetting to remove the
&.
I think arch_atomic_read() should work, lemme try.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
2022-05-02 11:07 ` [PATCH 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds Peter Zijlstra
2022-05-02 11:23 ` Marco Elver
@ 2022-05-02 13:09 ` Peter Zijlstra
2022-05-02 13:25 ` Marco Elver
1 sibling, 1 reply; 13+ messages in thread
From: Peter Zijlstra @ 2022-05-02 13:09 UTC (permalink / raw)
To: x86, jpoimboe
Cc: linux-kernel, elver, jbaron, rostedt, ardb, kernel test robot
Subject: jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
From: Peter Zijlstra <peterz@infradead.org>
Date: Mon May 2 12:30:20 CEST 2022
When building x86_64 with JUMP_LABEL=n it's possible for
instrumentation to sneak into noinstr:
vmlinux.o: warning: objtool: exit_to_user_mode+0x14: call to static_key_count.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_exit_to_user_mode+0x2d: call to static_key_count.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_exit_to_user_mode+0x1b: call to static_key_count.constprop.0() leaves .noinstr.text section
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/jump_label.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -256,9 +256,9 @@ extern void static_key_disable_cpuslocke
#include <linux/atomic.h>
#include <linux/bug.h>
-static inline int static_key_count(struct static_key *key)
+static __always_inline int static_key_count(struct static_key *key)
{
- return atomic_read(&key->enabled);
+ return arch_atomic_read(&key->enabled.count);
}
static __always_inline void jump_label_init(void)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
2022-05-02 13:09 ` [PATCH v2 " Peter Zijlstra
@ 2022-05-02 13:25 ` Marco Elver
2022-05-02 14:54 ` Peter Zijlstra
0 siblings, 1 reply; 13+ messages in thread
From: Marco Elver @ 2022-05-02 13:25 UTC (permalink / raw)
To: Peter Zijlstra
Cc: x86, jpoimboe, linux-kernel, jbaron, rostedt, ardb, kernel test robot
On Mon, May 02, 2022 at 03:09PM +0200, Peter Zijlstra wrote:
>
> Subject: jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
> From: Peter Zijlstra <peterz@infradead.org>
> Date: Mon May 2 12:30:20 CEST 2022
>
> When building x86_64 with JUMP_LABEL=n it's possible for
> instrumentation to sneak into noinstr:
>
> vmlinux.o: warning: objtool: exit_to_user_mode+0x14: call to static_key_count.constprop.0() leaves .noinstr.text section
> vmlinux.o: warning: objtool: syscall_exit_to_user_mode+0x2d: call to static_key_count.constprop.0() leaves .noinstr.text section
> vmlinux.o: warning: objtool: irqentry_exit_to_user_mode+0x1b: call to static_key_count.constprop.0() leaves .noinstr.text section
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> include/linux/jump_label.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/include/linux/jump_label.h
> +++ b/include/linux/jump_label.h
> @@ -256,9 +256,9 @@ extern void static_key_disable_cpuslocke
> #include <linux/atomic.h>
> #include <linux/bug.h>
>
> -static inline int static_key_count(struct static_key *key)
> +static __always_inline int static_key_count(struct static_key *key)
> {
> - return atomic_read(&key->enabled);
> + return arch_atomic_read(&key->enabled.count);
Curious if this compiles - s/.count// ?
> }
>
> static __always_inline void jump_label_init(void)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
2022-05-02 13:25 ` Marco Elver
@ 2022-05-02 14:54 ` Peter Zijlstra
0 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2022-05-02 14:54 UTC (permalink / raw)
To: Marco Elver
Cc: x86, jpoimboe, linux-kernel, jbaron, rostedt, ardb, kernel test robot
On Mon, May 02, 2022 at 03:25:14PM +0200, Marco Elver wrote:
> On Mon, May 02, 2022 at 03:09PM +0200, Peter Zijlstra wrote:
> >
> > Subject: jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
> > From: Peter Zijlstra <peterz@infradead.org>
> > Date: Mon May 2 12:30:20 CEST 2022
> >
> > When building x86_64 with JUMP_LABEL=n it's possible for
> > instrumentation to sneak into noinstr:
> >
> > vmlinux.o: warning: objtool: exit_to_user_mode+0x14: call to static_key_count.constprop.0() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: syscall_exit_to_user_mode+0x2d: call to static_key_count.constprop.0() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: irqentry_exit_to_user_mode+0x1b: call to static_key_count.constprop.0() leaves .noinstr.text section
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > ---
> > include/linux/jump_label.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > --- a/include/linux/jump_label.h
> > +++ b/include/linux/jump_label.h
> > @@ -256,9 +256,9 @@ extern void static_key_disable_cpuslocke
> > #include <linux/atomic.h>
> > #include <linux/bug.h>
> >
> > -static inline int static_key_count(struct static_key *key)
> > +static __always_inline int static_key_count(struct static_key *key)
> > {
> > - return atomic_read(&key->enabled);
> > + return arch_atomic_read(&key->enabled.count);
>
> Curious if this compiles - s/.count// ?
It does if you have JUMP_LABEL=y... (-:
*sigh*... how I about I go back to mowing the lawn and try again
later...
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends
2022-05-02 11:07 ` [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends Peter Zijlstra
2022-05-02 11:54 ` Marco Elver
@ 2022-05-02 18:47 ` Josh Poimboeuf
2022-05-03 14:20 ` Mark Rutland
2022-05-30 10:38 ` [tip: objtool/urgent] " tip-bot2 for Peter Zijlstra
2 siblings, 1 reply; 13+ messages in thread
From: Josh Poimboeuf @ 2022-05-02 18:47 UTC (permalink / raw)
To: Peter Zijlstra
Cc: x86, linux-kernel, elver, jbaron, rostedt, ardb, kernel test robot
On Mon, May 02, 2022 at 01:07:43PM +0200, Peter Zijlstra wrote:
> vmlinux.o: warning: objtool: enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
> vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x28: call to __kcsan_check_access() leaves .noinstr.text section
> vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x24: call to __kcsan_check_access() leaves .noinstr.text section
> vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
An explanation about *why* this fixes it would help, as I have no idea
from looking at the patch.
> ---
> arch/x86/include/asm/cpufeature.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/arch/x86/include/asm/cpufeature.h
> +++ b/arch/x86/include/asm/cpufeature.h
> @@ -51,7 +51,7 @@ extern const char * const x86_power_flag
> extern const char * const x86_bug_flags[NBUGINTS*32];
>
> #define test_cpu_cap(c, bit) \
> - test_bit(bit, (unsigned long *)((c)->x86_capability))
> + arch_test_bit(bit, (unsigned long *)((c)->x86_capability))
>
> /*
> * There are 32 bits/features in each mask word. The high bits
>
>
--
Josh
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends
2022-05-02 18:47 ` Josh Poimboeuf
@ 2022-05-03 14:20 ` Mark Rutland
0 siblings, 0 replies; 13+ messages in thread
From: Mark Rutland @ 2022-05-03 14:20 UTC (permalink / raw)
To: Josh Poimboeuf
Cc: Peter Zijlstra, x86, linux-kernel, elver, jbaron, rostedt, ardb,
kernel test robot
On Mon, May 02, 2022 at 11:47:47AM -0700, Josh Poimboeuf wrote:
> On Mon, May 02, 2022 at 01:07:43PM +0200, Peter Zijlstra wrote:
> > vmlinux.o: warning: objtool: enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x28: call to __kcsan_check_access() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x24: call to __kcsan_check_access() leaves .noinstr.text section
> > vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>
> An explanation about *why* this fixes it would help, as I have no idea
> from looking at the patch.
How about something like:
| As x86 uses the <asm-generic/bitops/instrumented-*.h> headers, the
| regular forms of all bitops are instrumented with explicit calls to
| KASAN and KCSAN checks. As these are explicit calls, these are not
| suppressed by the noinstr function attribute.
|
| This can result in calls to those check functions in noinstr code, which
| objtool warns about:
|
| vmlinux.o: warning: objtool: enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
| vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x28: call to __kcsan_check_access() leaves .noinstr.text section
| vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x24: call to __kcsan_check_access() leaves .noinstr.text section
| vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
|
| Prevent this by using the arch_*() bitops, which are the underlying
| bitops without explciit instrumentation.
Thanks,
Mark.
>
> > ---
> > arch/x86/include/asm/cpufeature.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > --- a/arch/x86/include/asm/cpufeature.h
> > +++ b/arch/x86/include/asm/cpufeature.h
> > @@ -51,7 +51,7 @@ extern const char * const x86_power_flag
> > extern const char * const x86_bug_flags[NBUGINTS*32];
> >
> > #define test_cpu_cap(c, bit) \
> > - test_bit(bit, (unsigned long *)((c)->x86_capability))
> > + arch_test_bit(bit, (unsigned long *)((c)->x86_capability))
> >
> > /*
> > * There are 32 bits/features in each mask word. The high bits
> >
> >
>
> --
> Josh
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [tip: objtool/urgent] x86/cpu: Elide KCSAN for cpu_has() and friends
2022-05-02 11:07 ` [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends Peter Zijlstra
2022-05-02 11:54 ` Marco Elver
2022-05-02 18:47 ` Josh Poimboeuf
@ 2022-05-30 10:38 ` tip-bot2 for Peter Zijlstra
2 siblings, 0 replies; 13+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2022-05-30 10:38 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: a6a5eb269f6f3a2fe392f725a8d9052190c731e2
Gitweb: https://git.kernel.org/tip/a6a5eb269f6f3a2fe392f725a8d9052190c731e2
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 02 May 2022 12:15:23 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 27 May 2022 12:34:43 +02:00
x86/cpu: Elide KCSAN for cpu_has() and friends
As x86 uses the <asm-generic/bitops/instrumented-*.h> headers, the
regular forms of all bitops are instrumented with explicit calls to
KASAN and KCSAN checks. As these are explicit calls, these are not
suppressed by the noinstr function attribute.
This can result in calls to those check functions in noinstr code, which
objtool warns about:
vmlinux.o: warning: objtool: enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x28: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x24: call to __kcsan_check_access() leaves .noinstr.text section
vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
Prevent this by using the arch_*() bitops, which are the underlying
bitops without explciit instrumentation.
[null: Changelog]
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220502111216.290518605@infradead.org
---
arch/x86/include/asm/cpufeature.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 66d3e3b..ea34cc3 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -54,7 +54,7 @@ extern const char * const x86_power_flags[32];
extern const char * const x86_bug_flags[NBUGINTS*32];
#define test_cpu_cap(c, bit) \
- test_bit(bit, (unsigned long *)((c)->x86_capability))
+ arch_test_bit(bit, (unsigned long *)((c)->x86_capability))
/*
* There are 32 bits/features in each mask word. The high bits
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2022-05-30 10:39 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 11:07 [PATCH 0/3] x86: Address various objtool complaints Peter Zijlstra
2022-05-02 11:07 ` [PATCH 1/3] objtool: Mark __ubsan_handle_builtin_unreachable() as noreturn Peter Zijlstra
2022-05-02 11:07 ` [PATCH 2/3] x86/cpu: Elide KCSAN for cpu_has() and friends Peter Zijlstra
2022-05-02 11:54 ` Marco Elver
2022-05-02 18:47 ` Josh Poimboeuf
2022-05-03 14:20 ` Mark Rutland
2022-05-30 10:38 ` [tip: objtool/urgent] " tip-bot2 for Peter Zijlstra
2022-05-02 11:07 ` [PATCH 3/3] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds Peter Zijlstra
2022-05-02 11:23 ` Marco Elver
2022-05-02 13:01 ` Peter Zijlstra
2022-05-02 13:09 ` [PATCH v2 " Peter Zijlstra
2022-05-02 13:25 ` Marco Elver
2022-05-02 14:54 ` Peter Zijlstra
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.