1. 25 9月, 2019 1 次提交
  2. 25 7月, 2019 1 次提交
  3. 19 7月, 2019 12 次提交
  4. 18 7月, 2019 1 次提交
  5. 09 7月, 2019 1 次提交
    • J
      objtool: Add support for C jump tables · 87b512de
      Josh Poimboeuf 提交于
      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: NJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Kairui Song <kasong@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Link: https://lkml.kernel.org/r/0ba2ca30442b16b97165992381ce643dc27b3d1a.1561685471.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      87b512de
  6. 21 5月, 2019 1 次提交
    • T
      treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 · 1ccea77e
      Thomas Gleixner 提交于
      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: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NJilayne Lovejoy <opensource@jilayne.com>
      Reviewed-by: NSteve Winslow <swinslow@gmail.com>
      Reviewed-by: NAllison Randal <allison@lohutok.net>
      Cc: linux-spdx@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190519154041.837383322@linutronix.deSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1ccea77e
  7. 14 5月, 2019 2 次提交
    • J
      objtool: Fix function fallthrough detection · e6f393bc
      Josh Poimboeuf 提交于
      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:
      
        13810435 ("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: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: <stable@vger.kernel.org>
      Fixes: 13810435 ("objtool: Support GCC 8's cold subfunctions")
      Link: http://lkml.kernel.org/r/546d143820cd08a46624ae8440d093dd6c902cae.1557766718.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e6f393bc
    • J
      objtool: Don't use ignore flag for fake jumps · e6da9567
      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: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/71abc072ff48b2feccc197723a9c52859476c068.1557766718.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e6da9567
  8. 05 4月, 2019 1 次提交
  9. 03 4月, 2019 8 次提交
    • P
      objtool: Add Direction Flag validation · 2f0f9e9a
      Peter Zijlstra 提交于
      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: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      2f0f9e9a
    • P
      objtool: Add UACCESS validation · ea24213d
      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: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      ea24213d
    • P
      objtool: Fix sibling call detection · 54262aa2
      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 <__asan_loadN>:
        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 <check_memory_region>
      
      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: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      54262aa2
    • P
      objtool: Rewrite alt->skip_orig · 764eef4b
      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: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      764eef4b
    • P
      objtool: Add --backtrace support · 7697eee3
      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: <=== (func)
      
        0000000000000000 <__clear_user>:
          0:   e8 00 00 00 00          callq  5 <__clear_user+0x5>
                       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 <__clear_user+0x29>
         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 <__clear_user+0x1a>
         29:   48 89 c1                mov    %rax,%rcx
         2c:   85 c9                   test   %ecx,%ecx
         2e:   74 0a                   je     3a <__clear_user+0x3a>
         30:   c6 07 00                movb   $0x0,(%rdi)
         33:   48 ff c7                inc    %rdi
         36:   ff c9                   dec    %ecx
         38:   75 f6                   jne    30 <__clear_user+0x30>
         3a:   90                      nop
         3b:   90                      nop
         3c:   90                      nop
         3d:   48 89 c8                mov    %rcx,%rax
         40:   c3                      retq
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      7697eee3
    • P
      objtool: Rewrite add_ignores() · aaf5c623
      Peter Zijlstra 提交于
      The whole add_ignores() thing was wildly weird; rewrite it according
      to 'modern' ways.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      aaf5c623
    • P
      objtool: Set insn->func for alternatives · a4d09dde
      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: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      a4d09dde
    • P
      x86/nospec, objtool: Introduce ANNOTATE_IGNORE_ALTERNATIVE · ff05ab23
      Peter Zijlstra 提交于
      To facillitate other usage of ignoring alternatives; rename
      ANNOTATE_NOSPEC_IGNORE to ANNOTATE_IGNORE_ALTERNATIVE.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      ff05ab23
  10. 21 3月, 2019 1 次提交
  11. 08 9月, 2018 1 次提交
    • A
      objtool: Support per-function rodata sections · 4a60aa05
      Allan Xavier 提交于
      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: NAllan Xavier <allan.x.xavier@oracle.com>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/099bdc375195c490dda04db777ee0b95d566ded1.1536325914.git.jpoimboe@redhat.com
      4a60aa05
  12. 21 6月, 2018 1 次提交
  13. 20 6月, 2018 1 次提交
  14. 06 6月, 2018 1 次提交
    • J
      objtool: Fix GCC 8 cold subfunction detection for aliased functions · cd77849a
      Josh Poimboeuf 提交于
      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: 13810435 ("objtool: Support GCC 8's cold subfunctions")
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/d3ba52662cbc8e3a64a3b64d44b4efc5674fd9ab.1527855808.git.jpoimboe@redhat.com
      cd77849a
  15. 19 5月, 2018 1 次提交
    • J
      objtool: Detect RIP-relative switch table references, part 2 · 7dec80cc
      Josh Poimboeuf 提交于
      With the following commit:
      
        fd35c88b ("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:
      
        6f5ec299 ("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: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/f400541613d45689086329432f3095119ffbc328.1526674218.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      7dec80cc
  16. 15 5月, 2018 1 次提交
    • J
      objtool: Detect RIP-relative switch table references · 6f5ec299
      Josh Poimboeuf 提交于
      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 <dispc_runtime_suspend+0xb6a>
      			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 <dispc_runtime_suspend+0xbb8>
      			19c0: R_X86_64_PC32	.rodata+0x45c
          19c4:	e9 00 00 00 00       	jmpq   19c9 <dispc_runtime_suspend+0xbbd>
      			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: NRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/b6098294fd67afb69af8c47c9883d7a68bf0f8ea.1526305958.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      6f5ec299
  17. 14 5月, 2018 3 次提交
    • J
      objtool: Support GCC 8 switch tables · fd35c88b
      Josh Poimboeuf 提交于
      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: NArnd Bergmann <arnd@arndb.de>
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: damian <damian.tometzki@icloud.com>
      Link: http://lkml.kernel.org/r/20180510224849.xwi34d6tzheb5wgw@trebleSigned-off-by: NIngo Molnar <mingo@kernel.org>
      fd35c88b
    • J
      objtool: Support GCC 8's cold subfunctions · 13810435
      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: Ndamian <damian.tometzki@icloud.com>
      Reported-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/0965e7fcfc5f31a276f0c7f298ff770c19b68706.1525923412.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      13810435
    • J
      objtool: Fix "noreturn" detection for recursive sibling calls · 0afd0d9e
      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: NRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: damian <damian.tometzki@icloud.com>
      Link: http://lkml.kernel.org/r/7cc156408c5781a1f62085d352ced1fe39fe2f91.1525923412.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      0afd0d9e
  18. 27 3月, 2018 1 次提交
    • J
      objtool: Add Clang support · 3c1f0583
      Josh Poimboeuf 提交于
      Since the ORC unwinder was made the default on x86_64, Clang-built
      defconfig kernels have triggered some new objtool warnings:
      
        drivers/gpu/drm/i915/i915_gpu_error.o: warning: objtool: i915_error_printf()+0x6c: return with modified stack frame
        drivers/gpu/drm/i915/intel_display.o: warning: objtool: pipe_config_err()+0xa6: return with modified stack frame
      
      The problem is that objtool has never seen clang-built binaries before.
      
      Shockingly enough, objtool is apparently able to follow the code flow
      mostly fine, except for one instruction sequence.  Instead of a LEAVE
      instruction, clang restores RSP and RBP the long way:
      
         67c:   48 89 ec                mov    %rbp,%rsp
         67f:   5d                      pop    %rbp
      
      Teach objtool about this new code sequence.
      Reported-and-test-by: NMatthias Kaehlcke <mka@chromium.org>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matthias Kaehlcke <mka@chromium.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/fce88ce81c356eedcae7f00ed349cfaddb3363cc.1521741586.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      3c1f0583
  19. 07 3月, 2018 1 次提交