x86: Address various objtool complaints
Subsystems (5)
Peter Zijlstra
maintainercover x86: Address various objtool complaints
Hi!
A few objtool fixes that I mean to include in a late pull.
Peter Zijlstra
maintainerPATCH 1/7 x86/entry: Anchor annotation
x86_64-allmodconfig gives:
vmlinux.o: warning: objtool: entry_SYSCALL_compat+0x0: ANNOTATE_NOENDBR on ENDBR
This is due to:
ANNOTATE_NOENDBRSYM_CODE_END(entry_SYSENTER_compat)SYM_CODE_START(entry_SYSCALL_compat)
UNWIND_HINT_EMPTY
ENDBR
And the hint then landing on the first instruction of the next symbol, which happens to be ENDBR. Stick in an int3 to anchor the annotation in the previous symbol.
--- arch/x86/entry/entry_64_compat.S | 1 + 1 file changed, 1 insertion(+)
arch/x86/entry/entry_64_compat.S +1 -0
@@ -124,6 +124,7 @@ SYM_INNER_LABEL(entry_SYSENTER_compat_af jmp .Lsysenter_flags_fixed SYM_INNER_LABEL(__end_entry_SYSENTER_compat, SYM_L_GLOBAL) ANNOTATE_NOENDBR // is_sysenter_singlestep + int3 SYM_CODE_END(entry_SYSENTER_compat) /*
Josh Poimboeuf
maintainerRe: [PATCH 1/7] x86/entry: Anchor annotation
Quoted 25 lines · Peter Zijlstra
x86_64-allmodconfig gives:
vmlinux.o: warning: objtool:
entry_SYSCALL_compat+0x0:ANNOTATE_NOENDBRon ENDBRThis is due to:
ANNOTATE_NOENDBRSYM_CODE_END(entry_SYSENTER_compat)SYM_CODE_START(entry_SYSCALL_compat)
UNWIND_HINT_EMPTY
ENDBRAnd the hint then landing on the first instruction of the next symbol, which happens to be ENDBR. Stick in an int3 to anchor the annotation in the previous symbol.
Fixes 3e3f06950434 ("x86/ibt: Annotate text references")Signed-off-by Peter Zijlstra (Intel) <[email protected]>--- arch/x86/entry/entry_64_compat.S | 1 + 1 file changed, 1 insertion(+)
arch/x86/entry/entry_64_compat.S SYM_INNER_LABEL(entry_SYSENTER_compat_af · line 128
Quoted 5 lines
arch/x86/entry/entry_64_compat.S +1
-0@@ -124,6 +124,7 @@ SYM_INNER_LABEL(entry_SYSENTER_compat_af jmp .Lsysenter_flags_fixed SYM_INNER_LABEL(__end_entry_SYSENTER_compat, SYM_L_GLOBAL) ANNOTATE_NOENDBR // is_sysenter_singlestep + int3 SYM_CODE_END(entry_SYSENTER_compat)
Hm, I get the feeling this warning is pretty much useless anyway. Can we just get rid of the warning instead?
Signature · 1 line
Josh
Peter Zijlstra
maintainerPATCH 2/7 objtool: Extend UNWIND_HINT based ENDBR rules
In reply to Peter ZijlstraExtend the UNWIND hint driven rules for ENDBR placement. Currently objtool expects an ENDBR at any UNWINT_HINT_IRET_REGS that is at +0 of an STB_GLOBAL symbol, with the expectation that this is an exception entry point.
Extend this to also expect ENDBR at UNWIND_HINT_EMPTY at +0 for STB_GLOBAL symbols, with the expectation that these are also machine entry points (SYSCALL et. al.).
This guarantees all machine entry points are covered by objtool rules at the expense of a few additional false positives:
vmlinux.o: warning: objtool: startup_64+0x0: UNWIND_HINT_EMPTY without ENDBR vmlinux.o: warning: objtool: start_cpu0+0x0: UNWIND_HINT_EMPTY without ENDBR
--- arch/x86/kernel/head_64.S | 2 ++ tools/objtool/check.c | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-)
arch/x86/kernel/head_64.S +2 -0
@@ -43,6 +43,7 @@ L3_START_KERNEL = pud_index(__START_KERN .code64 SYM_CODE_START_NOALIGN(startup_64) UNWIND_HINT_EMPTY + ANNOTATE_NOENDBR /* * At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 0, * and someone has loaded an identity mapped page table
@@ -371,6 +372,7 @@ SYM_CODE_END(secondary_startup_64) */ SYM_CODE_START(start_cpu0) UNWIND_HINT_EMPTY + ANNOTATE_NOENDBR movq initial_stack(%rip), %rsp jmp .Ljump_to_C_code SYM_CODE_END(start_cpu0)
tools/objtool/check.c +18 -5
@@ -1947,14 +1947,27 @@ static int read_unwind_hints(struct objt insn->hint = true; -if (opts.ibt && hint->type ==UNWIND_HINT_TYPE_REGS_PARTIAL ) { +if (opts.ibt) {struct symbol *sym =find_symbol_by_offset (insn->sec, insn->offset); -if (sym && sym->bind ==STB_GLOBAL && - insn->type !=INSN_ENDBR && !insn->noendbr) { -WARN_FUNC ("UNWIND_HINT_IRET_REGS without ENDBR" , - insn->sec, insn->offset); +if (!sym || sym->bind !=STB_GLOBAL ) + goto no_entry; + +if (hint->type ==UNWIND_HINT_TYPE_CALL && !hint->sp_reg) { +if (insn->type !=INSN_ENDBR && !insn->noendbr) { +WARN_FUNC ("UNWIND_HINT_EMPTY without ENDBR" , + insn->sec, insn->offset); + } + } + +if (hint->type ==UNWIND_HINT_TYPE_REGS_PARTIAL ) { +if (insn->type !=INSN_ENDBR && !insn->noendbr) { +WARN_FUNC ("UNWIND_HINT_IRET_REGS without ENDBR" , + insn->sec, insn->offset); + } } + +no_entry: ; }if (hint->type ==UNWIND_HINT_TYPE_FUNC ) {
Josh Poimboeuf
maintainerRe: [PATCH 2/7] objtool: Extend UNWIND_HINT based ENDBR rules
Quoted 9 lines · Peter Zijlstra
Extend the UNWIND hint driven rules for ENDBR placement. Currently objtool expects an ENDBR at any
UNWINT_HINT_IRET_REGSthat is at +0 of anSTB_GLOBALsymbol, with the expectation that this is an exception entry point.Extend this to also expect ENDBR at
UNWIND_HINT_EMPTYat +0 forSTB_GLOBALsymbols, with the expectation that these are also machine entry points (SYSCALL et. al.).
Quoted 7 lines
This guarantees all machine entry points are covered by objtool rules at the expense of a few additional false positives:
vmlinux.o: warning: objtool:
startup_64+0x0:UNWIND_HINT_EMPTYwithout ENDBR vmlinux.o: warning: objtool:start_cpu0+0x0:UNWIND_HINT_EMPTYwithout ENDBRSigned-off-by Peter Zijlstra (Intel) <[email protected]>
I can't remember if this was my bright idea, but it feels kind of arbitrary. Hopefully there won't be a lot of false positives.
Anyway, won't SYSCALL-type symbols typically be referenced elsewhere in the kernel and thus be found by the regular IBT validation?
Do you have any examples of where this warning would trigger if there were a missing ENDBR?
Signature · 1 line
Josh
Peter Zijlstra
maintainerRe: [PATCH 2/7] objtool: Extend UNWIND_HINT based ENDBR rules
Quoted 13 lines · Josh Poimboeuf
Quoted 12 lines · Peter Zijlstra
Extend the UNWIND hint driven rules for ENDBR placement. Currently objtool expects an ENDBR at any
UNWINT_HINT_IRET_REGSthat is at +0 of anSTB_GLOBALsymbol, with the expectation that this is an exception entry point.Extend this to also expect ENDBR at
UNWIND_HINT_EMPTYat +0 forSTB_GLOBALsymbols, with the expectation that these are also machine entry points (SYSCALL et. al.).This guarantees all machine entry points are covered by objtool rules at the expense of a few additional false positives:
Quoted 7 lines
Quoted 4 lines
vmlinux.o: warning: objtool:
startup_64+0x0:UNWIND_HINT_EMPTYwithout ENDBR vmlinux.o: warning: objtool:start_cpu0+0x0:UNWIND_HINT_EMPTYwithout ENDBRSigned-off-by Peter Zijlstra (Intel) <[email protected]>I can't remember if this was my bright idea, but it feels kind of arbitrary. Hopefully there won't be a lot of false positives.
The existing UNWIND_HINT_IRET_REGS at +0 was your idea, I'm just trying to cover more.
Quoted 2 lines
Anyway, won't SYSCALL-type symbols typically be referenced elsewhere in the kernel and thus be found by the regular IBT validation?
They do indeed, and that's what we've been relying on. I just figured it would be more consistent to have rules covering all machine entry points.
(also all the Xen entry points are EMPTY like).
Quoted 2 lines
Do you have any examples of where this warning would trigger if there were a missing ENDBR?
No.
Anyway, I can drop these first two patches for now.
Peter Zijlstra
maintainerPATCH 3/7 objtool: Mark __ubsan_handle_builtin_unreachable() as noreturn
In reply to Peter Zijlstra 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-0x4000000000000129b <ni_readpage_cmpr.cold>:
Tell objtool that __ubsan_handle_builtin_unreachable() is a noreturn.
--- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
@@ -185,6 +185,7 @@ static bool __dead_end_function(struct o"stop_this_cpu" ,"__invalid_creds" ,"cpu_startup_entry" , + "__ubsan_handle_builtin_unreachable", };if (!func)
Re: [PATCH 3/7] objtool: Mark __ubsan_handle_builtin_unreachable() as noreturn
Quoted 24 lines · Peter Zijlstra
fs/ntfs3/ntfs3.prelink.o: warning: objtool:ni_read_frame()falls through to next functionni_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
Quoted 7 lines
000000000000129b<ni_readpage_cmpr.cold>:Tell objtool that
__ubsan_handle_builtin_unreachable()is a noreturn.
Quoted 16 lines
--- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+)tools/objtool/check.c +1
-0@@ -185,6 +185,7 @@ static bool __dead_end_function(struct o"stop_this_cpu" ,"__invalid_creds" ,"cpu_startup_entry" , + "__ubsan_handle_builtin_unreachable", };if (!func)
Peter Zijlstra
maintainerPATCH 4/7 x86/cpu: Elide KCSAN for cpu_has() and friends
In reply to Peter ZijlstraAs 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.
--- arch/x86/include/asm/cpufeature.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/cpufeature.h +1 -1
@@ -51,7 +51,7 @@ extern const char * const x86_power_flagextern 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
Re: [PATCH 4/7] x86/cpu: Elide KCSAN for cpu_has() and friends
Quoted 13 lines · Peter Zijlstra
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
Quoted 6 lines
Prevent this by using the arch_*() bitops, which are the underlying bitops without explciit instrumentation.
Quoted 17 lines
--- arch/x86/include/asm/cpufeature.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/include/asm/cpufeature.h +1
-1@@ -51,7 +51,7 @@ extern const char * const x86_power_flagextern 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
Peter Zijlstra
maintainerPATCH 5/7 jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
In reply to Peter ZijlstraWhen 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
Switch to arch_ prefixed atomic to avoid the explicit instrumentation.
--- include/linux/jump_label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/jump_label.h +2 -2
@@ -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); } static __always_inline void jump_label_init(void)
Re: [PATCH 5/7] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
Quoted 11 lines · Peter Zijlstra
When building
x86_64with 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 sectionSwitch to
arch_prefixed atomic to avoid the explicit instrumentation.Reported-by kernel test robot <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>
Quoted 20 lines
--- include/linux/jump_label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/linux/jump_label.h +2
-2@@ -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); } static __always_inline void jump_label_init(void)
Peter Zijlstra
maintainerPATCH 6/7 x86: Always inline on_thread_stack() and current_top_of_stack()
In reply to Peter ZijlstraBecaues GCC clearly lost it's marbles again...
vmlinux.o: warning: objtool: enter_from_user_mode+0x4e: call to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x53: call to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x4e: call to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x4e: call to on_thread_stack() leaves .noinstr.text section
vmlinux.o: warning: objtool: enter_from_user_mode+0x4e: call to current_top_of_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x53: call to current_top_of_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x4e: call to current_top_of_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x4e: call to current_top_of_stack() leaves .noinstr.text section
--- arch/x86/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/processor.h +2 -2
@@ -559,7 +559,7 @@ static __always_inline void native_swapg#endif } -static inline unsigned long current_top_of_stack (void ) +static __always_inline unsigned long current_top_of_stack (void ) {/* * We can't read directly from tss.sp0: sp0 on x86_32 is special in
@@ -569,7 +569,7 @@ static inline unsigned long current_top_return this_cpu_read_stable (cpu_current_top_of_stack); } -static inline bool on_thread_stack (void ) +static __always_inline bool on_thread_stack(void) {return (unsigned long )(current_top_of_stack () - current_stack_pointer) <THREAD_SIZE ;
[tip: objtool/urgent] x86: Always inline on_thread_stack() and current_top_of_stack()
The following commit has been merged into the objtool/urgent branch of tip:
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: 1894a4030582472336c2873cb07911ce67e0d14e Gitweb: https://git.kernel.org/tip/1894a4030582472336c2873cb07911ce67e0d14e Author: Peter Zijlstra <[email protected]> AuthorDate: Sat, 07 May 2022 13:37:45 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 27 May 2022 12:34:44 +02:00
x86: Always inline on_thread_stack() and current_top_of_stack()
Becaues GCC clearly lost it's marbles again...
vmlinux.o: warning: objtool: enter_from_user_mode+0x4e: call to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x53: call to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x4e: call to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x4e: call to on_thread_stack() leaves .noinstr.text section
vmlinux.o: warning: objtool: enter_from_user_mode+0x4e: call to current_top_of_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x53: call to current_top_of_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x4e: call to current_top_of_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x4e: call to current_top_of_stack() leaves .noinstr.text section
--- arch/x86/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/processor.h +2 -2
@@ -559,7 +559,7 @@ static __always_inline void native_swapgs(void)#endif } -static inline unsigned long current_top_of_stack (void ) +static __always_inline unsigned long current_top_of_stack (void ) {/* * We can't read directly from tss.sp0: sp0 on x86_32 is special in
@@ -569,7 +569,7 @@ static inline unsigned long current_top_of_stack(void)return this_cpu_read_stable (cpu_current_top_of_stack); } -static inline bool on_thread_stack (void ) +static __always_inline bool on_thread_stack(void) {return (unsigned long )(current_top_of_stack () - current_stack_pointer) <THREAD_SIZE ;
Re: [PATCH 6/7] x86: Always inline on_thread_stack() and current_top_of_stack()
In reply to Peter ZijlstraQuoted 2 lines · Peter Zijlstra
Becaues GCC clearly lost it's marbles again...
This must have been with some of the big sanitizers though, right?
Quoted 11 lines
vmlinux.o: warning: objtool:
enter_from_user_mode+0x4e: call toon_thread_stack()leaves .noinstr.text section vmlinux.o: warning: objtool:syscall_enter_from_user_mode+0x53: call toon_thread_stack()leaves .noinstr.text section vmlinux.o: warning: objtool:syscall_enter_from_user_mode_prepare+0x4e: call toon_thread_stack()leaves .noinstr.text section vmlinux.o: warning: objtool:irqentry_enter_from_user_mode+0x4e: call toon_thread_stack()leaves .noinstr.text sectionvmlinux.o: warning: objtool:
enter_from_user_mode+0x4e: call tocurrent_top_of_stack()leaves .noinstr.text section vmlinux.o: warning: objtool:syscall_enter_from_user_mode+0x53: call tocurrent_top_of_stack()leaves .noinstr.text section vmlinux.o: warning: objtool:syscall_enter_from_user_mode_prepare+0x4e: call tocurrent_top_of_stack()leaves .noinstr.text section vmlinux.o: warning: objtool:irqentry_enter_from_user_mode+0x4e: call tocurrent_top_of_stack()leaves .noinstr.text sectionSigned-off-by Peter Zijlstra (Intel) <[email protected]>
Quoted 26 lines
--- arch/x86/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/include/asm/processor.h +2
-2@@ -559,7 +559,7 @@ static __always_inline void native_swapg#endif } -static inline unsigned long current_top_of_stack (void ) +static __always_inline unsigned long current_top_of_stack (void ) {/* * We can't read directly from tss.sp0: sp0 on x86_32 is special in @@ -569,7 +569,7 @@ static inline unsigned long current_top_return this_cpu_read_stable (cpu_current_top_of_stack); } -static inline bool on_thread_stack (void ) +static __always_inline bool on_thread_stack(void) {return (unsigned long )(current_top_of_stack () - current_stack_pointer) <THREAD_SIZE ;
Peter Zijlstra
maintainerPATCH 7/7 context_tracking: Always inline empty stubs
In reply to Peter ZijlstraBecause GCC is seriously challenged..
vmlinux.o: warning: objtool: enter_from_user_mode+0x85: call to context_tracking_enabled() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x8f: call to context_tracking_enabled() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x85: call to context_tracking_enabled() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x85: call to context_tracking_enabled() leaves .noinstr.text section
--- include/linux/context_tracking_state.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/context_tracking_state.h +4 -4
@@ -46,10 +46,10 @@ static __always_inline bool context_tracreturn __this_cpu_read (context_tracking.state) ==CONTEXT_USER ; }#else -static inline bool context_tracking_in_user (void ) {return false; } -static inline bool context_tracking_enabled (void ) {return false; } -static inline bool context_tracking_enabled_cpu (int cpu) {return false; } -static inline bool context_tracking_enabled_this_cpu (void ) {return false; } +static __always_inline bool context_tracking_in_user(void) { return false; } +static __always_inline bool context_tracking_enabled(void) { return false; } +static __always_inline bool context_tracking_enabled_cpu(int cpu) { return false; } +static __always_inline bool context_tracking_enabled_this_cpu(void) { return false; }#endif /* CONFIG_CONTEXT_TRACKING */ #endif
Josh Poimboeuf
maintainerRe: [PATCH 7/7] context_tracking: Always inline empty stubs
Quoted 1 line · Peter Zijlstra
Because GCC is seriously challenged..
Or are these CONFIG_DEBUG_SECTION_MISMATCH?
Signature · 1 line
Josh
Mark Rutland
Acked-byRe: [PATCH 7/7] context_tracking: Always inline empty stubs
Quoted 4 lines · Josh Poimboeuf
Quoted 1 line · Peter Zijlstra
Because GCC is seriously challenged..
Or are these
CONFIG_DEBUG_SECTION_MISMATCH?
Does it matter?
The fact that CONFIG_DEBUG_SECTION_MISMATCH=y forces GCC to place these out-of-line is really a debugging aid, since it shows us what it could potentially leave out-of-line. It's not the *only* reason GCC might do this (e.g. I see sanitizers and other debug options often have similar effects on arm64).
So FWIW, for the patch:
... as I'd like this for arm64, even if you don't beleive that's necessary for x86.
Thanks,
Mark.
Josh Poimboeuf
maintainerRe: [PATCH 7/7] context_tracking: Always inline empty stubs
Quoted 7 lines · Mark Rutland
Quoted 4 lines · Josh Poimboeuf
Quoted 1 line · Peter Zijlstra
Because GCC is seriously challenged..
Or are these
CONFIG_DEBUG_SECTION_MISMATCH?Does it matter?
Yes, because I believe the only thing this option is good for is creating a bunch of useless '__always_inline' patches:
Signature · 1 line
Josh
Re: [PATCH 7/7] context_tracking: Always inline empty stubs
Quoted 5 lines · Josh Poimboeuf
Quoted 4 lines · Mark Rutland
Quoted 3 lines · Josh Poimboeuf
Quoted 1 line · Peter Zijlstra
Because GCC is seriously challenged..
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Or are these
CONFIG_DEBUG_SECTION_MISMATCH?Does it matter?
Yes, because I believe the only thing this option is good for is creating a bunch of useless '
__always_inline' patches:
Sure, but as I said, there are other reasons why the compiler can generate code in this way, even if that's unlikely. Without __always_inline we don't actually have a guarantee of inlining, so those warning *is* legitimate, even if 99.99% of the time the compiler doesn't decide to generate code in a silly way.
Thanks,
Mark.
[tip: objtool/urgent] context_tracking: Always inline empty stubs
In reply to Peter ZijlstraThe following commit has been merged into the objtool/urgent branch of tip:
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: 620f8d3bd3d5e82dff8cc591c831827d4beeae2e Gitweb: https://git.kernel.org/tip/620f8d3bd3d5e82dff8cc591c831827d4beeae2e Author: Peter Zijlstra <[email protected]> AuthorDate: Sat, 07 May 2022 13:35:37 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 27 May 2022 12:34:44 +02:00
context_tracking: Always inline empty stubs
Because GCC is seriously challenged..
vmlinux.o: warning: objtool: enter_from_user_mode+0x85: call to context_tracking_enabled() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x8f: call to context_tracking_enabled() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x85: call to context_tracking_enabled() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x85: call to context_tracking_enabled() leaves .noinstr.text section
--- include/linux/context_tracking_state.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/linux/context_tracking_state.h +4 -4
@@ -46,10 +46,10 @@ static __always_inline bool context_tracking_in_user(void)return __this_cpu_read (context_tracking.state) ==CONTEXT_USER ; }#else -static inline bool context_tracking_in_user (void ) {return false; } -static inline bool context_tracking_enabled (void ) {return false; } -static inline bool context_tracking_enabled_cpu (int cpu) {return false; } -static inline bool context_tracking_enabled_this_cpu (void ) {return false; } +static __always_inline bool context_tracking_in_user(void) { return false; } +static __always_inline bool context_tracking_enabled(void) { return false; } +static __always_inline bool context_tracking_enabled_cpu(int cpu) { return false; } +static __always_inline bool context_tracking_enabled_this_cpu(void) { return false; }#endif /* CONFIG_CONTEXT_TRACKING */ #endif