06 Dec, 2016

1 commit

  • For the "lea %(rsp), %rbp" case, we check if there is a rex_prefix.
    But we check 'bytes' which is insn_byte_t[4] in rex_prefix (insn_field
    structure). Therefore, the check is always true.

    Instead, check 'nbytes' which is the right one.

    Signed-off-by: Jiri Slaby
    Acked-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20161205105551.25917-1-jslaby@suse.cz
    Signed-off-by: Ingo Molnar

    Jiri Slaby
     

27 Oct, 2016

1 commit

  • The following commit:

    3732710ff6f2 ("objtool: Improve rare switch jump table pattern detection")

    ... improved objtool's ability to detect GCC switch statement jump
    tables for GCC 6. However the check to allow short jumps with the
    scanned range of instructions wasn't quite right. The pattern detection
    should allow jumps to the indirect jump instruction itself.

    This fixes the following warning:

    drivers/infiniband/sw/rxe/rxe_comp.o: warning: objtool: rxe_completer()+0x315: sibling call from callable instruction with changed frame pointer

    Reported-by: Arnd Bergmann
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: 3732710ff6f2 ("objtool: Improve rare switch jump table pattern detection")
    Link: http://lkml.kernel.org/r/20161026153408.2rifnw7bvoc5sex7@treble
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

16 Oct, 2016

2 commits

  • Recently objtool has started reporting a few "unreachable instruction"
    warnings when CONFIG_GCOV is enabled for newer versions of GCC. Usually
    this warning means there's some new control flow that objtool doesn't
    understand. But in this case, objtool is correct and the instructions
    really are inaccessible. It's an annoying quirk of gcov, but it's
    harmless, so it's ok to just silence the warnings.

    With older versions of GCC, it was relatively easy to detect
    gcov-specific instructions and to skip any unreachable warnings produced
    by them. But GCC 6 has gotten craftier.

    Instead of continuing to play whack-a-mole with gcov, just use a bigger,
    more permanent hammer and disable unreachable warnings for the whole
    file when gcov is enabled. This is fine to do because a) unreachable
    warnings are usually of questionable value; and b) gcov isn't used for
    production kernels and we can relax the checks a bit there.

    Reported-by: kbuild test robot
    Signed-off-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Arnd Bergmann
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/38d5c87d61d9cd46486dd2c86f46603dff0df86f.1476393584.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • GCC 6 added a new switch statement jump table optimization which makes
    objtool's life harder. It looks like:

    mov [rodata addr],%reg1
    ... some instructions ...
    jmpq *(%reg1,%reg2,8)

    The optimization is quite rare, but objtool still needs to be able to
    identify the pattern so that it can follow all possible control flow
    paths related to the switch statement.

    In order to detect the pattern, objtool starts from the indirect jump
    and scans backwards through the function until it finds the first
    instruction in the pattern. If it encounters an unconditional jump
    along the way, it stops and considers the pattern to be not found.

    As it turns out, unconditional jumps can happen, as long as they are
    small forward jumps within the range being scanned.

    This fixes the following warnings:

    drivers/infiniband/sw/rxe/rxe_comp.o: warning: objtool: rxe_completer()+0x2f4: sibling call from callable instruction with changed frame pointer
    drivers/infiniband/sw/rxe/rxe_resp.o: warning: objtool: rxe_responder()+0x10f: sibling call from callable instruction with changed frame pointer

    Reported-by: Arnd Bergmann
    Signed-off-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/8a9ed68ae1780e8d3963e4ee13f2f257fe3a3c33.1476393584.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

11 Oct, 2016

1 commit

  • Arnd reported that enabling CONFIG_MATOM results in a bunch of objtool
    false positive frame pointer warnings:

    arch/x86/events/intel/ds.o: warning: objtool: intel_pmu_pebs_del()+0x43: call without frame pointer save/setup
    security/keys/keyring.o: warning: objtool: keyring_read()+0x59: call without frame pointer save/setup
    kernel/signal.o: warning: objtool: __dequeue_signal()+0xd8: call without frame pointer save/setup
    ...

    objtool gets confused by the fact that the '-mtune=atom' GCC option
    sometimes uses 'lea (%rsp),%rbp' instead of 'mov %rsp,%rbp'. The
    instructions are effectively the same, but objtool doesn't know about
    the 'lea' variant.

    Fix the false warnings by adding support for 'lea (%rsp),%rbp' in the
    objtool decoder.

    Reported-by: Arnd Bergmann
    Signed-off-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

23 Sep, 2016

1 commit

  • objtool reports the following new warning:

    kernel/exit.o: warning: objtool: do_exit() falls through to next function complete_and_exit()

    The warning is caused by do_exit()'s new call to do_task_dead(), which
    is a new "noreturn" function which objtool doesn't know about yet,
    introduced by:

    9af6528ee9b6 ("sched/core: Optimize __schedule()")

    ( objtool has to know all the global noreturn functions so it can follow
    the control flow of any functions which call them. Unfortunately they
    need to be hard-coded because there's no automated way to detect them. )

    Reported-by: kbuild test robot
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: kbuild-all@01.org
    Cc: tipbuild@zytor.com
    Link: http://lkml.kernel.org/r/20160922212125.zbuewckqll4yur25@treble
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

31 Jul, 2016

1 commit

  • Pull misc fixes from Thomas Gleixner:
    "This update contains:

    - a fix for stomp-machine so the nmi_watchdog wont trigger on the cpu
    waiting for the others to execute the callback

    - various fixes and updates to objtool including an resync of the
    instruction decoder to match the kernel's decoder"

    * 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    objtool: Un-capitalize "Warning" for out-of-sync instruction decoder
    objtool: Resync x86 instruction decoder with the kernel's
    objtool: Support new GCC 6 switch jump table pattern
    stop_machine: Touch_nmi_watchdog() after MULTI_STOP_PREPARE
    objtool: Add 'fixdep' to objtool/.gitignore

    Linus Torvalds
     

29 Jul, 2016

4 commits

  • Change "Warning" to "warning" to make it look more like a GCC warning.
    Hopefully that will be enough to help the 0-day bot or other automated
    tools catch this warning earlier before it ends up in Linus's tree.

    Reported-by: Linus Torvalds
    Signed-off-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/b1669f391a5db91040427fd9f8e1e79db18f9709.1469751119.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • This fixes the following warning:

    Warning: objtool: x86 instruction decoder differs from kernel

    Unfortunately we have three identical copies of the x86 instruction
    decoder in the kernel tree that have to be manually kept in sync.

    It's on my TODO list to at least library-ize the ones in the tools
    subdir so we'd only have two of them instead of three. In the meantime,
    here's another manual sync.

    Reported-by: Linus Torvalds
    Signed-off-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: c61f4d5ebaf0 ("perf tools: Add AVX-512 support to the instruction decoder used by Intel PT")
    Link: http://lkml.kernel.org/r/d7f74b4d91fed25b0be33cd5c86f5131fa1a7529.1469751119.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • This fixes some false positive objtool warnings seen with gcc 6.1.1:

    kernel/trace/ring_buffer.o: warning: objtool: ring_buffer_read_page()+0x36c: sibling call from callable instruction with changed frame pointer
    arch/x86/kernel/reboot.o: warning: objtool: native_machine_emergency_restart()+0x139: sibling call from callable instruction with changed frame pointer
    lib/xz/xz_dec_stream.o: warning: objtool: xz_dec_run()+0xc2: sibling call from callable instruction with changed frame pointer

    With GCC 6, a new code pattern is sometimes used to access a switch
    statement jump table in .rodata, which objtool doesn't yet recognize:

    mov [rodata addr],%reg1
    ... some instructions ...
    jmpq *(%reg1,%reg2,8)

    Add support for detecting that pattern. The detection code is rather
    crude, but it's still effective at weeding out false positives and
    catching real warnings. It can be refined later once objtool starts
    reading DWARF CFI.

    Reported-by: Linus Torvalds
    Signed-off-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/b8c9503b4ad8c8a827cc5400db4c1b40a3ea07bc.1469751119.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • Pull libnvdimm updates from Dan Williams:

    - Replace pcommit with ADR / directed-flushing.

    The pcommit instruction, which has not shipped on any product, is
    deprecated. Instead, the requirement is that platforms implement
    either ADR, or provide one or more flush addresses per nvdimm.

    ADR (Asynchronous DRAM Refresh) flushes data in posted write buffers
    to the memory controller on a power-fail event.

    Flush addresses are defined in ACPI 6.x as an NVDIMM Firmware
    Interface Table (NFIT) sub-structure: "Flush Hint Address Structure".
    A flush hint is an mmio address that when written and fenced assures
    that all previous posted writes targeting a given dimm have been
    flushed to media.

    - On-demand ARS (address range scrub).

    Linux uses the results of the ACPI ARS commands to track bad blocks
    in pmem devices. When latent errors are detected we re-scrub the
    media to refresh the bad block list, userspace can also request a
    re-scrub at any time.

    - Support for the Microsoft DSM (device specific method) command
    format.

    - Support for EDK2/OVMF virtual disk device memory ranges.

    - Various fixes and cleanups across the subsystem.

    * tag 'libnvdimm-for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: (41 commits)
    libnvdimm-btt: Delete an unnecessary check before the function call "__nd_device_register"
    nfit: do an ARS scrub on hitting a latent media error
    nfit: move to nfit/ sub-directory
    nfit, libnvdimm: allow an ARS scrub to be triggered on demand
    libnvdimm: register nvdimm_bus devices with an nd_bus driver
    pmem: clarify a debug print in pmem_clear_poison
    x86/insn: remove pcommit
    Revert "KVM: x86: add pcommit support"
    nfit, tools/testing/nvdimm/: unify shutdown paths
    libnvdimm: move ->module to struct nvdimm_bus_descriptor
    nfit: cleanup acpi_nfit_init calling convention
    nfit: fix _FIT evaluation memory leak + use after free
    tools/testing/nvdimm: add manufacturing_{date|location} dimm properties
    tools/testing/nvdimm: add virtual ramdisk range
    acpi, nfit: treat virtual ramdisk SPA as pmem region
    pmem: kill __pmem address space
    pmem: kill wmb_pmem()
    libnvdimm, pmem: use nvdimm_flush() for namespace I/O writes
    fs/dax: remove wmb_pmem()
    libnvdimm, pmem: flush posted-write queues on shutdown
    ...

    Linus Torvalds
     

27 Jul, 2016

2 commits

  • To fix:

    Untracked files:
    (use "git add ..." to include in what will be committed)

    tools/objtool/fixdep

    Signed-off-by: Paul Gortmaker
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/a4571f6893caf737d05524cfa3829c2abc1fb240.1469452729.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Paul Gortmaker
     
  • Pull perf fixes from Ingo Molnar:
    "This tree contains tooling fixes plus some additions:

    - fixes to the vdso2c build environment that Stephen Rothwell is
    using for the linux-next build (Arnaldo Carvalho de Melo)

    - AVX-512 instruction mappings (Adrian Hunter)

    - misc fixes"

    * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    Revert "perf tools: event.h needs asm/perf_regs.h"
    x86: Make the vdso2c compiler use the host architecture headers
    tools build: Fix objtool build with ARCH=x86_64
    objtool: Always use host headers
    objtool: Use tools/scripts/Makefile.arch to get ARCH and HOSTARCH
    tools build: Add HOSTARCH Makefile variable
    perf tests kmod-path: Fix build on ubuntu:16.04-x-armhf
    perf tools: Add AVX-512 instructions to the new instructions test
    perf tools: Add AVX-512 support to the instruction decoder used by Intel PT
    x86/insn: Add AVX-512 support to the instruction decoder
    x86/insn: perf tools: Fix vcvtph2ps instruction decoding

    Linus Torvalds
     

26 Jul, 2016

1 commit

  • Pull perf updates from Ingo Molnar:
    "With over 300 commits it's been a busy cycle - with most of the work
    concentrated on the tooling side (as it should).

    The main kernel side enhancements were:

    - Add per event callchain limit: Recently we introduced a sysctl to
    tune the max-stack for all events for which callchains were
    requested:

    $ sysctl kernel.perf_event_max_stack
    kernel.perf_event_max_stack = 127

    Now this patch introduces a way to configure this per event, i.e.
    this becomes possible:

    $ perf record -e sched:*/max-stack=2/ -e block:*/max-stack=10/ -a

    allowing finer tuning of how much buffer space callchains use.

    This uses an u16 from the reserved space at the end, leaving
    another u16 for future use.

    There has been interest in even finer tuning, namely to control the
    max stack for kernel and userspace callchains separately. Further
    discussion is needed, we may for instance use the remaining u16 for
    that and when it is present, assume that the sample_max_stack
    introduced in this patch applies for the kernel, and the u16 left
    is used for limiting the userspace callchain (Arnaldo Carvalho de
    Melo)

    - Optimize AUX event (hardware assisted side-band event) delivery
    (Kan Liang)

    - Rework Intel family name macro usage (this is partially x86 arch
    work) (Dave Hansen)

    - Refine and fix Intel LBR support (David Carrillo-Cisneros)

    - Add support for Intel 'TopDown' events (Andi Kleen)

    - Intel uncore PMU driver fixes and enhancements (Kan Liang)

    - ... other misc changes.

    Here's an incomplete list of the tooling enhancements (but there's
    much more, see the shortlog and the git log for details):

    - Support cross unwinding, i.e. collecting '--call-graph dwarf'
    perf.data files in one machine and then doing analysis in another
    machine of a different hardware architecture. This enables, for
    instance, to do:

    $ perf record -a --call-graph dwarf

    on a x86-32 or aarch64 system and then do 'perf report' on it on a
    x86_64 workstation (He Kuang)

    - Allow reading from a backward ring buffer (one setup via
    sys_perf_event_open() with perf_event_attr.write_backward = 1)
    (Wang Nan)

    - Finish merging initial SDT (Statically Defined Traces) support, see
    cset comments for details about how it all works (Masami Hiramatsu)

    - Support attaching eBPF programs to tracepoints (Wang Nan)

    - Add demangling of symbols in programs written in the Rust language
    (David Tolnay)

    - Add support for tracepoints in the python binding, including an
    example, that sets up and parses sched:sched_switch events,
    tools/perf/python/tracepoint.py (Jiri Olsa)

    - Introduce --stdio-color to set up the color output mode selection
    in 'annotate' and 'report', allowing emit color escape sequences
    when redirecting the output of these tools (Arnaldo Carvalho de
    Melo)

    - Add 'callindent' option to 'perf script -F', to indent the Intel PT
    call stack, making this output more ftrace-like (Adrian Hunter,
    Andi Kleen)

    - Allow dumping the object files generated by llvm when processing
    eBPF scriptlet events (Wang Nan)

    - Add stackcollapse.py script to help generating flame graphs (Paolo
    Bonzini)

    - Add --ldlat option to 'perf mem' to specify load latency for loads
    event (e.g. cpu/mem-loads/ ) (Jiri Olsa)

    - Tooling support for Intel TopDown counters, recently added to the
    kernel (Andi Kleen)"

    * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (303 commits)
    perf tests: Add is_printable_array test
    perf tools: Make is_printable_array global
    perf script python: Fix string vs byte array resolving
    perf probe: Warn unmatched function filter correctly
    perf cpu_map: Add more helpers
    perf stat: Balance opening and reading events
    tools: Copy linux/{hash,poison}.h and check for drift
    perf tools: Remove include/linux/list.h from perf's MANIFEST
    tools: Copy the bitops files accessed from the kernel and check for drift
    Remove: kernel unistd*h files from perf's MANIFEST, not used
    perf tools: Remove tools/perf/util/include/linux/const.h
    perf tools: Remove tools/perf/util/include/asm/byteorder.h
    perf tools: Add missing linux/compiler.h include to perf-sys.h
    perf jit: Remove some no-op error handling
    perf jit: Add missing curly braces
    objtool: Initialize variable to silence old compiler
    objtool: Add -I$(srctree)/tools/arch/$(ARCH)/include/uapi
    perf record: Add --tail-synthesize option
    perf session: Don't warn about out of order event if write_backward is used
    perf tools: Enable overwrite settings
    ...

    Linus Torvalds
     

24 Jul, 2016

1 commit

  • The pcommit instruction is being deprecated in favor of either ADR
    (asynchronous DRAM refresh: flush-on-power-fail) at the platform level, or
    posted-write-queue flush addresses as defined by the ACPI 6.x NFIT (NVDIMM
    Firmware Interface Table).

    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: x86@kernel.org
    Cc: Josh Poimboeuf
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: Borislav Petkov
    Cc: Andy Lutomirski
    Cc: Xiao Guangrong
    Cc: Adrian Hunter
    Cc: Ross Zwisler
    Acked-by: Ingo Molnar
    Signed-off-by: Dan Williams

    Dan Williams
     

23 Jul, 2016

3 commits

  • The objtool build fails in a cross-compiled environment on a non-x86
    host with "ARCH=x86_64":

    tools/objtool/objtool-in.o: In function `decode_instructions':
    tools/objtool/builtin-check.c:276: undefined reference to `arch_decode_instruction'

    We could override the ARCH environment variable and change it back to
    x86, similar to what the objtool Makefile was doing before; but it's
    tricky to override environment variables consistently.

    Instead, take a similar approach used by the Linux top-level Makefile
    and introduce a SRCARCH Makefile variable which evaluates to "x86" when
    ARCH is either "x86_64" or "x86".

    Reported-by: Stephen Rothwell
    Signed-off-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: H. Peter Anvin
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20160722191920.ej62fnspnqurbaa7@treble
    Signed-off-by: Arnaldo Carvalho de Melo

    Josh Poimboeuf
     
  • From a conversation with Josh:

    From http://lkml.kernel.org/r/20160722034118.guckaniobf3f7czc@treble :

    It needs to be compiled with the host (powerpc) compiler, but then it
    needs to disassemble target (x86) files.

    ----

    So use HOSTARCH instead of ARCH.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Josh Poimboeuf
    Cc: Namhyung Kim
    Cc: Stephen Rothwell
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/20160722034118.guckaniobf3f7czc@treble
    Link: http://lkml.kernel.org/n/tip-le1m1yzxnfpt3msbblu40nm8@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • objtool's Makefile was setting up ARCH but fixing up just the x86_64 ->
    x86, using Makefile.arch will do the necessary fixups for all arches.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Josh Poimboeuf
    Cc: Namhyung Kim
    Cc: Stephen Rothwell
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-hbq0bbh03u2b722vozcyql31@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

16 Jul, 2016

2 commits

  • gcc version 4.1.2 20080704 (Red Hat 4.1.2-55) barfs with:

    CC /tmp/build/objtool/builtin-check.o
    cc1: warnings being treated as errors
    builtin-check.c: In function 'cmd_check':
    builtin-check.c:667: warning: 'prev_rela' may be used uninitialized in this function
    mv: cannot stat `/tmp/build/objtool/.builtin-check.o.tmp': No such file or directory
    make[1]: *** [/tmp/build/objtool/builtin-check.o] Error 1

    Init it to NULL to silence it.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Josh Poimboeuf
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-qolo31rl2ojlwj1lj9dhemyz@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • So that it can find asm/bitsperlong.h to get the __BITS_PER_LONG
    definition.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Josh Poimboeuf
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-pr3pvskh65pey4po7t122z4j@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

14 Jul, 2016

2 commits


13 Jul, 2016

2 commits

  • To make it portable to non-glibc systems, that follow the XSI variant
    instead of the GNU specific one that gets in place when _GNU_SOURCE is
    defined.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Josh Poimboeuf
    Cc: Namhyung Kim
    Cc: Steven Rostedt
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-bozcszy93tpgw9ad6qm3dhpx@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • They were in tools/include/linux/kernel.h, requiring that it in turn
    included stdio.h, which is way too heavy.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Josh Poimboeuf
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-855h8olnkot9v0dajuee1lo3@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

10 Jul, 2016

1 commit

  • Mathieu Desnoyers reported that the STACK_FRAME_NON_STANDARD macro
    wasn't working with the lttng_filter_interpret_bytecode() function in
    the lttng-modules code.

    Usually the relocation created by STACK_FRAME_NON_STANDARD creates a
    reference to a section symbol like this:

    Offset Type Value Addend Name
    000000000000000000 X86_64_64 000000000000000000 +3136 .text

    But in this case it created a reference to a function symbol:

    Offset Type Value Addend Name
    000000000000000000 X86_64_64 0x00000000000003a0 +0 lttng_filter_interpret_bytecode

    To be honest I have no idea what causes gcc to decide to do one over the
    other. But both are valid ELF, so add support for the function symbol.

    Reported-by: Mathieu Desnoyers
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: lttng-dev@lists.lttng.org
    Link: http://lkml.kernel.org/r/9cee42843bc6d94e990a152e4e0319cfdf6756ef.1466023450.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

17 May, 2016

1 commit

  • The switch to elf_getshdr{num,strndx} post-dates the oldest tool chain
    the kernel is supposed to be able to build with, so try to cope with
    such an environment.

    Signed-off-by: Jan Beulich
    Signed-off-by: Josh Poimboeuf
    Cc: # for v4.6
    Cc: Alexander Shishkin
    Cc: Arnaldo Carvalho de Melo
    Cc: Jan Beulich
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Link: http://lkml.kernel.org/r/732dae6872b7ff187d94f22bb699a12849d3fe04.1463430618.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Jan Beulich
     

16 Apr, 2016

1 commit

  • There are several cases in compiled C code where a function may not
    return at the end, and may instead fall through to the next function.

    That may indicate a bug in the code, or a gcc bug, or even an objtool
    bug. But in each case, objtool reports an unhelpful warning, something
    like:

    drivers/scsi/qla2xxx/qla_attr.o: warning: objtool: qla2x00_get_fc_host_stats()+0x0: duplicate frame pointer save
    drivers/scsi/qla2xxx/qla_attr.o: warning: objtool: qla2x00_get_fc_host_stats()+0x0: frame pointer state mismatch

    Detect this situation and print a more useful error message:

    drivers/scsi/qla2xxx/qla_attr.o: warning: objtool: qla2x00_get_host_fabric_name() falls through to next function qla2x00_get_starget_node_name()

    Also add some information about this warning and its potential causes to
    the documentation.

    Reported-by: kbuild test robot
    Signed-off-by: Josh Poimboeuf
    Cc: Alexander Shishkin
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/caa4ec6c687931db805e692d4e4bf06cd87d33e6.1460729697.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

15 Apr, 2016

1 commit

  • GCC has a rare quirk, currently only seen in three driver functions in
    the kernel, and only with certain obscure non-distro configs, which can
    cause objtool to produce "unreachable instruction" false positive
    warnings.

    As part of an optimization, GCC makes a copy of an existing switch jump
    table, modifies it, and then hard-codes the jump (albeit with an
    indirect jump) to use a single entry in the table. The rest of the jump
    table and some of its jump targets remain as dead code.

    In such a case we can just crudely ignore all unreachable instruction
    warnings for the entire object file. Ideally we would just ignore them
    for the function, but that would require redesigning the code quite a
    bit. And honestly that's just not worth doing: unreachable instruction
    warnings are of questionable value anyway, and this is a very rare
    issue.

    kbuild reports:

    https://lkml.kernel.org/r/201603231906.LWcVUpxm%25fengguang.wu@intel.com
    https://lkml.kernel.org/r/201603271114.K9i45biy%25fengguang.wu@intel.com
    https://lkml.kernel.org/r/201603291058.zuJ6ben1%25fengguang.wu@intel.com

    GCC bug:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70604

    Reported-by: kbuild test robot
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/700fa029bbb0feff34f03ffc69d666a3c3b57a61.1460663532.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

09 Mar, 2016

10 commits

  • When objtool discovers an issue, it's very common for it to flood the
    terminal with a lot of duplicate warnings. For example:

    warning: objtool: rtlwifi_rate_mapping()+0x2e7: frame pointer state mismatch
    warning: objtool: rtlwifi_rate_mapping()+0x2f3: frame pointer state mismatch
    warning: objtool: rtlwifi_rate_mapping()+0x2ff: frame pointer state mismatch
    warning: objtool: rtlwifi_rate_mapping()+0x30b: frame pointer state mismatch
    ...

    The first warning is usually all you need. Change it to only warn once
    per function.

    Suggested-by: Ingo Molnar
    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/c47f3ca38aa01e2a9b6601f9e38efd414c3f3c18.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • Use hash tables for instruction and rela lookups (and keep the linked
    lists around for sequential access).

    Also cache the section struct for the "__func_stack_frame_non_standard"
    section.

    With this change, "objtool check net/wireless/nl80211.o" goes from:

    real 0m1.168s
    user 0m1.163s
    sys 0m0.005s

    to:

    real 0m0.059s
    user 0m0.042s
    sys 0m0.017s

    for a 20x speedup.

    With the same object, it should be noted that the memory heap usage grew
    from 8MB to 62MB. Reducing the memory usage is on the TODO list.

    Reported-by: Ingo Molnar
    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/dd0d8e1449506cfa7701b4e7ba73577077c44253.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • Ingo reported [1] some false positive objtool warnings:

    drivers/net/wireless/realtek/rtlwifi/base.o: warning: objtool: rtlwifi_rate_mapping()+0x2e7: frame pointer state mismatch
    drivers/net/wireless/realtek/rtlwifi/base.o: warning: objtool: rtlwifi_rate_mapping()+0x2f3: frame pointer state mismatch
    ...

    And so did the 0-day bot [2]:

    drivers/gpu/drm/radeon/cik.o: warning: objtool: cik_tiling_mode_table_init()+0x6ce: call without frame pointer save/setup
    drivers/gpu/drm/radeon/cik.o: warning: objtool: cik_tiling_mode_table_init()+0x72b: call without frame pointer save/setup
    ...

    Both sets of warnings involve functions which have multiple switch
    statements. When there's more than one switch statement in a function,
    objtool interprets all the switch jump tables as a single table. If the
    targets of one jump table assume a stack frame and the targets of
    another one don't, it prints false positive warnings.

    Fix the bug by detecting the size of each switch jump table. For
    multiple tables, each one ends where the next one begins.

    [1] https://lkml.kernel.org/r/20160308103716.GA9618@gmail.com
    [2] https://lists.01.org/pipermail/kbuild-all/2016-March/018124.html

    Reported-by: Ingo Molnar
    Reported-by: kbuild test robot
    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/2d7eecc6bc52d301f494b80f5fd62c2b6c895658.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • Rename some list heads to distinguish them from hash node heads, which
    are added later in the patch series.

    Also rename the get_*() functions to add_*(), which is more descriptive:
    they "add" data to the objtool_file struct.

    Also rename rodata_rela and text_rela to be clearer:
    - text_rela refers to a rela entry in .rela.text.
    - rodata_rela refers to a rela entry in .rela.rodata.

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/ee0eca2bba8482aa45758958c5586c00a7b71e62.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • The insns list is initialized twice, in cmd_check() and in
    decode_instructions(). Remove the latter.

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/be6e21d7eec1f072095d22a1cbe144057135e097.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • Add some helper macros to make it easier to traverse instructions, and
    to abstract the details of the instruction list implementation in
    preparation for creating a hash structure.

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/8e1715d5035bc02b4db28d0fccef6bb1170d1f12.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • With some configs [1], objtool prints a bunch of false positive warnings
    like:

    arch/x86/events/core.o: warning: objtool: x86_del_exclusive()+0x0: frame pointer state mismatch

    For some reason this config has a bunch of sibling calls. When objtool
    follows a sibling call jump, it attempts to compare the frame pointer
    state. But it also accidentally compares the FENTRY state, resulting in
    a false positive warning.

    [1] https://lkml.kernel.org/r/20160308154909.GA20956@gmail.com

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/382de77ccaaa8cd79b27a155c3d109ebd4ce0219.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • Compile objtool with debugging symbols ('-g') to help tools like perf
    and gdb understand what it's doing. Combined with '-O2', it's not
    always helpful, but it's better than nothing.

    Reported-by: Ingo Molnar
    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/c295e9ee9ed360dc8b2e1d180c859f11cfc151ef.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • I don't _think_ dead_end_function() can get into a recursive loop, but
    just in case, stop the loop and print a warning.

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/ff489a63e6feb88abb192cfb361d81626dcf3e89.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • Ingo reported an infinite loop in objtool with a certain randconfig [1].
    With the given config, two functions in crypto/ablkcipher.o contained
    sibling calls to each other, which threw the recursive call in
    dead_end_function() for a loop (literally!).

    Split the noreturn detection into two passes. In the first pass, check
    for return instructions. In the second pass, do the potentially
    recursive sibling call check. In most cases, the first pass will be
    good enough. In the rare case where a second pass is needed, recursion
    should hopefully no longer be possible.

    [1] https://lkml.kernel.org/r/20160308154909.GA20956@gmail.com

    Reported-by: Ingo Molnar
    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/16afb602640ef43b7782087d6cca17bf6fc13603.1457502970.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

03 Mar, 2016

2 commits

  • When building with CONFIG_STACK_VALIDATION on a ppc64le host with an x86
    cross-compiler, Stephen Rothwell saw the following objtool build errors:

    DESCEND objtool
    CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/builtin-check.o
    CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/special.o
    CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/elf.o
    CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/objtool.o
    MKDIR /home/sfr/next/x86_64_allmodconfig/tools/objtool/arch/x86/insn/
    CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/libstring.o
    elf.c:22:23: fatal error: sys/types.h: No such file or directory
    compilation terminated.
    CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/exec-cmd.o
    CC /home/sfr/next/x86_64_allmodconfig/tools/objtool/help.o
    builtin-check.c:28:20: fatal error: string.h: No such file or directory
    compilation terminated.
    objtool.c:28:19: fatal error: stdio.h: No such file or directory
    compilation terminated.

    It fails to build because it tries to compile objtool with the
    cross-compiler instead of the host compiler.

    Ensure that it always uses the host compiler by ignoring CROSS_COMPILE.

    In order to do that properly, the libsubcmd.a library needs to be built
    in tools/objtool/ rather than tools/lib/subcmd/. The latter directory
    contains the cross-compiled version which is needed for perf and
    possibly other tools.

    Note that cross-compiling for x86 on a _big_ endian system would result
    in a bunch of false positive objtool warnings during the kernel build
    because it isn't endian-aware. But that's generally a rare edge case
    and there haven't been any reports of anybody needing that.

    Reported-by: Stephen Rothwell
    Signed-off-by: Josh Poimboeuf
    Cc: Adrian Hunter
    Cc: Linus Torvalds
    Cc: Masami Hiramatsu
    Cc: Michael Ellerman
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/55b63eefc347f1bb28573f972d8d1adbf1f1c31d.1456962210.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • When running objtool on a ppc64le host to analyze x86 binaries, it
    reports a lot of false warnings like:

    ipc/compat_mq.o: warning: objtool: compat_SyS_mq_open()+0x91: can't find jump dest instruction at .text+0x3a5

    The warnings are caused by the x86 instruction decoder setting the wrong
    value for the jump instruction's immediate field because it assumes that
    "char == signed char", which isn't true for all architectures. When
    converting char to int, gcc sign-extends on x86 but doesn't sign-extend
    on ppc64le.

    According to the gcc man page, that's a feature, not a bug:

    > Each kind of machine has a default for what "char" should be. It is
    > either like "unsigned char" by default or like "signed char" by
    > default.
    >
    > Ideally, a portable program should always use "signed char" or
    > "unsigned char" when it depends on the signedness of an object.

    Conform to the "standards" by changing the "char" casts to "signed
    char". This results in no actual changes to the object code on x86.

    Note: the x86 decoder now lives in three different locations in the
    kernel tree, which are all kept in sync via makefile checks and
    warnings: in-kernel, perf, and objtool. This fixes all three locations.
    Eventually we should probably try to at least converge the two separate
    "tools" locations into a single shared location.

    Signed-off-by: Josh Poimboeuf
    Cc: Adrian Hunter
    Cc: Linus Torvalds
    Cc: Masami Hiramatsu
    Cc: Michael Ellerman
    Cc: Peter Zijlstra
    Cc: Stephen Rothwell
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/9dd4161719b20e6def9564646d68bfbe498c549f.1456962210.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf