01 Oct, 2020

1 commit

  • [ Upstream commit db6c6a0df840e3f52c84cc302cc1a08ba11a4416 ]

    When a function is annotated with STACK_FRAME_NON_STANDARD, objtool
    doesn't validate its code paths. It also skips sibling call detection
    within the function.

    But sibling call detection is actually needed for the case where the
    ignored function doesn't have any return instructions. Otherwise
    objtool naively marks the function as implicit static noreturn, which
    affects the reachability of its callers, resulting in "unreachable
    instruction" warnings.

    Fix it by just enabling sibling call detection for ignored functions.
    The 'insn->ignore' check in add_jump_destinations() is no longer needed
    after

    e6da9567959e ("objtool: Don't use ignore flag for fake jumps").

    Fixes the following warning:

    arch/x86/kvm/vmx/vmx.o: warning: objtool: vmx_handle_exit_irqoff()+0x142: unreachable instruction

    which triggers on an allmodconfig with CONFIG_GCOV_KERNEL unset.

    Reported-by: Linus Torvalds
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Borislav Petkov
    Acked-by: Linus Torvalds
    Link: https://lkml.kernel.org/r/5b1e2536cdbaa5246b60d7791b76130a74082c62.1599751464.git.jpoimboe@redhat.com
    Signed-off-by: Sasha Levin

    Josh Poimboeuf
     

26 Aug, 2020

1 commit

  • commit a0d1c951ef08ed24f35129267e3595d86f57f5d3 upstream.

    As Documentation/kbuild/llvm.rst implies, building the kernel with a
    full set of LLVM tools gets very verbose and unwieldy.

    Provide a single switch LLVM=1 to use Clang and LLVM tools instead
    of GCC and Binutils. You can pass it from the command line or as an
    environment variable.

    Please note LLVM=1 does not turn on the integrated assembler. You need
    to pass LLVM_IAS=1 to use it. When the upstream kernel is ready for the
    integrated assembler, I think we can make it default.

    We discussed what we need, and we agreed to go with a simple boolean
    flag that switches both target and host tools:

    https://lkml.org/lkml/2020/3/28/494
    https://lkml.org/lkml/2020/4/3/43

    Some items discussed, but not adopted:

    - LLVM_DIR

    When multiple versions of LLVM are installed, I just thought supporting
    LLVM_DIR=/path/to/my/llvm/bin/ might be useful.

    CC = $(LLVM_DIR)clang
    LD = $(LLVM_DIR)ld.lld
    ...

    However, we can handle this by modifying PATH. So, we decided to not do
    this.

    - LLVM_SUFFIX

    Some distributions (e.g. Debian) package specific versions of LLVM with
    naming conventions that use the version as a suffix.

    CC = clang$(LLVM_SUFFIX)
    LD = ld.lld(LLVM_SUFFIX)
    ...

    will allow a user to pass LLVM_SUFFIX=-11 to use clang-11 etc.,
    but the suffixed versions in /usr/bin/ are symlinks to binaries in
    /usr/lib/llvm-#/bin/, so this can also be handled by PATH.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Nathan Chancellor
    Tested-by: Nathan Chancellor # build
    Tested-by: Nick Desaulniers
    Reviewed-by: Nick Desaulniers
    Signed-off-by: Nick Desaulniers
    Signed-off-by: Greg Kroah-Hartman

    Masahiro Yamada
     

22 Jun, 2020

1 commit

  • [ Upstream commit 7170cf47d16f1ba29eca07fd818870b7af0a93a5 ]

    The .alternatives section can contain entries with no original
    instructions. Objtool will currently crash when handling such an entry.

    Just skip that entry, but still give a warning to discourage useless
    entries.

    Signed-off-by: Julien Thierry
    Acked-by: Peter Zijlstra (Intel)
    Reviewed-by: Miroslav Benes
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin

    Julien Thierry
     

14 May, 2020

1 commit

  • commit d8dd25a461e4eec7190cb9d66616aceacc5110ad upstream.

    When the current frame address (CFA) is stored on the stack (i.e.,
    cfa->base == CFI_SP_INDIRECT), objtool neglects to adjust the stack
    offset when there are subsequent pushes or pops. This results in bad
    ORC data at the end of the ENTER_IRQ_STACK macro, when it puts the
    previous stack pointer on the stack and does a subsequent push.

    This fixes the following unwinder warning:

    WARNING: can't dereference registers at 00000000f0a6bdba for ip interrupt_entry+0x9f/0xa0

    Fixes: 627fce14809b ("objtool: Add ORC unwind table generation")
    Reported-by: Vince Weaver
    Reported-by: Dave Jones
    Reported-by: Steven Rostedt
    Reported-by: Vegard Nossum
    Reported-by: Joe Mario
    Reviewed-by: Miroslav Benes
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Ingo Molnar
    Cc: Andy Lutomirski
    Cc: Jann Horn
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: https://lore.kernel.org/r/853d5d691b29e250333332f09b8e27410b2d9924.1587808742.git.jpoimboe@redhat.com
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     

02 May, 2020

2 commits

  • [ Upstream commit 8782e7cab51b6bf01a5a86471dd82228af1ac185 ]

    Historically, the relocation symbols for ORC entries have only been
    section symbols:

    .text+0: sp:sp+8 bp:(und) type:call end:0

    However, the Clang assembler is aggressive about stripping section
    symbols. In that case we will need to use function symbols:

    freezing_slow_path+0: sp:sp+8 bp:(und) type:call end:0

    In preparation for the generation of such entries in "objtool orc
    generate", add support for reading them in "objtool orc dump".

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Borislav Petkov
    Reviewed-by: Miroslav Benes
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/b811b5eb1a42602c3b523576dc5efab9ad1c174d.1585761021.git.jpoimboe@redhat.com
    Signed-off-by: Sasha Levin

    Josh Poimboeuf
     
  • [ Upstream commit bd841d6154f5f41f8a32d3c1b0bc229e326e640a ]

    CONFIG_UBSAN_TRAP causes GCC to emit a UD2 whenever it encounters an
    unreachable code path. This includes __builtin_unreachable(). Because
    the BUG() macro uses __builtin_unreachable() after it emits its own UD2,
    this results in a double UD2. In this case objtool rightfully detects
    that the second UD2 is unreachable:

    init/main.o: warning: objtool: repair_env_string()+0x1c8: unreachable instruction

    We weren't able to figure out a way to get rid of the double UD2s, so
    just silence the warning.

    Reported-by: Randy Dunlap
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Borislav Petkov
    Reviewed-by: Kees Cook
    Reviewed-by: Miroslav Benes
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/6653ad73c6b59c049211bd7c11ed3809c20ee9f5.1585761021.git.jpoimboe@redhat.com
    Signed-off-by: Sasha Levin

    Josh Poimboeuf
     

23 Apr, 2020

1 commit

  • commit b401efc120a399dfda1f4d2858a4de365c9b08ef upstream.

    If a switch jump table's indirect branch is in a ".cold" subfunction in
    .text.unlikely, objtool doesn't detect it, and instead prints a false
    warning:

    drivers/media/v4l2-core/v4l2-ioctl.o: warning: objtool: v4l_print_format.cold()+0xd6: sibling call from callable instruction with modified stack frame
    drivers/hwmon/max6650.o: warning: objtool: max6650_probe.cold()+0xa5: sibling call from callable instruction with modified stack frame
    drivers/media/dvb-frontends/drxk_hard.o: warning: objtool: init_drxk.cold()+0x16f: sibling call from callable instruction with modified stack frame

    Fix it by comparing the function, instead of the section and offset.

    Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions")
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Borislav Petkov
    Reviewed-by: Miroslav Benes
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/157c35d42ca9b6354bbb1604fe9ad7d1153ccb21.1585761021.git.jpoimboe@redhat.com
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     

24 Feb, 2020

1 commit

  • [ Upstream commit 8580bed7e751e6d4f17881e059daf3cb37ba4717 ]

    Building objtool with ARCH=x86_64 fails with:

    $make ARCH=x86_64 -C tools/objtool
    ...
    CC arch/x86/decode.o
    arch/x86/decode.c:10:22: fatal error: asm/insn.h: No such file or directory
    #include
    ^
    compilation terminated.
    mv: cannot stat ‘arch/x86/.decode.o.tmp’: No such file or directory
    make[2]: *** [arch/x86/decode.o] Error 1
    ...

    The root cause is that the command-line variable 'ARCH' cannot be
    overridden. It can be replaced by 'SRCARCH', which is defined in
    'tools/scripts/Makefile.arch'.

    Signed-off-by: Shile Zhang
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Ingo Molnar
    Reviewed-by: Kamalesh Babulal
    Link: https://lore.kernel.org/r/d5d11370ae116df6c653493acd300ec3d7f5e925.1579543924.git.jpoimboe@redhat.com
    Signed-off-by: Sasha Levin

    Shile Zhang
     

11 Feb, 2020

1 commit

  • commit 6ec14aa7a58a1c2fb303692f8cb1ff82d9abd10a upstream.

    The sync-check.sh script prints out the path due to a "cd -" at the end
    of the script, even on silent builds. This isn't even needed, since the
    script is executed in our build instead of sourced (so it won't change
    the working directory of the surrounding build anyway).

    Just remove the cd to make the build silent.

    Fixes: 2ffd84ae973b ("objtool: Update sync-check.sh from perf's check-headers.sh")
    Signed-off-by: Olof Johansson
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Ingo Molnar
    Link: https://lore.kernel.org/r/cb002857fafa8186cfb9c3e43fb62e4108a1bab9.1579543924.git.jpoimboe@redhat.com
    Signed-off-by: Greg Kroah-Hartman

    Olof Johansson
     

31 Dec, 2019

1 commit

  • [ Upstream commit 9a50dcaf0416a43e1fe411dc61a99c8333c90119 ]

    The new check_zeroed_user() function uses variable shifts inside of a
    user_access_begin()/user_access_end() section and that results in GCC
    emitting __ubsan_handle_shift_out_of_bounds() calls, even though
    through value range analysis it would be able to see that the UB in
    question is impossible.

    Annotate and whitelist this UBSAN function; continued use of
    user_access_begin()/user_access_end() will undoubtedly result in
    further uses of function.

    Reported-by: Randy Dunlap
    Tested-by: Randy Dunlap
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Randy Dunlap
    Acked-by: Christian Brauner
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Stephen Rothwell
    Cc: Thomas Gleixner
    Cc: cyphar@cyphar.com
    Cc: keescook@chromium.org
    Cc: linux@rasmusvillemoes.dk
    Fixes: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper")
    Link: https://lkml.kernel.org/r/20191021131149.GA19358@hirez.programming.kicks-ass.net
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin

    Peter Zijlstra
     

25 Sep, 2019

1 commit

  • Explicitly check kvm_rebooting in kvm_spurious_fault() prior to invoking
    BUG(), as opposed to assuming the caller has already done so. Letting
    kvm_spurious_fault() be called "directly" will allow VMX to better
    optimize its low level assembly flows.

    As a happy side effect, kvm_spurious_fault() no longer needs to be
    marked as a dead end since it doesn't unconditionally BUG().

    Acked-by: Paolo Bonzini
    Cc: Josh Poimboeuf
    Signed-off-by: Sean Christopherson
    Signed-off-by: Paolo Bonzini

    Sean Christopherson
     

17 Sep, 2019

1 commit

  • Pull perf updates from Ingo Molnar:
    "Kernel side changes:

    - Improved kbprobes robustness

    - Intel PEBS support for PT hardware tracing

    - Other Intel PT improvements: high order pages memory footprint
    reduction and various related cleanups

    - Misc cleanups

    The perf tooling side has been very busy in this cycle, with over 300
    commits. This is an incomplete high-level summary of the many
    improvements done by over 30 developers:

    - Lots of updates to the following tools:

    'perf c2c'
    'perf config'
    'perf record'
    'perf report'
    'perf script'
    'perf test'
    'perf top'
    'perf trace'

    - Updates to libperf and libtraceevent, and a consolidation of the
    proliferation of x86 instruction decoder libraries.

    - Vendor event updates for Intel and PowerPC CPUs,

    - Updates to hardware tracing tooling for ARM and Intel CPUs,

    - ... and lots of other changes and cleanups - see the shortlog and
    Git log for details"

    * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (322 commits)
    kprobes: Prohibit probing on BUG() and WARN() address
    perf/x86: Make more stuff static
    x86, perf: Fix the dependency of the x86 insn decoder selftest
    objtool: Ignore intentional differences for the x86 insn decoder
    objtool: Update sync-check.sh from perf's check-headers.sh
    perf build: Ignore intentional differences for the x86 insn decoder
    perf intel-pt: Use shared x86 insn decoder
    perf intel-pt: Remove inat.c from build dependency list
    perf: Update .gitignore file
    objtool: Move x86 insn decoder to a common location
    perf metricgroup: Support multiple events for metricgroup
    perf metricgroup: Scale the metric result
    perf pmu: Change convert_scale from static to global
    perf symbols: Move mem_info and branch_info out of symbol.h
    perf auxtrace: Uninline functions that touch perf_session
    perf tools: Remove needless evlist.h include directives
    perf tools: Remove needless evlist.h include directives
    perf tools: Remove needless thread_map.h include directives
    perf tools: Remove needless thread.h include directives
    perf tools: Remove needless map.h include directives
    ...

    Linus Torvalds
     

10 Sep, 2019

1 commit

  • If the build user has the CFLAGS variable set in their environment,
    objtool blindly appends to it, which can cause unexpected behavior.

    Clobber CFLAGS to ensure consistent objtool compilation behavior.

    Reported-by: Valdis Kletnieks
    Tested-by: Valdis Kletnieks
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: https://lkml.kernel.org/r/83a276df209962e6058fcb6c615eef9d401c21bc.1567121311.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

01 Sep, 2019

3 commits

  • Since we need to build this in !x86, we need to explicitely use the x86
    files, not things like asm/insn.h, so we intentionally differ from the
    master copy in the kernel sources, add -I diff directives to ignore just
    these differences when checking for drift.

    Acked-by: Josh Poimboeuf
    Link: http://lore.kernel.org/lkml/20190830193109.p7jagidsrahoa4pn@treble
    Acked-by: Masami Hiramatsu
    Cc: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/n/tip-j965m9b7xtdc83em3twfkh9o@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • To allow using the -I trick that will be needed for checking the x86
    insn decoder files.

    Without the specific -I lines we still get the same warnings as before:

    $ make -C tools/objtool/ clean ; make -C tools/objtool/
    make: Entering directory '/home/acme/git/perf/tools/objtool'
    CLEAN objtool
    find -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
    rm -f arch/x86/inat-tables.c fixdep

    LD objtool-in.o
    make[1]: Leaving directory '/home/acme/git/perf/tools/objtool'
    Warning: Kernel ABI header at 'tools/arch/x86/include/asm/inat.h' differs from latest version at 'arch/x86/include/asm/inat.h'
    diff -u tools/arch/x86/include/asm/inat.h arch/x86/include/asm/inat.h
    Warning: Kernel ABI header at 'tools/arch/x86/include/asm/insn.h' differs from latest version at 'arch/x86/include/asm/insn.h'
    diff -u tools/arch/x86/include/asm/insn.h arch/x86/include/asm/insn.h
    Warning: Kernel ABI header at 'tools/arch/x86/lib/inat.c' differs from latest version at 'arch/x86/lib/inat.c'
    diff -u tools/arch/x86/lib/inat.c arch/x86/lib/inat.c
    Warning: Kernel ABI header at 'tools/arch/x86/lib/insn.c' differs from latest version at 'arch/x86/lib/insn.c'
    diff -u tools/arch/x86/lib/insn.c arch/x86/lib/insn.c
    /home/acme/git/perf/tools/objtool
    LINK objtool
    make: Leaving directory '/home/acme/git/perf/tools/objtool'
    $

    The next patch will add the -I lines for those files.

    Acked-by: Josh Poimboeuf
    Link: http://lore.kernel.org/lkml/20190830193109.p7jagidsrahoa4pn@treble
    Acked-by: Masami Hiramatsu
    Cc: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/n/tip-vu3p38mnxlwd80rlsnjkqcf2@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • The kernel tree has three identical copies of the x86 instruction
    decoder. Two of them are in the tools subdir.

    The tools subdir is supposed to be completely standalone and separate
    from the kernel. So having at least one copy of the kernel decoder in
    the tools subdir is unavoidable. However, we don't need *two* of them.

    Move objtool's copy of the decoder to a shared location, so that perf
    will also be able to use it.

    Signed-off-by: Josh Poimboeuf
    Reviewed-by: Masami Hiramatsu
    Acked-by: Peter Zijlstra (Intel)
    Cc: Adrian Hunter
    Cc: Jiri Olsa
    Cc: x86@kernel.org
    Link: http://lore.kernel.org/lkml/55b486b88f6bcd0c9a2a04b34f964860c8390ca8.1567118001.git.jpoimboe@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Josh Poimboeuf
     

25 Jul, 2019

1 commit

  • A clang build reported an (obvious) double CLAC while a GCC build did not;
    it turns out that objtool only re-visits instructions if the first visit
    was with AC=0. If OTOH the first visit was with AC=1, it completely ignores
    any subsequent visit, even when it has AC=0.

    Fix this by using a visited mask instead of a boolean, and (explicitly)
    mark the AC state.

    $ ./objtool check -b --no-fp --retpoline --uaccess drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o
    drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: .altinstr_replacement+0x22: redundant UACCESS disable
    drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0xea: (alt)
    drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: .altinstr_replacement+0xffffffffffffffff: (branch)
    drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0xd9: (alt)
    drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0xb2: (branch)
    drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0x39: (branch)
    drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0x0:
    Reported-by: Thomas Gleixner
    Reported-by: Sedat Dilek
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nathan Chancellor
    Tested-by: Nick Desaulniers
    Tested-by: Sedat Dilek
    Link: https://github.com/ClangBuiltLinux/linux/issues/617
    Link: https://lkml.kernel.org/r/5359166aad2d53f3145cd442d83d0e5115e0cd17.1564007838.git.jpoimboe@redhat.com

    Peter Zijlstra
     

19 Jul, 2019

13 commits

  • A Clang-built kernel is showing the following warning:

    arch/x86/kernel/platform-quirks.o: warning: objtool: x86_early_init_platform_quirks()+0x84: unreachable instruction

    That corresponds to this code:

    7e: 0f 85 00 00 00 00 jne 84
    80: R_X86_64_PC32 __x86_indirect_thunk_r11-0x4
    84: c3 retq

    This is a conditional retpoline sibling call, which is now possible
    thanks to retpolines. Objtool hasn't seen that before. It's
    incorrectly interpreting the conditional jump as an unconditional
    dynamic jump.

    Reported-by: Nick Desaulniers
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/30d4c758b267ef487fb97e6ecb2f148ad007b554.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • This makes it easier to add new instruction types. Also it's hopefully
    more robust since the compiler should warn about out-of-range enums.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/0740e96af0d40e54cfd6a07bf09db0fbd10793cd.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • In one rare case, Clang generated the following code:

    5ca: 83 e0 21 and $0x21,%eax
    5cd: b9 04 00 00 00 mov $0x4,%ecx
    5d2: ff 24 c5 00 00 00 00 jmpq *0x0(,%rax,8)
    5d5: R_X86_64_32S .rodata+0x38

    which uses the corresponding jump table relocations:

    000000000038 000200000001 R_X86_64_64 0000000000000000 .text + 834
    000000000040 000200000001 R_X86_64_64 0000000000000000 .text + 5d9
    000000000048 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000050 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000058 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000060 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000068 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000070 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000078 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000080 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000088 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000090 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000098 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000a0 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000a8 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000b0 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000b8 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000c0 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000c8 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000d0 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000d8 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000e0 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000e8 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000f0 000200000001 R_X86_64_64 0000000000000000 .text + b96
    0000000000f8 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000100 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000108 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000110 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000118 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000120 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000128 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000130 000200000001 R_X86_64_64 0000000000000000 .text + b96
    000000000138 000200000001 R_X86_64_64 0000000000000000 .text + 82f
    000000000140 000200000001 R_X86_64_64 0000000000000000 .text + 828

    Since %eax was masked with 0x21, only the first two and the last two
    entries are possible.

    Objtool doesn't actually emulate all the code, so it isn't smart enough
    to know that all the middle entries aren't reachable. They point to the
    NOP padding area after the end of the function, so objtool seg faulted
    when it tried to dereference a NULL insn->func.

    After this fix, objtool still gives an "unreachable" error because it
    stops reading the jump table when it encounters the bad addresses:

    /home/jpoimboe/objtool-tests/adm1275.o: warning: objtool: adm1275_probe()+0x828: unreachable instruction

    While the above code is technically correct, it's very wasteful of
    memory -- it uses 34 jump table entries when only 4 are needed. It's
    also not possible for objtool to validate this type of switch table
    because the unused entries point outside the function and objtool has no
    way of determining if that's intentional. Hopefully the Clang folks can
    fix it.

    Reported-by: Arnd Bergmann
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/a9db88eec4f1ca089e040989846961748238b6d8.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • This fixes objtool for both a GCC issue and a Clang issue:

    1) GCC issue:

    kernel/bpf/core.o: warning: objtool: ___bpf_prog_run()+0x8d5: sibling call from callable instruction with modified stack frame

    With CONFIG_RETPOLINE=n, GCC is doing the following optimization in
    ___bpf_prog_run().

    Before:

    select_insn:
    jmp *jumptable(,%rax,8)
    ...
    ALU64_ADD_X:
    ...
    jmp select_insn
    ALU_ADD_X:
    ...
    jmp select_insn

    After:

    select_insn:
    jmp *jumptable(, %rax, 8)
    ...
    ALU64_ADD_X:
    ...
    jmp *jumptable(, %rax, 8)
    ALU_ADD_X:
    ...
    jmp *jumptable(, %rax, 8)

    This confuses objtool. It has never seen multiple indirect jump
    sites which use the same jump table.

    For GCC switch tables, the only way of detecting the size of a table
    is by continuing to scan for more tables. The size of the previous
    table can only be determined after another switch table is found, or
    when the scan reaches the end of the function.

    That logic was reused for C jump tables, and was based on the
    assumption that each jump table only has a single jump site. The
    above optimization breaks that assumption.

    2) Clang issue:

    drivers/usb/misc/sisusbvga/sisusb.o: warning: objtool: sisusb_write_mem_bulk()+0x588: can't find switch jump table

    With clang 9, code can be generated where a function contains two
    indirect jump instructions which use the same switch table.

    The fix is the same for both issues: split the jump table parsing into
    two passes.

    In the first pass, locate the heads of all switch tables for the
    function and mark their locations.

    In the second pass, parse the switch tables and add them.

    Fixes: e55a73251da3 ("bpf: Fix ORC unwinding in non-JIT BPF code")
    Reported-by: Randy Dunlap
    Reported-by: Arnd Bergmann
    Signed-off-by: Jann Horn
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/e995befaada9d4d8b2cf788ff3f566ba900d2b4d.1563413318.git.jpoimboe@redhat.com

    Co-developed-by: Josh Poimboeuf

    Jann Horn
     
  • Now that C jump tables are supported, call them "jump tables" instead of
    "switch tables". Also rename some other variables, add comments, and
    simplify the code flow a bit.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/cf951b0c0641628e0b9b81f7ceccd9bcabcb4bd8.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • Simplify the sibling call detection logic a bit.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/8357dbef9e7f5512e76bf83a76c81722fc09eb5e.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • Even calls to __noreturn functions need the frame pointer setup first.
    Such functions often dump the stack.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/aed62fbd60e239280218be623f751a433658e896.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • dead_end_function() can no longer return an error. Simplify its
    interface by making it return boolean.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/9e6679610768fb6e6c51dca23f7d4d0c03b0c910.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • All callable functions should have an ELF size.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/03d429c4fa87829c61c5dc0e89652f4d9efb62f1.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • - Add an alias check in validate_functions(). With this change, aliases
    no longer need uaccess_safe set.

    - Add an alias check in decode_instructions(). With this change, the
    "if (!insn->func)" check is no longer needed.

    - Don't create aliases for zero-length functions, as it can have
    unexpected results. The next patch will spit out a warning for
    zero-length functions anyway.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/26a99c31426540f19c9a58b9e10727c385a147bc.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • If 'insn->func' is NULL, objtool skips some important checks, including
    sibling call validation. So if some .fixup code does an invalid sibling
    call, objtool ignores it.

    Treat all code branches (including alts) as part of the original
    function by keeping track of the original func value from
    validate_functions().

    This improves the usefulness of some clang function fallthrough
    warnings, and exposes some additional kernel bugs in the process.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/505df630f33c9717e1ccde6e4b64c5303135c25f.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • After an objtool improvement, it's reporting that __memcpy_mcsafe() is
    calling mcsafe_handle_tail() with AC=1:

    arch/x86/lib/memcpy_64.o: warning: objtool: .fixup+0x13: call to mcsafe_handle_tail() with UACCESS enabled
    arch/x86/lib/memcpy_64.o: warning: objtool: __memcpy_mcsafe()+0x34: (alt)
    arch/x86/lib/memcpy_64.o: warning: objtool: __memcpy_mcsafe()+0xb: (branch)
    arch/x86/lib/memcpy_64.o: warning: objtool: __memcpy_mcsafe()+0x0:
    Signed-off-by: Thomas Gleixner
    Tested-by: Nick Desaulniers
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/035c38f7eac845281d3c3d36749144982e06e58c.1563413318.git.jpoimboe@redhat.com

    Josh Poimboeuf
     
  • Pick up the two pending objtool patches as the next round of objtool fixes
    depend on them.

    Thomas Gleixner
     

18 Jul, 2019

2 commits

  • The elftoolchain version of libelf has a function named elf_open().

    The function name isn't quite accurate anyway, since it also reads all
    the ELF data. Rename it to elf_read(), which is more accurate.

    [ jpoimboe: rename to elf_read(); write commit description ]

    Signed-off-by: Michael Forney
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Link: https://lkml.kernel.org/r/7ce2d1b35665edf19fd0eb6fbc0b17b81a48e62f.1562793604.git.jpoimboe@redhat.com

    Michael Forney
     
  • The libelf implementation might use a different struct name, and the
    Elf_Scn typedef is already used throughout the rest of objtool.

    Signed-off-by: Michael Forney
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Link: https://lkml.kernel.org/r/d270e1be2835fc2a10acf67535ff2ebd2145bf43.1562793448.git.jpoimboe@redhat.com

    Michael Forney
     

10 Jul, 2019

1 commit

  • Pull Documentation updates from Jonathan Corbet:
    "It's been a relatively busy cycle for docs:

    - A fair pile of RST conversions, many from Mauro. These create more
    than the usual number of simple but annoying merge conflicts with
    other trees, unfortunately. He has a lot more of these waiting on
    the wings that, I think, will go to you directly later on.

    - A new document on how to use merges and rebases in kernel repos,
    and one on Spectre vulnerabilities.

    - Various improvements to the build system, including automatic
    markup of function() references because some people, for reasons I
    will never understand, were of the opinion that
    :c:func:``function()`` is unattractive and not fun to type.

    - We now recommend using sphinx 1.7, but still support back to 1.4.

    - Lots of smaller improvements, warning fixes, typo fixes, etc"

    * tag 'docs-5.3' of git://git.lwn.net/linux: (129 commits)
    docs: automarkup.py: ignore exceptions when seeking for xrefs
    docs: Move binderfs to admin-guide
    Disable Sphinx SmartyPants in HTML output
    doc: RCU callback locks need only _bh, not necessarily _irq
    docs: format kernel-parameters -- as code
    Doc : doc-guide : Fix a typo
    platform: x86: get rid of a non-existent document
    Add the RCU docs to the core-api manual
    Documentation: RCU: Add TOC tree hooks
    Documentation: RCU: Rename txt files to rst
    Documentation: RCU: Convert RCU UP systems to reST
    Documentation: RCU: Convert RCU linked list to reST
    Documentation: RCU: Convert RCU basic concepts to reST
    docs: filesystems: Remove uneeded .rst extension on toctables
    scripts/sphinx-pre-install: fix out-of-tree build
    docs: zh_CN: submitting-drivers.rst: Remove a duplicated Documentation/
    Documentation: PGP: update for newer HW devices
    Documentation: Add section about CPU vulnerabilities for Spectre
    Documentation: platform: Delete x86-laptop-drivers.txt
    docs: Note that :c:func: should no longer be used
    ...

    Linus Torvalds
     

09 Jul, 2019

1 commit

  • Objtool doesn't know how to read C jump tables, so it has to whitelist
    functions which use them, causing missing ORC unwinder data for such
    functions, e.g. ___bpf_prog_run().

    C jump tables are very similar to GCC switch jump tables, which objtool
    already knows how to read. So adding support for C jump tables is easy.
    It just needs to be able to find the tables and distinguish them from
    other data.

    To allow the jump tables to be found, create an __annotate_jump_table
    macro which can be used to annotate them.

    The annotation is done by placing the jump table in an
    .rodata..c_jump_table section. The '.rodata' prefix ensures that the data
    will be placed in the rodata section by the vmlinux linker script. The
    double periods are part of an existing convention which distinguishes
    kernel sections from GCC sections.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Song Liu
    Cc: Kairui Song
    Cc: Steven Rostedt
    Cc: Borislav Petkov
    Cc: Alexei Starovoitov
    Cc: Daniel Borkmann
    Link: https://lkml.kernel.org/r/0ba2ca30442b16b97165992381ce643dc27b3d1a.1561685471.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

02 Jul, 2019

1 commit

  • Fix objtool build, because it adds _ctype dependency via isspace call patch.

    Signed-off-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: André Goddard Rosa
    Cc: Clark Williams
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Thomas Gleixner
    Fixes: 7bd330de43fd ("tools lib: Adopt skip_spaces() from the kernel sources")
    Link: http://lkml.kernel.org/r/20190702121240.GB12694@krava
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

15 Jun, 2019

1 commit


09 Jun, 2019

1 commit

  • Mostly due to x86 and acpi conversion, several documentation
    links are still pointing to the old file. Fix them.

    Signed-off-by: Mauro Carvalho Chehab
    Reviewed-by: Wolfram Sang
    Reviewed-by: Sven Van Asbroeck
    Reviewed-by: Bhupesh Sharma
    Acked-by: Mark Brown
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit

  • Based on 2 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not see http www gnu org licenses

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details [based]
    [from] [clk] [highbank] [c] you should have received a copy of the
    gnu general public license along with this program if not see http
    www gnu org licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 355 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Kate Stewart
    Reviewed-by: Jilayne Lovejoy
    Reviewed-by: Steve Winslow
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190519154041.837383322@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

20 May, 2019

1 commit