17 May, 2019

1 commit


15 May, 2019

1 commit

  • The directive specified in the documentation to add an exception
    for a single file in a Makefile was inverted.

    Signed-off-by: Raphael Gault
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/522362a1b934ee39d0af0abb231f68e160ecf1a8.1557874043.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Raphael Gault
     

14 May, 2019

2 commits

  • When a function falls through to the next function due to a compiler
    bug, objtool prints some obscure warnings. For example:

    drivers/regulator/core.o: warning: objtool: regulator_count_voltages()+0x95: return with modified stack frame
    drivers/regulator/core.o: warning: objtool: regulator_count_voltages()+0x0: stack state mismatch: cfa1=7+32 cfa2=7+8

    Instead it should be printing:

    drivers/regulator/core.o: warning: objtool: regulator_supply_is_couple() falls through to next function regulator_count_voltages()

    This used to work, but was broken by the following commit:

    13810435b9a7 ("objtool: Support GCC 8's cold subfunctions")

    The padding nops at the end of a function aren't actually part of the
    function, as defined by the symbol table. So the 'func' variable in
    validate_branch() is getting cleared to NULL when a padding nop is
    encountered, breaking the fallthrough detection.

    If the current instruction doesn't have a function associated with it,
    just consider it to be part of the previously detected function by not
    overwriting the previous value of 'func'.

    Reported-by: kbuild test robot
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc:
    Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions")
    Link: http://lkml.kernel.org/r/546d143820cd08a46624ae8440d093dd6c902cae.1557766718.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • The ignore flag is set on fake jumps in order to keep
    add_jump_destinations() from setting their jump_dest, since it already
    got set when the fake jump was created.

    But using the ignore flag is a bit of a hack. It's normally used to
    skip validation of an instruction, which doesn't really make sense for
    fake jumps.

    Also, after the next patch, using the ignore flag for fake jumps can
    trigger a false "why am I validating an ignored function?" warning.

    Instead just add an explicit check in add_jump_destinations() to skip
    fake jumps.

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

    Josh Poimboeuf
     

09 May, 2019

1 commit

  • Pull documentation updates from Jonathan Corbet:
    "A reasonably busy cycle for docs, including:

    - Lots of work on the Chinese and Italian translations

    - Some license-rules clarifications from Christoph

    - Various build-script fixes

    - A new document on memory models

    - RST conversion of the live-patching docs

    - The usual collection of typo fixes and corrections"

    * tag 'docs-5.2' of git://git.lwn.net/linux: (140 commits)
    docs/livepatch: Unify style of livepatch documentation in the ReST format
    docs: livepatch: convert docs to ReST and rename to *.rst
    scripts/documentation-file-ref-check: detect broken :doc:`foo`
    scripts/documentation-file-ref-check: don't parse Next/ dir
    LICENSES: Rename other to deprecated
    LICENSES: Clearly mark dual license only licenses
    docs: Don't reference the ZLib license in license-rules.rst
    docs/vm: Minor editorial changes in the THP and hugetlbfs
    docs/vm: add documentation of memory models
    doc:it_IT: translation alignment
    doc: fix typo in PGP guide
    dontdiff: update with Kconfig build artifacts
    docs/zh_CN: fix typos in 1.Intro.rst file
    docs/zh_CN: redirect CoC docs to Chinese version
    doc: mm: migration doesn't use FOLL_SPLIT anymore
    docs: doc-guide: remove the extension from .rst files
    doc: kselftest: Fix KBUILD_OUTPUT usage instructions
    docs: trace: fix some Sphinx warnings
    docs: speculation.txt: mark example blocks as such
    docs: ntb.txt: add blank lines to clean up some Sphinx warnings
    ...

    Linus Torvalds
     

08 May, 2019

1 commit

  • Convert livepatch documentation to ReST format. The changes
    are mostly trivial, as the documents are already on a good
    shape. Just a few markup changes are needed for Sphinx to
    properly parse the docs.

    The conversion is actually:
    - add blank lines and identation in order to identify paragraphs;
    - fix tables markups;
    - add some lists markups;
    - mark literal blocks;
    - The in-file TOC becomes a comment, in order to skip it from the
    output, as Sphinx already generates an index there.
    - adjust title markups.

    At its new index.rst, let's add a :orphan: while this is not linked to
    the main index.rst file, in order to avoid build warnings.

    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Petr Mladek
    Acked-by: Miroslav Benes
    Acked-by: Josh Poimboeuf
    Acked-by: Joe Lawrence
    Reviewed-by: Kamalesh Babulal
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

07 May, 2019

1 commit

  • Pull objtool updates from Ingo Molnar:
    "This is a series from Peter Zijlstra that adds x86 build-time uaccess
    validation of SMAP to objtool, which will detect and warn about the
    following uaccess API usage bugs and weirdnesses:

    - call to %s() with UACCESS enabled
    - return with UACCESS enabled
    - return with UACCESS disabled from a UACCESS-safe function
    - recursive UACCESS enable
    - redundant UACCESS disable
    - UACCESS-safe disables UACCESS

    As it turns out not leaking uaccess permissions outside the intended
    uaccess functionality is hard when the interfaces are complex and when
    such bugs are mostly dormant.

    As a bonus we now also check the DF flag. We had at least one
    high-profile bug in that area in the early days of Linux, and the
    checking is fairly simple. The checks performed and warnings emitted
    are:

    - call to %s() with DF set
    - return with DF set
    - return with modified stack frame
    - recursive STD
    - redundant CLD

    It's all x86-only for now, but later on this can also be used for PAN
    on ARM and objtool is fairly cross-platform in principle.

    While all warnings emitted by this new checking facility that got
    reported to us were fixed, there might be GCC version dependent
    warnings that were not reported yet - which we'll address, should they
    trigger.

    The warnings are non-fatal build warnings"

    * 'core-objtool-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (27 commits)
    mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions
    x86/uaccess: Dont leak the AC flag into __put_user() argument evaluation
    sched/x86_64: Don't save flags on context switch
    objtool: Add Direction Flag validation
    objtool: Add UACCESS validation
    objtool: Fix sibling call detection
    objtool: Rewrite alt->skip_orig
    objtool: Add --backtrace support
    objtool: Rewrite add_ignores()
    objtool: Handle function aliases
    objtool: Set insn->func for alternatives
    x86/uaccess, kcov: Disable stack protector
    x86/uaccess, ftrace: Fix ftrace_likely_update() vs. SMAP
    x86/uaccess, ubsan: Fix UBSAN vs. SMAP
    x86/uaccess, kasan: Fix KASAN vs SMAP
    x86/smap: Ditch __stringify()
    x86/uaccess: Introduce user_access_{save,restore}()
    x86/uaccess, signal: Fix AC=1 bloat
    x86/uaccess: Always inline user_access_begin()
    x86/uaccess, xen: Suppress SMAP warnings
    ...

    Linus Torvalds
     

05 Apr, 2019

1 commit

  • This fixes the following warning seen on GCC 7.3:

    arch/x86/kernel/dumpstack.o: warning: objtool: oops_end() falls through to next function show_regs()

    Reported-by: kbuild test robot
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Cc: Peter Zijlstra
    Link: https://lkml.kernel.org/r/3418ebf5a5a9f6ed7e80954c741c0b904b67b5dc.1554398240.git.jpoimboe@redhat.com

    Josh Poimboeuf
     

03 Apr, 2019

9 commits

  • Having DF escape is BAD(tm).

    Linus; you suggested this one, but since DF really is only used from
    ASM and the failure case is fairly obvious, do we really need this?

    OTOH the patch is fairly small and simple, so let's just do this
    to demonstrate objtool's superior awesomeness.

    Suggested-by: Linus Torvalds
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Josh Poimboeuf
    Cc: Borislav Petkov
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • It is important that UACCESS regions are as small as possible;
    furthermore the UACCESS state is not scheduled, so doing anything that
    might directly call into the scheduler will cause random code to be
    ran with UACCESS enabled.

    Teach objtool too track UACCESS state and warn about any CALL made
    while UACCESS is enabled. This very much includes the __fentry__()
    and __preempt_schedule() calls.

    Note that exceptions _do_ save/restore the UACCESS state, and therefore
    they can drive preemption. This also means that all exception handlers
    must have an otherwise redundant UACCESS disable instruction;
    therefore ignore this warning for !STT_FUNC code (exception handlers
    are not normal functions).

    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Josh Poimboeuf
    Cc: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • It turned out that we failed to detect some sibling calls;
    specifically those without relocation records; like:

    $ ./objdump-func.sh defconfig-build/mm/kasan/generic.o __asan_loadN
    0000 0000000000000840 :
    0000 840: 48 8b 0c 24 mov (%rsp),%rcx
    0004 844: 31 d2 xor %edx,%edx
    0006 846: e9 45 fe ff ff jmpq 690

    So extend the cross-function jump to also consider those that are not
    between known (or newly detected) parent/child functions, as
    sibling-cals when they jump to the start of the function.

    The second part of that condition is to deal with random jumps to the
    middle of other function, as can be found in
    arch/x86/lib/copy_user_64.S for example.

    This then (with later patches applied) makes the above recognise the
    sibling call:

    mm/kasan/generic.o: warning: objtool: __asan_loadN()+0x6: call to check_memory_region() with UACCESS enabled

    Also make sure to set insn->call_dest for sibling calls so we can know
    who we're calling. This is useful information when printing validation
    warnings later.

    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Josh Poimboeuf
    Cc: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Really skip the original instruction flow, instead of letting it
    continue with NOPs.

    Since the alternative code flow already continues after the original
    instructions, only the alt-original is skipped.

    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Josh Poimboeuf
    Cc: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • For when you want to know the path that reached your fail state:

    $ ./objtool check --no-fp --backtrace arch/x86/lib/usercopy_64.o
    arch/x86/lib/usercopy_64.o: warning: objtool: .altinstr_replacement+0x3: UACCESS disable without MEMOPs: __clear_user()
    arch/x86/lib/usercopy_64.o: warning: objtool: __clear_user()+0x3a: (alt)
    arch/x86/lib/usercopy_64.o: warning: objtool: __clear_user()+0x2e: (branch)
    arch/x86/lib/usercopy_64.o: warning: objtool: __clear_user()+0x18: (branch)
    arch/x86/lib/usercopy_64.o: warning: objtool: .altinstr_replacement+0xffffffffffffffff: (branch)
    arch/x86/lib/usercopy_64.o: warning: objtool: __clear_user()+0x5: (alt)
    arch/x86/lib/usercopy_64.o: warning: objtool: __clear_user()+0x0: :
    0: e8 00 00 00 00 callq 5
    1: R_X86_64_PLT32 __fentry__-0x4
    5: 90 nop
    6: 90 nop
    7: 90 nop
    8: 48 89 f0 mov %rsi,%rax
    b: 48 c1 ee 03 shr $0x3,%rsi
    f: 83 e0 07 and $0x7,%eax
    12: 48 89 f1 mov %rsi,%rcx
    15: 48 85 c9 test %rcx,%rcx
    18: 74 0f je 29
    1a: 48 c7 07 00 00 00 00 movq $0x0,(%rdi)
    21: 48 83 c7 08 add $0x8,%rdi
    25: ff c9 dec %ecx
    27: 75 f1 jne 1a
    29: 48 89 c1 mov %rax,%rcx
    2c: 85 c9 test %ecx,%ecx
    2e: 74 0a je 3a
    30: c6 07 00 movb $0x0,(%rdi)
    33: 48 ff c7 inc %rdi
    36: ff c9 dec %ecx
    38: 75 f6 jne 30
    3a: 90 nop
    3b: 90 nop
    3c: 90 nop
    3d: 48 89 c8 mov %rcx,%rax
    40: c3 retq

    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Josh Poimboeuf
    Cc: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • The whole add_ignores() thing was wildly weird; rewrite it according
    to 'modern' ways.

    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Josh Poimboeuf
    Cc: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Function aliases result in different symbols for the same set of
    instructions; track a canonical symbol so there is a unique point of
    access.

    This again prepares the way for function attributes. And in particular
    the need for aliases comes from how KASAN uses them.

    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Josh Poimboeuf
    Cc: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • In preparation of function attributes, we need each instruction to
    have a valid link back to its function.

    Therefore make sure we set the function association for alternative
    instruction sequences; they are, after all, still part of the function.

    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Josh Poimboeuf
    Cc: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • To facillitate other usage of ignoring alternatives; rename
    ANNOTATE_NOSPEC_IGNORE to ANNOTATE_IGNORE_ALTERNATIVE.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Borislav Petkov
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

28 Mar, 2019

1 commit

  • If it is not in the default location, compilation fails at several points.

    Signed-off-by: Rolf Eike Beer
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/91a25e992566a7968fedc89ec80e7f4c83ad0548.1553622500.git.jpoimboe@redhat.com

    Rolf Eike Beer
     

21 Mar, 2019

1 commit

  • Objtool uses over 512k of stack, thanks to the hash table embedded in
    the objtool_file struct. This causes an unnecessarily large stack
    allocation and breaks users with low stack limits.

    Move the struct off the stack.

    Fixes: 042ba73fe7eb ("objtool: Add several performance improvements")
    Reported-by: Vassili Karpov
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/df92dcbc4b84b02ffa252f46876df125fb56e2d7.1552954176.git.jpoimboe@redhat.com

    Josh Poimboeuf
     

21 Nov, 2018

2 commits

  • Because find_symbol_by_name() traverses the same lists as
    read_symbols(), changing sym->name in place without copying it affects
    the result of find_symbol_by_name(). In the case where a ".cold"
    function precedes its parent in sec->symbol_list, it can result in a
    function being considered a parent of itself. This leads to function
    length being set to 0 and other consequent side-effects including a
    segfault in add_switch_table(). The effects of this bug are only
    visible when building with -ffunction-sections in KCFLAGS.

    Fix by copying the search string instead of modifying it in place.

    Signed-off-by: Artem Savkov
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions")
    Link: http://lkml.kernel.org/r/910abd6b5a4945130fd44f787c24e07b9e07c8da.1542736240.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Artem Savkov
     
  • If read_symbols() fails during second list traversal (the one dealing
    with ".cold" subfunctions) it frees the symbol, but never deletes it
    from the list/hash_table resulting in symbol being freed again in
    elf_close(). Fix it by just returning an error, leaving cleanup to
    elf_close().

    Signed-off-by: Artem Savkov
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions")
    Link: http://lkml.kernel.org/r/beac5a9b7da9e8be90223459dcbe07766ae437dd.1542736240.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Artem Savkov
     

04 Nov, 2018

1 commit


01 Nov, 2018

1 commit

  • Starting with GCC 8, a lot of unlikely code was moved out of line to
    "cold" subfunctions in .text.unlikely.

    For example, the unlikely bits of:

    irq_do_set_affinity()

    are moved out to the following subfunction:

    irq_do_set_affinity.cold.49()

    Starting with GCC 9, the numbered suffix has been removed. So in the
    above example, the cold subfunction is instead:

    irq_do_set_affinity.cold()

    Tweak the objtool subfunction detection logic so that it detects both
    GCC 8 and GCC 9 naming schemes.

    Reported-by: Peter Zijlstra (Intel)
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Peter Zijlstra (Intel)
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/015e9544b1f188d36a7f02fa31e9e95629aa5f50.1541040800.git.jpoimboe@redhat.com

    Josh Poimboeuf
     

29 Oct, 2018

1 commit


27 Sep, 2018

1 commit

  • Similar to the arm64 case, 64-bit x86 can benefit from using relative
    references rather than absolute ones when emitting struct jump_entry
    instances. Not only does this reduce the memory footprint of the entries
    themselves by 33%, it also removes the need for carrying relocation
    metadata on relocatable builds (i.e., for KASLR) which saves a fair
    chunk of .init space as well (although the savings are not as dramatic
    as on arm64)

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra (Intel)
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-s390@vger.kernel.org
    Cc: Arnd Bergmann
    Cc: Heiko Carstens
    Cc: Kees Cook
    Cc: Will Deacon
    Cc: Catalin Marinas
    Cc: Steven Rostedt
    Cc: Martin Schwidefsky
    Cc: Jessica Yu
    Link: https://lkml.kernel.org/r/20180919065144.25010-7-ard.biesheuvel@linaro.org

    Ard Biesheuvel
     

08 Sep, 2018

1 commit

  • Add support for processing switch jump tables in objects with multiple
    .rodata sections, such as those created by '-ffunction-sections' and
    '-fdata-sections'. Currently, objtool always looks in .rodata for jump
    table information, which results in many "sibling call from callable
    instruction with modified stack frame" warnings with objects compiled
    using those flags.

    The fix is comprised of three parts:

    1. Flagging all .rodata sections when importing ELF information for
    easier checking later.

    2. Keeping a reference to the section each relocation is from in order
    to get the list_head for the other relocations in that section.

    3. Finding jump tables by following relocations to .rodata sections,
    rather than always referencing a single global .rodata section.

    The patch has been tested without data sections enabled and no
    differences in the resulting orc unwind information were seen.

    Note that as objtool adds terminators to end of each .text section the
    unwind information generated between a function+data sections build and
    a normal build aren't directly comparable. Manual inspection suggests
    that objtool is now generating the correct information, or at least
    making more of an effort to do so than it did previously.

    Signed-off-by: Allan Xavier
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Link: https://lkml.kernel.org/r/099bdc375195c490dda04db777ee0b95d566ded1.1536325914.git.jpoimboe@redhat.com

    Allan Xavier
     

16 Aug, 2018

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - verify depmod is installed before modules_install

    - support build salt in case build ids must be unique between builds

    - allow users to specify additional host compiler flags via HOST*FLAGS,
    and rename internal variables to KBUILD_HOST*FLAGS

    - update buildtar script to drop vax support, add arm64 support

    - update builddeb script for better debarch support

    - document the pit-fall of if_changed usage

    - fix parallel build of UML with O= option

    - make 'samples' target depend on headers_install to fix build errors

    - remove deprecated host-progs variable

    - add a new coccinelle script for refcount_t vs atomic_t check

    - improve double-test coccinelle script

    - misc cleanups and fixes

    * tag 'kbuild-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (41 commits)
    coccicheck: return proper error code on fail
    Coccinelle: doubletest: reduce side effect false positives
    kbuild: remove deprecated host-progs variable
    kbuild: make samples really depend on headers_install
    um: clean up archheaders recipe
    kbuild: add %asm-generic to no-dot-config-targets
    um: fix parallel building with O= option
    scripts: Add Python 3 support to tracing/draw_functrace.py
    builddeb: Add automatic support for sh{3,4}{,eb} architectures
    builddeb: Add automatic support for riscv* architectures
    builddeb: Add automatic support for m68k architecture
    builddeb: Add automatic support for or1k architecture
    builddeb: Add automatic support for sparc64 architecture
    builddeb: Add automatic support for mips{,64}r6{,el} architectures
    builddeb: Add automatic support for mips64el architecture
    builddeb: Add automatic support for ppc64 and powerpcspe architectures
    builddeb: Introduce functions to simplify kconfig tests in set_debarch
    builddeb: Drop check for 32-bit s390
    builddeb: Change architecture detection fallback to use dpkg-architecture
    builddeb: Skip architecture detection when KBUILD_DEBARCH is set
    ...

    Linus Torvalds
     

14 Aug, 2018

1 commit

  • Pull x86 asm updates from Thomas Gleixner:
    "The lowlevel and ASM code updates for x86:

    - Make stack trace unwinding more reliable

    - ASM instruction updates for better code generation

    - Various cleanups"

    * 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86/entry/64: Add two more instruction suffixes
    x86/asm/64: Use 32-bit XOR to zero registers
    x86/build/vdso: Simplify 'cmd_vdso2c'
    x86/build/vdso: Remove unused vdso-syms.lds
    x86/stacktrace: Enable HAVE_RELIABLE_STACKTRACE for the ORC unwinder
    x86/unwind/orc: Detect the end of the stack
    x86/stacktrace: Do not fail for ORC with regs on stack
    x86/stacktrace: Clarify the reliable success paths
    x86/stacktrace: Remove STACKTRACE_DUMP_ONCE
    x86/stacktrace: Do not unwind after user regs
    x86/asm: Use CC_SET/CC_OUT in percpu_cmpxchg8b_double() to micro-optimize code generation

    Linus Torvalds
     

18 Jul, 2018

2 commits


14 Jul, 2018

1 commit

  • Clang puts its section header names in the '.strtab' section instead of
    '.shstrtab', which causes objtool to fail with a "can't find
    .shstrtab section" warning when attempting to write ORC metadata to an
    object file.

    If '.shstrtab' doesn't exist, use '.strtab' instead.

    Signed-off-by: Simon Ser
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/d1c1c3fe55872be433da7bc5e1860538506229ba.1531153015.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Simon Ser
     

02 Jul, 2018

1 commit

  • Since the following commit:

    cd77849a69cf ("objtool: Fix GCC 8 cold subfunction detection for aliased functions")

    ... if the kernel is built with EXTRA_CFLAGS='-fno-reorder-functions',
    objtool can get stuck in an infinite loop.

    That flag causes the new GCC 8 cold subfunctions to be placed in .text
    instead of .text.unlikely. But it also has an unfortunate quirk: in the
    symbol table, the subfunction (e.g., nmi_panic.cold.7) is nested inside
    the parent (nmi_panic).

    That function overlap confuses objtool, and causes it to get into an
    infinite loop in next_insn_same_func(). Here's Allan's description of
    the loop:

    "Objtool iterates through the instructions in nmi_panic using
    next_insn_same_func. Once it reaches the end of nmi_panic at 0x534 it
    jumps to 0x528 as that's the start of nmi_panic.cold.7. However, since
    the instructions starting at 0x528 are still associated with nmi_panic
    objtool will get stuck in a loop, continually jumping back to 0x528
    after reaching 0x534."

    Fix it by shortening the length of the parent function so that the
    functions no longer overlap.

    Reported-and-analyzed-by: Allan Xavier
    Signed-off-by: Josh Poimboeuf
    Cc: Allan Xavier
    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/9e704c52bee651129b036be14feda317ae5606ae.1530136978.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

21 Jun, 2018

1 commit

  • The existing UNWIND_HINT_EMPTY annotations happen to be good indicators
    of where entry code calls into C code for the first time. So also use
    them to mark the end of the stack for the ORC unwinder.

    Use that information to set unwind->error if the ORC unwinder doesn't
    unwind all the way to the end. This will be needed for enabling
    HAVE_RELIABLE_STACKTRACE for the ORC unwinder so we can use it with the
    livepatch consistency model.

    Thanks to Jiri Slaby for teaching the ORCs about the unwind hints.

    Signed-off-by: Josh Poimboeuf
    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: https://lkml.kernel.org/lkml/20180518064713.26440-5-jslaby@suse.cz
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

20 Jun, 2018

1 commit

  • machine_real_restart() is annotated as '__noreturn", so add it to the
    objtool noreturn list. This fixes the following warning with clang and
    CONFIG_CC_OPTIMIZE_FOR_SIZE=y:

    arch/x86/kernel/reboot.o: warning: objtool: native_machine_emergency_restart() falls through to next function machine_power_off()

    Reported-by: Matthias Kaehlcke
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Tested-by: Matthias Kaehlcke
    Reviewed-by: Matthias Kaehlcke
    Link: https://lkml.kernel.org/r/791712792aa4431bdd55bf1beb33a169ddf3b4a2.1529423255.git.jpoimboe@redhat.com

    Josh Poimboeuf
     

06 Jun, 2018

1 commit

  • The kbuild test robot reported the following issue:

    kernel/time/posix-stubs.o: warning: objtool: sys_ni_posix_timers.cold.1()+0x0: unreachable instruction

    This file creates symbol aliases for the sys_ni_posix_timers() function.
    So there are multiple ELF function symbols for the same function:

    23: 0000000000000150 26 FUNC GLOBAL DEFAULT 1 __x64_sys_timer_create
    24: 0000000000000150 26 FUNC GLOBAL DEFAULT 1 sys_ni_posix_timers
    25: 0000000000000150 26 FUNC GLOBAL DEFAULT 1 __ia32_sys_timer_create
    26: 0000000000000150 26 FUNC GLOBAL DEFAULT 1 __x64_sys_timer_gettime

    Here's the corresponding cold subfunction:

    11: 0000000000000000 45 FUNC LOCAL DEFAULT 6 sys_ni_posix_timers.cold.1

    When analyzing overlapping functions, objtool only looks at the first
    one in the symbol list. The rest of the functions are basically ignored
    because they point to instructions which have already been analyzed.

    So in this case it analyzes the __x64_sys_timer_create() function, but
    then it fails to recognize that its cold subfunction is
    sys_ni_posix_timers.cold.1(), because the names are different.

    Make the subfunction detection a little smarter by associating each
    subfunction with the first function which jumps to it, since that's the
    one which will be analyzed.

    Unfortunately we still have to leave the original subfunction detection
    code in place, thanks to GCC switch tables. (See the comment for more
    details.)

    Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions")
    Reported-by: kbuild test robot
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Thomas Gleixner
    Cc: Peter Zijlstra
    Link: https://lkml.kernel.org/r/d3ba52662cbc8e3a64a3b64d44b4efc5674fd9ab.1527855808.git.jpoimboe@redhat.com

    Josh Poimboeuf
     

19 May, 2018

1 commit

  • With the following commit:

    fd35c88b7417 ("objtool: Support GCC 8 switch tables")

    I added a "can't find switch jump table" warning, to stop covering up
    silent failures if add_switch_table() can't find anything.

    That warning found yet another bug in the objtool switch table detection
    logic. For cases 1 and 2 (as described in the comments of
    find_switch_table()), the find_symbol_containing() check doesn't adjust
    the offset for RIP-relative switch jumps.

    Incidentally, this bug was already fixed for case 3 with:

    6f5ec2993b1f ("objtool: Detect RIP-relative switch table references")

    However, that commit missed the fix for cases 1 and 2.

    The different cases are now starting to look more and more alike. So
    fix the bug by consolidating them into a single case, by checking the
    original dynamic jump instruction in the case 3 loop.

    This also simplifies the code and makes it more robust against future
    switch table detection issues -- of which I'm sure there will be many...

    Switch table detection has been the most fragile area of objtool, by
    far. I long for the day when we'll have a GCC plugin for annotating
    switch tables. Linus asked me to delay such a plugin due to the
    flakiness of the plugin infrastructure in older versions of GCC, so this
    rickety code is what we're stuck with for now. At least the code is now
    a little simpler than it was.

    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/f400541613d45689086329432f3095119ffbc328.1526674218.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

15 May, 2018

1 commit

  • Typically a switch table can be found by detecting a .rodata access
    followed an indirect jump:

    1969: 4a 8b 0c e5 00 00 00 mov 0x0(,%r12,8),%rcx
    1970: 00
    196d: R_X86_64_32S .rodata+0x438
    1971: e9 00 00 00 00 jmpq 1976
    1972: R_X86_64_PC32 __x86_indirect_thunk_rcx-0x4

    Randy Dunlap reported a case (seen with GCC 4.8) where the .rodata
    access uses RIP-relative addressing:

    19bd: 48 8b 3d 00 00 00 00 mov 0x0(%rip),%rdi # 19c4
    19c0: R_X86_64_PC32 .rodata+0x45c
    19c4: e9 00 00 00 00 jmpq 19c9
    19c5: R_X86_64_PC32 __x86_indirect_thunk_rdi-0x4

    In this case the relocation addend needs to be adjusted accordingly in
    order to find the location of the switch table.

    The fix is for case 3 (as described in the comments), but also make the
    existing case 1 & 2 checks more precise by only adjusting the addend for
    R_X86_64_PC32 relocations.

    This fixes the following warnings:

    drivers/video/fbdev/omap2/omapfb/dss/dispc.o: warning: objtool: dispc_runtime_suspend()+0xbb8: sibling call from callable instruction with modified stack frame
    drivers/video/fbdev/omap2/omapfb/dss/dispc.o: warning: objtool: dispc_runtime_resume()+0xcc5: sibling call from callable instruction with modified stack frame

    Reported-by: Randy Dunlap
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/b6098294fd67afb69af8c47c9883d7a68bf0f8ea.1526305958.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

14 May, 2018

3 commits

  • With GCC 8, some issues were found with the objtool switch table
    detection.

    1) In the .rodata section, immediately after the switch table, there can
    be another object which contains a pointer to the function which had
    the switch statement. In this case objtool wrongly considers the
    function pointer to be part of the switch table. Fix it by:

    a) making sure there are no pointers to the beginning of the
    function; and

    b) making sure there are no gaps in the switch table.

    Only the former was needed, the latter adds additional protection for
    future optimizations.

    2) In find_switch_table(), case 1 and case 2 are missing the check to
    ensure that the .rodata switch table data is anonymous, i.e. that it
    isn't already associated with an ELF symbol. Fix it by adding the
    same find_symbol_containing() check which is used for case 3.

    This fixes the following warnings with GCC 8:

    drivers/block/virtio_blk.o: warning: objtool: virtio_queue_rq()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+72
    net/ipv6/icmp.o: warning: objtool: icmpv6_rcv()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+64
    drivers/usb/core/quirks.o: warning: objtool: quirks_param_set()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+48
    drivers/mtd/nand/raw/nand_hynix.o: warning: objtool: hynix_nand_decode_id()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+24
    drivers/mtd/nand/raw/nand_samsung.o: warning: objtool: samsung_nand_decode_id()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+32
    drivers/gpu/drm/nouveau/nvkm/subdev/top/gk104.o: warning: objtool: gk104_top_oneinit()+0x0: stack state mismatch: cfa1=7+8 cfa2=7+64

    Reported-by: Arnd Bergmann
    Reported-by: kbuild test robot
    Signed-off-by: Josh Poimboeuf
    Acked-by: Peter Zijlstra (Intel)
    Cc: David Laight
    Cc: Greg KH
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Randy Dunlap
    Cc: Thomas Gleixner
    Cc: damian
    Link: http://lkml.kernel.org/r/20180510224849.xwi34d6tzheb5wgw@treble
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • GCC 8 moves a lot of unlikely code out of line to "cold" subfunctions in
    .text.unlikely. Properly detect the new subfunctions and treat them as
    extensions of the original functions.

    This fixes a bunch of warnings like:

    kernel/cgroup/cgroup.o: warning: objtool: parse_cgroup_root_flags()+0x33: sibling call from callable instruction with modified stack frame
    kernel/cgroup/cgroup.o: warning: objtool: cgroup_addrm_files()+0x290: sibling call from callable instruction with modified stack frame
    kernel/cgroup/cgroup.o: warning: objtool: cgroup_apply_control_enable()+0x25b: sibling call from callable instruction with modified stack frame
    kernel/cgroup/cgroup.o: warning: objtool: rebind_subsystems()+0x325: sibling call from callable instruction with modified stack frame

    Reported-and-tested-by: damian
    Reported-by: Arnd Bergmann
    Signed-off-by: Josh Poimboeuf
    Acked-by: Peter Zijlstra (Intel)
    Cc: David Laight
    Cc: Greg KH
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Randy Dunlap
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/0965e7fcfc5f31a276f0c7f298ff770c19b68706.1525923412.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • Objtool has some crude logic for detecting static "noreturn" functions
    (aka "dead ends"). This is necessary for being able to correctly follow
    GCC code flow when such functions are called.

    It's remotely possible for two functions to call each other via sibling
    calls. If they don't have RET instructions, objtool's noreturn
    detection logic goes into a recursive loop:

    drivers/char/ipmi/ipmi_ssif.o: warning: objtool: return_hosed_msg()+0x0: infinite recursion (objtool bug!)
    drivers/char/ipmi/ipmi_ssif.o: warning: objtool: deliver_recv_msg()+0x0: infinite recursion (objtool bug!)

    Instead of reporting an error in this case, consider the functions to be
    non-dead-ends.

    Reported-and-tested-by: Randy Dunlap
    Signed-off-by: Josh Poimboeuf
    Acked-by: Peter Zijlstra (Intel)
    Cc: Arnd Bergmann
    Cc: David Laight
    Cc: Greg KH
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: damian
    Link: http://lkml.kernel.org/r/7cc156408c5781a1f62085d352ced1fe39fe2f91.1525923412.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf