Skip to contentSkip to conversation

objtool fixes

GIT PULL Merged Ingo Molnar 4 participants 15 messages Apr 1, 2025 – Apr 3, 2025

lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest objtool/urgent Git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git objtool-urgent-2025-04-01

# HEAD: 7c977393b8277ed319e92e4b598b26598c9d30c0 objtool/loongarch: Add unwind hints in prepare_frametrace()

These are objtool fixes and updates by Josh Poimboeuf, centered around the fallout from the new CONFIG_OBJTOOL_WERROR=y feature, which, despite its default-off nature, increased the profile/impact of objtool warnings:

- Improve error handling and the presentation of warnings/errors.

- Revert the new summary warning line that some test-bot tools interpreted as new regressions.

- Fix a number of objtool warnings in various drivers, core kernel code and architecture code. About half of them are potential problems related to out-of-bounds accesses or potential undefined behavior, the other half are additional objtool annotations.

- Update objtool to latest (known) compiler quirks and objtool bugs triggered by compiler code generation

- Misc fixes

Thanks,

Ingo

------------------>
David Laight (1):
objtool: Fix verbose disassembly if CROSS_COMPILE isn't set

Josh Poimboeuf (35):
objtool: Fix detection of consecutive jump tables on Clang 20
objtool: Warn when disabling unreachable warnings
objtool: Ignore entire functions rather than instructions
objtool: Fix X86_FEATURE_SMAP alternative handling
objtool: Fix CONFIG_OBJTOOL_WERROR for vmlinux.o
objtool: Fix init_module() handling
objtool: Silence more KCOV warnings
objtool: Properly disable uaccess validation
objtool: Improve error handling
objtool: Reduce CONFIG_OBJTOOL_WERROR verbosity
objtool: Fix up some outdated references to ENTRY/ENDPROC
objtool: Remove --no-unreachable for noinstr-only vmlinux.o runs
objtool: Remove redundant opts.noinstr dependency
objtool, spi: amd: Fix out-of-bounds stack access in amd_set_spi_freq()
objtool, nvmet: Fix out-of-bounds stack access in nvmet_ctrl_state_show() objtool, media: dib8000: Prevent divide-by-zero in dib8000_set_dds()
objtool, panic: Disable SMAP in __stack_chk_fail()
objtool, Input: cyapa - Remove undefined behavior in cyapa_update_fw_store() objtool, ASoC: codecs: wcd934x: Remove potential undefined behavior in wcd934x_slim_irq_handler() objtool, regulator: rk808: Remove potential undefined behavior in rk806_set_mode_dcdc() objtool, lkdtm: Obfuscate the do_nothing() pointer
objtool: Fix NULL printf() '%s' argument in builtin-check.c:save_argv()
objtool: Fix segfault in ignore_unreachable_insn()
objtool: Fix STACK_FRAME_NON_STANDARD for cold subfunctions
objtool, drm/vmwgfx: Don't ignore vmw_send_msg() for ORC
objtool: Silence more KCOV warnings, part 2
objtool: Ignore end-of-section jumps for KCOV/GCOV
objtool: Append "()" to function name in "unexpected end of section" warning Revert "objtool: Increase per-function WARN_FUNC() rate limit"
objtool: Always fail on fatal errors
objtool: Change "warning:" to "error: " for fatal errors
sched/smt: Always inline sched_smt_active()
context_tracking: Always inline ct_{nmi,irq}_{enter,exit}()
rcu-tasks: Always inline rcu_irq_work_resched()
objtool/loongarch: Add unwind hints in prepare_frametrace()

 arch/loongarch/include/asm/stacktrace.h   |   3 +
 arch/loongarch/include/asm/unwind_hints.h |  10 +-
 arch/x86/include/asm/arch_hweight.h       |   6 +-
 arch/x86/include/asm/smap.h               |  23 +-
 arch/x86/include/asm/xen/hypercall.h      |   6 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c       |   2 +-
 drivers/input/mouse/cyapa.c               |   4 +-
 drivers/media/dvb-frontends/dib8000.c     |   5 +-
 drivers/misc/lkdtm/perms.c                |  14 +-
 drivers/nvme/target/debugfs.c             |   2 +-
 drivers/regulator/rk808-regulator.c       |   4 +-
 drivers/spi/spi-amd.c                     |   2 +-
 include/linux/context_tracking_irq.h      |   8 +-
 include/linux/linkage.h                   |   4 -
 include/linux/objtool.h                   |   2 +-
 include/linux/rcupdate.h                  |   2 +-
 include/linux/sched/smt.h                 |   2 +-
 kernel/panic.c                            |   6 +
 scripts/Makefile.lib                      |   4 +-
 scripts/Makefile.vmlinux_o                |  15 +-
 sound/soc/codecs/wcd934x.c                |   2 +-
 tools/objtool/Documentation/objtool.txt   |  10 +-
 tools/objtool/arch/loongarch/decode.c     |  14 +-
 tools/objtool/arch/loongarch/orc.c        |   8 +-
 tools/objtool/arch/x86/decode.c           |  15 +-
 tools/objtool/arch/x86/orc.c              |   6 +-
 tools/objtool/arch/x86/special.c          |  38 +-
 tools/objtool/builtin-check.c             | 132 +++---
 tools/objtool/check.c                     | 647 +++++++++++++++---------------
 tools/objtool/elf.c                       | 156 ++++---
 tools/objtool/include/objtool/builtin.h   |   6 +-
 tools/objtool/include/objtool/check.h     |   3 +-
 tools/objtool/include/objtool/elf.h       |  30 +-
 tools/objtool/include/objtool/objtool.h   |   2 +-
 tools/objtool/include/objtool/special.h   |   4 +-
 tools/objtool/include/objtool/warn.h      |  62 +--
 tools/objtool/objtool.c                   |  15 +-
 tools/objtool/orc_dump.c                  |  30 +-
 tools/objtool/special.c                   |  25 +-
 39 files changed, 679 insertions(+), 650 deletions(-)
merge bot Merged
#1 lore raw
The pull request you sent on Tue, 1 Apr 2025 21:57:29 +0200:

The pull request you sent on Tue, 1 Apr 2025 21:57:29 +0200:

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git objtool-urgent-2025-04-01

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/92b71befc349587d58fdbbe6cdd68fb67f4933a8

Thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html
#2 lore raw
In reply to Ingo Molnar
Quoted 5 lines · Ingo Molnar

- Fix a number of objtool warnings in various drivers, core kernel code and architecture code. About half of them are potential problems related to out-of-bounds accesses or potential undefined behavior, the other half are additional objtool annotations.

So I've pulled this, but I really dislike some of it.

That

Quoted 2 lines

Josh Poimboeuf (35):
objtool: Fix X86_FEATURE_SMAP alternative handling

makes a bad thing even worse.

Apparently nobody else ever looks at generated code, but dammit, the clac/stac code generation has turned the ugly up to 11.

Yes, the altinstruction replacement thing was already making the generated asm hard to read, but now it's *also* adding this garbage to it:

        911:
        .pushsection .discard.annotate_insn,"M",@progbits,8
        .long 911b - .
        .long 6
        .popsection

which is just pure unadulterated pointless noise.

That "annotation #6" is WORTHLESS.

Dammit, objtool could have figured that annotation out ON ITS OWN without generating shit in our code. It's not like it doesn't already look at alternatives, and it's not like it couldn't just have seen "oh, look, it's a nop instruction with a clac/stac instruction as an alternative".

So why does it add that pointless garbage that makes already nasty code even nastier?

Please fix this.

Linus

#3 lore raw
Quoted 7 lines · Linus Torvalds
Quoted 5 lines · Ingo Molnar

- Fix a number of objtool warnings in various drivers, core kernel code and architecture code. About half of them are potential problems related to out-of-bounds accesses or potential undefined behavior, the other half are additional objtool annotations.

Quoted 8 lines

So I've pulled this, but I really dislike some of it.

That

Quoted 2 lines

Josh Poimboeuf (35):
objtool: Fix X86_FEATURE_SMAP alternative handling

makes a bad thing even worse.

Sorry about that, we'll fix it!!

Thanks,

Ingo

#4 lore raw
In reply to Linus Torvalds
Quoted 8 lines · Linus Torvalds
        911:
        .pushsection .discard.annotate_insn,"M",@progbits,8
        .long 911b - .
        .long 6
        .popsection

which is just pure unadulterated pointless noise.

Quoted 7 lines

That "annotation #6" is WORTHLESS.

Dammit, objtool could have figured that annotation out ON ITS OWN without generating shit in our code. It's not like it doesn't already look at alternatives, and it's not like it couldn't just have seen "oh, look, it's a nop instruction with a clac/stac instruction as an alternative".

Ugh, fragile hard-coded special cases like that are exactly what we're trying to get away from. They make the code unmaintainable and they end up triggering false positives, just like the one fixed by that patch in the first place.

Signature · 1 line
Josh
#5 lore raw
Quoted 4 lines · Josh Poimboeuf
Quoted 2 lines · Linus Torvalds

Apparently nobody else ever looks at generated code, but dammit, the clac/stac code generation has turned the ugly up to 11.

BTW., I do look at generated code, and I know others do too, but at the .o most of the time, not at the .s code, via two ways:

1) objdump --disassemble-all .o

2) perf top's live kernel function annotation and disassembler feature that uses /dev/mem. (While turning off KASLR, ptr-obfuscation, turning perf_event_paranoid up to 11^H -1, etc.)

Such output is more readable to me:

# [ __memmove_avx_unaligned_erms annotated screen: ]

0.00 1ea: vzeroupper

              ← retq            
                nop             
         1f0:   testq      %rcx,%rcx
              ↑ je         1ea  
         1f5:   vmovdqu    0x20(%rsi), %ymm5
                vmovdqu    0x40(%rsi), %ymm6
                leaq       -0x81(%rdi,%rdx),%rcx
                vmovdqu    0x60(%rsi), %ymm7
                vmovdqu    -0x20(%rsi,%rdx), %ymm8
                subq       %rdi,%rsi
                andq       $-0x20,%rcx
                addq       %rcx,%rsi
                nop             
   5.87  220:   vmovdqu    0x60(%rsi), %ymm1
   8.09         vmovdqu    0x40(%rsi), %ymm2
  10.34         vmovdqu    0x20(%rsi), %ymm3
  11.29         vmovdqu    (%rsi), %ymm4
  13.45         addq       $-0x80,%rsi
  13.47         vmovdqa    %ymm1,0x60(%rcx)
  11.26         vmovdqa    %ymm2,0x40(%rcx)
   9.16         vmovdqa    %ymm3,0x20(%rcx)
   7.45         vmovdqa    %ymm4,(%rcx)
   4.98         addq       $-0x80,%rcx
   4.57         cmpq       %rcx,%rdi
              ↑ jb         220  
                vmovdqu    %ymm0, (%rdi)
                vmovdqu    %ymm5, 0x20(%rdi)
                vmovdqu    %ymm6, 0x40(%rdi)
                vmovdqu    %ymm7, 0x60(%rdi)
                vmovdqu    %ymm8, -0x20(%rdx,%rdi)
                vzeroupper      
              ← retq            
                nop             
                nop             

( and the 'P' key within perf-top will print this out into the separate
__memmove_avx_unaligned_erms.annotation for editor based inspection. )

because:

- this kind of disassembler output is more standardized, regardless of compiler used,

- it's generally less messy looking,

- it gives ground-truth instead of being some intermediate layer in the toolchain that might or might not be the real deal,

- it shows alignment and the various other effects linkers may apply,

- there's profiling data overlaid if it's a perf top run,

- and on a live kernel it also sees through the kernel's various layers of runtime patching code obfuscation facilities, also known as: alternative-instructions, tracepoints and jump labels.

The compiler's .s is really a last-ditch way to look at generated machine code, for me at least.

Quoted 21 lines
Quoted 13 lines

Yes, the altinstruction replacement thing was already making the generated asm hard to read, but now it's *also* adding this garbage to it:

        911:
        .pushsection .discard.annotate_insn,"M",@progbits,8
        .long 911b - .
        .long 6
        .popsection

which is just pure unadulterated pointless noise.

Quoted 7 lines

That "annotation #6" is WORTHLESS.

Dammit, objtool could have figured that annotation out ON ITS OWN without generating shit in our code. It's not like it doesn't already look at alternatives, and it's not like it couldn't just have seen "oh, look, it's a nop instruction with a clac/stac instruction as an alternative".

Quoted 4 lines

Ugh, fragile hard-coded special cases like that are exactly what we're trying to get away from. They make the code unmaintainable and they end up triggering false positives, just like the one fixed by that patch in the first place.

So the problem is, by reducing objtool complexity a bit:

# 1154bbd326de objtool: Fix X86_FEATURE_SMAP alternative handling

   8 files changed, 37 insertions(+), 89 deletions(-)

and fixing these two false positive warnings where the 'objtool looks at the alternatives code' heuristics failed:

arch/x86/mm/fault.o: warning: objtool: do_user_addr_fault+0x8ec: __stack_chk_fail() missing __noreturn in .c/.h or NORETURN() in noreturns.h arch/x86/mm/fault.o: warning: objtool: do_user_addr_fault+0x8f1: unreachable instruction

... we have now uglified the kernel's .s asm output space for all affected stac()/clac() using functions:

    starship:~/tip> diff -up usercopy.s.before usercopy.s.after
    --- usercopy.s.before	2025-04-03 16:33:07.286944538 +0200
    +++ usercopy.s.after	2025-04-03 16:32:41.770041092 +0200
    @@ -78,11 +78,16 @@ copy_from_user_nmi:
     # ./include/linux/uaccess.h:244: 	current->pagefault_disabled++;
     	addl	$1, 2748(%rdx)	#, _25->pagefault_disabled
     # ./include/linux/uaccess.h:266: 	barrier();
    -# ./arch/x86/include/asm/smap.h:35: 	alternative("", "stac", X86_FEATURE_SMAP);
    +# ./arch/x86/include/asm/smap.h:35: 	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP);
     #APP
     # 35 "./arch/x86/include/asm/smap.h" 1
     	# ALT: oldinstr
     771:
    +	911:
    +	.pushsection .discard.annotate_insn,"M",@progbits,8
    +	.long 911b - .
    +	.long 6
    +	.popsection
     	
     772:
     # ALT: padding
    @@ -140,10 +145,15 @@ copy_from_user_nmi:
      .popsection
     
     # 0 "" 2
    -# ./arch/x86/include/asm/smap.h:29: 	alternative("", "clac", X86_FEATURE_SMAP);
    +# ./arch/x86/include/asm/smap.h:29: 	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP);
     # 29 "./arch/x86/include/asm/smap.h" 1
     	# ALT: oldinstr
     771:
    +	911:
    +	.pushsection .discard.annotate_insn,"M",@progbits,8
    +	.long 911b - .
    +	.long 6
    +	.popsection
     	
     772:
     # ALT: padding

Is there a way to make this more compact, more readable?

Or if not, we just have to do the more fragile thing I suspect? It's a tool after all.

Thanks,

Ingo

#6 lore raw
Quoted 31 lines · Ingo Molnar
    +# ./arch/x86/include/asm/smap.h:35: 	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP);
     #APP
     # 35 "./arch/x86/include/asm/smap.h" 1
     	# ALT: oldinstr
     771:
    +	911:
    +	.pushsection .discard.annotate_insn,"M",@progbits,8
    +	.long 911b - .
    +	.long 6
    +	.popsection
     	
     772:
     # ALT: padding
    @@ -140,10 +145,15 @@ copy_from_user_nmi:
      .popsection
     
     # 0 "" 2
    -# ./arch/x86/include/asm/smap.h:29: 	alternative("", "clac", X86_FEATURE_SMAP);
    +# ./arch/x86/include/asm/smap.h:29: 	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP);
     # 29 "./arch/x86/include/asm/smap.h" 1
     	# ALT: oldinstr
     771:
    +	911:
    +	.pushsection .discard.annotate_insn,"M",@progbits,8
    +	.long 911b - .
    +	.long 6
    +	.popsection
     	
     772:
     # ALT: padding
Quoted 1 line

Is there a way to make this more compact, more readable?

Put it all one line? I'm open to ideas :-)

Quoted 2 lines

Or if not, we just have to do the more fragile thing I suspect? It's a tool after all.

Objtool is an integral part of the kernel. Making it more fragile and less maintainable has the same effect on the kernel itself.

In fact we need the toolchain to be *more* reliable than the kernel. Otherwise problems multiply, and kernel quality goes down the tubes.

And I would rather spend time fixing actual kernel bugs than chasing down random nonsensical warnings.

Sure, ideally the .s file would be pretty, but not at the expense of actual robustness and functionality... Honestly I had to double check it wasn't April 1.

Signature · 1 line
Josh
#7 lore raw
Quoted 29 lines · Josh Poimboeuf
Quoted 28 lines · Ingo Molnar
    +# ./arch/x86/include/asm/smap.h:35: 	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP);
     #APP
     # 35 "./arch/x86/include/asm/smap.h" 1
     	# ALT: oldinstr
     771:
    +	911:
    +	.pushsection .discard.annotate_insn,"M",@progbits,8
    +	.long 911b - .
    +	.long 6
    +	.popsection
     	
     772:
     # ALT: padding
    @@ -140,10 +145,15 @@ copy_from_user_nmi:
      .popsection
     
     # 0 "" 2
    -# ./arch/x86/include/asm/smap.h:29: 	alternative("", "clac", X86_FEATURE_SMAP);
    +# ./arch/x86/include/asm/smap.h:29: 	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP);
     # 29 "./arch/x86/include/asm/smap.h" 1
     	# ALT: oldinstr
     771:
    +	911:
    +	.pushsection .discard.annotate_insn,"M",@progbits,8
    +	.long 911b - .
    +	.long 6
    +	.popsection
Quoted 6 lines
Quoted 4 lines

772:
# ALT: padding

Is there a way to make this more compact, more readable?

Put it all one line? I'm open to ideas :-)

I suppose there's no way to make the '6' a bit less magic at this point, we are post-processed already. :-/

Thanks,

Ingo

#8 lore raw
In reply to Josh Poimboeuf
Quoted 29 lines · Josh Poimboeuf
Quoted 28 lines · Ingo Molnar
    +# ./arch/x86/include/asm/smap.h:35: 	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP);
     #APP
     # 35 "./arch/x86/include/asm/smap.h" 1
     	# ALT: oldinstr
     771:
    +	911:
    +	.pushsection .discard.annotate_insn,"M",@progbits,8
    +	.long 911b - .
    +	.long 6
    +	.popsection
     	
     772:
     # ALT: padding
    @@ -140,10 +145,15 @@ copy_from_user_nmi:
      .popsection
     
     # 0 "" 2
    -# ./arch/x86/include/asm/smap.h:29: 	alternative("", "clac", X86_FEATURE_SMAP);
    +# ./arch/x86/include/asm/smap.h:29: 	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP);
     # 29 "./arch/x86/include/asm/smap.h" 1
     	# ALT: oldinstr
     771:
    +	911:
    +	.pushsection .discard.annotate_insn,"M",@progbits,8
    +	.long 911b - .
    +	.long 6
    +	.popsection
Quoted 6 lines
Quoted 4 lines

772:
# ALT: padding

Is there a way to make this more compact, more readable?

Put it all one line? I'm open to ideas :-)

How about adding a comment and making it one line like so?

# OBJTOOL ANNOTATION
911: .pushsection .discard.annotate_insn,"M",@progbits,8; .long 911b - .; .long 6; .popsection

Signature · 1 line
Josh
#9 lore raw
Quoted 3 lines · Josh Poimboeuf

# OBJTOOL ANNOTATION
911: .pushsection .discard.annotate_insn,"M",@progbits,8; .long 911b - .; .long 6; .popsection

Josh, what's wrong with just disassembling the damn instruction?

It's what objtool does.

By all means add annotations for when the kernel does something *special*, and the annotation is "this violates the usual rules". Those kinds of annotations make perfect sense, and are a "don't complain about this, because I know I'm doing something odd".

So annotations for things like non-standard stack frames etc are a good thing.

But dammit, clac/stac is *not* that. Quite the reverse. clac/stac *is* the usual rule. clac/stac *is* the annotation.

Linus

#10 lore raw
Quoted 9 lines · Linus Torvalds

Josh, what's wrong with just disassembling the damn instruction?

It's what objtool does.

By all means add annotations for when the kernel does something *special*, and the annotation is "this violates the usual rules". Those kinds of annotations make perfect sense, and are a "don't complain about this, because I know I'm doing something odd".

Quoted 4 lines

So annotations for things like non-standard stack frames etc are a good thing.

But dammit, clac/stac is *not* that. Quite the reverse. clac/stac *is* the usual rule. clac/stac *is* the annotation.

There's also smap_save() / smap_restore(). For the latter we'd need to look for alternatives with "push reg; popf", which is definitely not SMAP-specific. So we'd need to start reading feature bits again, which ends up even worse than what we had before.

I still don't see what's wrong with something like this:

# OBJTOOL (IGNORE_ALTERNATIVE)
911: .pushsection .discard.annotate_insn,"M",@progbits,8; .long 911b - .; .long 6; .popsection

Now compare that with an alternative:

# ./arch/x86/include/asm/cpufeature.h:101: asm goto(ALTERNATIVE_TERNARY("jmp 6f", %c[feature], "", "jmp %l[t_no]")
#APP
# 101 "./arch/x86/include/asm/cpufeature.h" 1
# ALT: oldinstr
771:
# ALT: oldinstr
771:
jmp 6f
772:
# ALT: padding
.skip -(((775f-774f)-(772b-771b)) > 0) * ((775f-774f)-(772b-771b)),0x90 773:
.pushsection .altinstructions,"a"
.long 771b - .
.long 774f - .
.4byte ( 3*32+21)
.byte 773b-771b
.byte 775f-774f
.popsection
.pushsection .altinstr_replacement, "ax"
# ALT: replacement
774:

	jmp .L250	#

775:
.popsection

772:
# ALT: padding
.skip -(((775f-774f)-(772b-771b)) > 0) * ((775f-774f)-(772b-771b)),0x90 773:
.pushsection .altinstructions,"a"
.long 771b - .
.long 774f - .
.4byte 516 #
.byte 773b-771b
.byte 775f-774f
.popsection
.pushsection .altinstr_replacement, "ax"
# ALT: replacement
774:

775:
.popsection
.pushsection .altinstr_aux,"ax"
6:
testb $16, boot_cpu_data+112(%rip) #,
jnz .L249 #
jmp .L250 #
.popsection

# 0 "" 2
#NO_APP

Signature · 1 line
Josh
#11 lore raw
Quoted 5 lines · Josh Poimboeuf

There's also smap_save() / smap_restore(). For the latter we'd need to look for alternatives with "push reg; popf", which is definitely not SMAP-specific. So we'd need to start reading feature bits again, which ends up even worse than what we had before.

Now, I agree that smap_save / smap_restore might be worthy of an annotation, to show that "this is just a push/pop, but the intent is to save AC".

Would that be ok?

Because I want to have *less* noise for clac/stac, not more.

The reason I noticed this immediately is that clac/stac are literally one of my "top 10" things I ever look at.

The optimized user copies (so the masked_user_access_begin() -> unsafe_get_user() -> user_read_access_end() path) and the dcache are the two places I look at almost constantly, because it turns out that those two things are the ones that show up the most on my machines.

The dcache doesn't do the clac/stac part (well, 'strncpy_from_user()' does, but while that's related to, it precedes the actual pathname lookup), so it's not like clac/stac is *all* I look at, but it really is important to me.

Linus

#12 lore raw
Quoted 7 lines · Linus Torvalds
Quoted 5 lines · Josh Poimboeuf

There's also smap_save() / smap_restore(). For the latter we'd need to look for alternatives with "push reg; popf", which is definitely not SMAP-specific. So we'd need to start reading feature bits again, which ends up even worse than what we had before.

Quoted 5 lines

Now, I agree that smap_save / smap_restore might be worthy of an annotation, to show that "this is just a push/pop, but the intent is to save AC".

Would that be ok?

Yeah, that should be fine.

If we can keep the annotations for those other alternatives, that leaves most of the benefits of the original patch intact.

The "nop with stac/clac" alternative check does look trivial enough.

Signature · 1 line
Josh
#13 lore raw
In reply to Ingo Molnar
Quoted 8 lines · Ingo Molnar

BTW., I do look at generated code, and I know others do too, but at the .o most of the time, not at the .s code, via two ways:

1) objdump --disassemble-all .

2) perf top's live kernel function annotation and disassembler feature that uses /dev/mem.

Sure, I do both of those too.

However, you are quite wrong:

Quoted 1 line

Such output is more readable to me:

it's readable for some cases.

But in other cases, it loses a *lot* of information that is in the generated assembler.

For example, gcc will helpfully annotate the asm output with the names of the pseudos it uses, so you see things like this:

movq %rbx, %rax # hashlen, __ret

where you see what the names of the variables are (and then for pseudos that are just internal. you see things like "_31", which is admittedly not helpful).

And yes, it's not exactly "legible", but it's the kind of thing that does help when you look at code and don't have to follow by hand what '%rbx' actually is.

(This is one reason I tend to prefer looking at gcc output over clang
- gcc adds more information like this, and admittedly I'm probably *much* too used to all the oddities that gcc sometimes does)

So no - objdump and perf is not replacements for just looking at the compiler output. They are *also* good sources, of course, but objdump output in particular is just *horrendous*.

objdump still can't even do relocations right, for chrissake, so it outputs usually just line noise. Any call to another object file will be just noise:

0000000000000000 <vfs_pressure_ratio>:

       0:       call   5 <vfs_pressure_ratio+0x5>

that's the "call __fentry__" because objdump output is *so* bad.

It's not fit for humans.

I do still look at it in very particular circumstances, though.

Linus

#14 lore raw
In reply to Josh Poimboeuf
Quoted 5 lines · Josh Poimboeuf

Ugh, fragile hard-coded special cases like that are exactly what we're trying to get away from. They make the code unmaintainable and they end up triggering false positives, just like the one fixed by that patch in the first place.

Josh, the "unmaintainable" is more important for the *kernel* than for objtool.

And the whole *point* of objtool is to check the object file and do those "hard-coded special cases".

So the argument makes no sense.

Linus