1. 02 6月, 2018 1 次提交
  2. 26 5月, 2018 2 次提交
  3. 23 5月, 2018 1 次提交
  4. 19 5月, 2018 6 次提交
    • 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
    • R
      radix tree test suite: multi-order iteration race · fd8f58c4
      Ross Zwisler 提交于
      Add a test which shows a race in the multi-order iteration code.  This
      test reliably hits the race in under a second on my machine, and is the
      result of a real bug report against kernel a production v4.15 based
      kernel (4.15.6-300.fc27.x86_64).  With a real kernel this issue is hit
      when using order 9 PMD DAX radix tree entries.
      
      The race has to do with how we tear down multi-order sibling entries
      when we are removing an item from the tree.  Remember that an order 2
      entry looks like this:
      
        struct radix_tree_node.slots[] = [entry][sibling][sibling][sibling]
      
      where 'entry' is in some slot in the struct radix_tree_node, and the
      three slots following 'entry' contain sibling pointers which point back
      to 'entry.'
      
      When we delete 'entry' from the tree, we call :
      
        radix_tree_delete()
          radix_tree_delete_item()
            __radix_tree_delete()
              replace_slot()
      
      replace_slot() first removes the siblings in order from the first to the
      last, then at then replaces 'entry' with NULL.  This means that for a
      brief period of time we end up with one or more of the siblings removed,
      so:
      
        struct radix_tree_node.slots[] = [entry][NULL][sibling][sibling]
      
      This causes an issue if you have a reader iterating over the slots in
      the tree via radix_tree_for_each_slot() while only under
      rcu_read_lock()/rcu_read_unlock() protection.  This is a common case in
      mm/filemap.c.
      
      The issue is that when __radix_tree_next_slot() => skip_siblings() tries
      to skip over the sibling entries in the slots, it currently does so with
      an exact match on the slot directly preceding our current slot.
      Normally this works:
      
                                            V preceding slot
        struct radix_tree_node.slots[] = [entry][sibling][sibling][sibling]
                                                    ^ current slot
      
      This lets you find the first sibling, and you skip them all in order.
      
      But in the case where one of the siblings is NULL, that slot is skipped
      and then our sibling detection is interrupted:
      
                                                   V preceding slot
        struct radix_tree_node.slots[] = [entry][NULL][sibling][sibling]
                                                          ^ current slot
      
      This means that the sibling pointers aren't recognized since they point
      all the way back to 'entry', so we think that they are normal internal
      radix tree pointers.  This causes us to think we need to walk down to a
      struct radix_tree_node starting at the address of 'entry'.
      
      In a real running kernel this will crash the thread with a GP fault when
      you try and dereference the slots in your broken node starting at
      'entry'.
      
      In the radix tree test suite this will be caught by the address
      sanitizer:
      
        ==27063==ERROR: AddressSanitizer: heap-buffer-overflow on address
        0x60c0008ae400 at pc 0x00000040ce4f bp 0x7fa89b8fcad0 sp 0x7fa89b8fcac0
        READ of size 8 at 0x60c0008ae400 thread T3
            #0 0x40ce4e in __radix_tree_next_slot /home/rzwisler/project/linux/tools/testing/radix-tree/radix-tree.c:1660
            #1 0x4022cc in radix_tree_next_slot linux/../../../../include/linux/radix-tree.h:567
            #2 0x4022cc in iterator_func /home/rzwisler/project/linux/tools/testing/radix-tree/multiorder.c:655
            #3 0x7fa8a088d50a in start_thread (/lib64/libpthread.so.0+0x750a)
            #4 0x7fa8a03bd16e in clone (/lib64/libc.so.6+0xf516e)
      
      Link: http://lkml.kernel.org/r/20180503192430.7582-5-ross.zwisler@linux.intel.comSigned-off-by: NRoss Zwisler <ross.zwisler@linux.intel.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: CR, Sapthagirish <sapthagirish.cr@intel.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Chinner <david@fromorbit.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Matthew Wilcox <willy@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fd8f58c4
    • R
      radix tree test suite: add item_delete_rcu() · 3e252fa7
      Ross Zwisler 提交于
      Currently the lifetime of "struct item" entries in the radix tree are
      not controlled by RCU, but are instead deleted inline as they are
      removed from the tree.
      
      In the following patches we add a test which has threads iterating over
      items pulled from the tree and verifying them in an
      rcu_read_lock()/rcu_read_unlock() section.  This means that though an
      item has been removed from the tree it could still be being worked on by
      other threads until the RCU grace period expires.  So, we need to
      actually free the "struct item" structures at the end of the grace
      period, just as we do with "struct radix_tree_node" items.
      
      Link: http://lkml.kernel.org/r/20180503192430.7582-4-ross.zwisler@linux.intel.comSigned-off-by: NRoss Zwisler <ross.zwisler@linux.intel.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: CR, Sapthagirish <sapthagirish.cr@intel.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Chinner <david@fromorbit.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Matthew Wilcox <willy@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3e252fa7
    • R
      radix tree test suite: fix compilation issue · dcbbf25a
      Ross Zwisler 提交于
      Pulled from a patch from Matthew Wilcox entitled "xarray: Add definition
      of struct xarray":
      
      > From: Matthew Wilcox <mawilcox@microsoft.com>
      > Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
      
        https://patchwork.kernel.org/patch/10341249/
      
      These defines fix this compilation error:
      
        In file included from ./linux/radix-tree.h:6:0,
                         from ./linux/../../../../include/linux/idr.h:15,
                         from ./linux/idr.h:1,
                         from idr.c:4:
        ./linux/../../../../include/linux/idr.h: In function `idr_init_base':
        ./linux/../../../../include/linux/radix-tree.h:129:2: warning: implicit declaration of function `spin_lock_init'; did you mean `spinlock_t'? [-Wimplicit-function-declaration]
          spin_lock_init(&(root)->xa_lock);    \
          ^
        ./linux/../../../../include/linux/idr.h:126:2: note: in expansion of macro `INIT_RADIX_TREE'
          INIT_RADIX_TREE(&idr->idr_rt, IDR_RT_MARKER);
          ^~~~~~~~~~~~~~~
      
      by providing a spin_lock_init() wrapper for the v4.17-rc* version of the
      radix tree test suite.
      
      Link: http://lkml.kernel.org/r/20180503192430.7582-3-ross.zwisler@linux.intel.comSigned-off-by: NRoss Zwisler <ross.zwisler@linux.intel.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: CR, Sapthagirish <sapthagirish.cr@intel.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Chinner <david@fromorbit.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Matthew Wilcox <willy@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      dcbbf25a
    • R
      radix tree test suite: fix mapshift build target · 8d9fa88e
      Ross Zwisler 提交于
      Commit c6ce3e2f ("radix tree test suite: Add config option for map
      shift") introduced a phony makefile target called 'mapshift' that ends
      up generating the file generated/map-shift.h.  This phony target was
      then added as a dependency of the top level 'targets' build target,
      which is what is run when you go to tools/testing/radix-tree and just
      type 'make'.
      
      Unfortunately, this phony target doesn't actually work as a dependency,
      so you end up getting:
      
        $ make
        make: *** No rule to make target 'generated/map-shift.h', needed by 'main.o'.  Stop.
        make: *** Waiting for unfinished jobs....
      
      Fix this by making the file generated/map-shift.h our real makefile
      target, and add this a dependency of the top level build target.
      
      Link: http://lkml.kernel.org/r/20180503192430.7582-2-ross.zwisler@linux.intel.comSigned-off-by: NRoss Zwisler <ross.zwisler@linux.intel.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: CR, Sapthagirish <sapthagirish.cr@intel.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Chinner <david@fromorbit.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Matthew Wilcox <willy@infradead.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8d9fa88e
    • A
      selftests: bpf: config: enable NET_SCH_INGRESS for xdp_meta.sh · a6837d26
      Anders Roxell 提交于
      When running bpf's selftest test_xdp_meta.sh it fails:
      ./test_xdp_meta.sh
      Error: Specified qdisc not found.
      selftests: test_xdp_meta [FAILED]
      
      Need to enable CONFIG_NET_SCH_INGRESS and CONFIG_NET_CLS_ACT to get the
      test to pass.
      
      Fixes: 22c88526 ("bpf: improve selftests and add tests for meta pointer")
      Signed-off-by: NAnders Roxell <anders.roxell@linaro.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      a6837d26
  5. 18 5月, 2018 1 次提交
  6. 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
  7. 14 5月, 2018 18 次提交
  8. 11 5月, 2018 8 次提交
    • A
      perf tools: Add missing newline when parsing empty BPF proggie · c23080a6
      Arnaldo Carvalho de Melo 提交于
      This is not specific to BPF but was found when parsing a .c BPF proggie
      that while valid, had no events attached to tracepoints, kprobes, etc:
      
      Very minimal file that perf's BPF code can compile:
      
        # cat empty.c
        char _license[] __attribute__((section("license"), used)) = "GPL";
        int _version __attribute__((section("version"), used)) = LINUX_VERSION_CODE;
        #
      
      Before this patch:
      
        # perf trace -e empty.c
        WARNING: event parser found nothinginvalid or unsupported event: 'empty.c'
        Run 'perf list' for a list of valid events
      
         Usage: perf trace [<options>] [<command>]
            or: perf trace [<options>] -- <command> [<options>]
            or: perf trace record [<options>] [<command>]
            or: perf trace record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event/syscall selector. use 'perf list' to list available events
          #
      
      After:
      
        # perf trace -e empty.c
        WARNING: event parser found nothing
        invalid or unsupported event: 'empty.c'
        Run 'perf list' for a list of valid events
      
         Usage: perf trace [<options>] [<command>]
            or: perf trace [<options>] -- <command> [<options>]
            or: perf trace record [<options>] [<command>]
            or: perf trace record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event/syscall selector. use 'perf list' to list available events
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-8ysughiz00h6mjpcot04qyjj@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c23080a6
    • L
      perf cs-etm: Remove redundant space · 3a088799
      Leo Yan 提交于
      There have two spaces ahead function name cs_etm__set_pid_tid_cpu(), so
      remove one space and correct indentation.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Acked-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1525924920-4381-2-git-send-email-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3a088799
    • L
      perf cs-etm: Support unknown_thread in cs_etm_auxtrace · 46d53620
      Leo Yan 提交于
      CoreSight doesn't allocate thread structure for unknown_thread in ETM
      auxtrace, so unknown_thread is NULL pointer.  If the perf data doesn't
      contain valid tid and then cs_etm__mem_access() uses unknown_thread
      instead as thread handler, this results in a segmentation fault when
      thread__find_addr_map() accesses the thread handler.
      
      This commit creates a new thread data which is used by unknown_thread, so
      CoreSight tracing can roll back to use unknown_thread if perf data
      doesn't include valid thread info.  This commit also releases thread
      data for initialization failure case and for normal auxtrace free flow.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Acked-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1525924920-4381-1-git-send-email-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      46d53620
    • P
      KVM: selftests: exit with 0 status code when tests cannot be run · bcb2b94a
      Paolo Bonzini 提交于
      Right now, skipped tests are returning a failure exit code if /dev/kvm does
      not exists.  Consistently return a zero status code so that various scripts
      over the interwebs do not complain.  Also return a zero status code if
      the KVM_CAP_SYNC_REGS capability is not present, and hardcode in the
      test the register kinds that are covered (rather than just using whatever
      value of KVM_SYNC_X86_VALID_FIELDS is provided by the kernel headers).
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      bcb2b94a
    • J
      tools: bpf: handle NULL return in bpf_prog_load_xattr() · 3597683c
      Jakub Kicinski 提交于
      bpf_object__open() can return error pointer as well as NULL.
      Fix error handling in bpf_prog_load_xattr() (and indirectly
      bpf_prog_load()).
      
      Fixes: 6f6d33f3 ("bpf: selftests add sockmap tests")
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Reviewed-by: NQuentin Monnet <quentin.monnet@netronome.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      3597683c
    • D
      tc-testing: fix tdc tests for 'bpf' action · f7017caf
      Davide Caratti 提交于
      - correct a typo in the value of 'matchPattern' of test 282d, potentially
       causing false negative
      - allow errors when 'teardown' executes '$TC action flush action bpf' in
       test 282d, to fix false positive when it is run with act_bpf unloaded
      - correct the value of 'matchPattern' in test e939, causing false positive
       in case the BPF JIT is enabled
      
      Fixes: 440ea4ae ("tc-testing: add selftests for 'bpf' action")
      Signed-off-by: NDavide Caratti <dcaratti@redhat.com>
      Acked-by: NLucas Bates <lucasb@mojatatu.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f7017caf
    • J
      perf annotate: Display all available events on --stdio · 04d2600a
      Jin Yao 提交于
      When we perform the following command lines:
      
        $ perf record -e "{cycles,branches}" ./div
        $ perf annotate main --stdio
      
      The output shows only the first event, "cycles" and the displaying
      format is not correct.
      
         Percent         |      Source code & Disassembly of div for cycles (44550 samples)
        -----------------------------------------------------------------------------------
                         :
                         :
                         :
                         :            Disassembly of section .text:
                         :
                         :            00000000004004b0 <main>:
                         :            main():
                         :
                         :                    return i;
                         :            }
                         :
                         :            int main(void)
                         :            {
            0.00 :   4004b0:       push   %rbx
                         :                    int i;
                         :                    int flag;
                         :                    volatile double x = 1212121212, y = 121212;
                         :
                         :                    s_randseed = time(0);
            0.00 :   4004b1:       xor    %edi,%edi
                         :                    srand(s_randseed);
            0.00 :   4004b3:       mov    $0x77359400,%ebx
                         :
                         :                    return i;
                         :            }
      
      The issue is that the value of the 'nr_percent' variable is hardcoded to
      1.  This patch fixes it.
      
      With this patch, the output is:
      
         Percent         |      Source code & Disassembly of div for cycles (44550 samples)
        -----------------------------------------------------------------------------------
                         :
                         :
                         :
                         :            Disassembly of section .text:
                         :
                         :            00000000004004b0 <main>:
                         :            main():
                         :
                         :                    return i;
                         :            }
                         :
                         :            int main(void)
                         :            {
            0.00    0.00 :   4004b0:       push   %rbx
                         :                    int i;
                         :                    int flag;
                         :                    volatile double x = 1212121212, y = 121212;
                         :
                         :                    s_randseed = time(0);
            0.00    0.00 :   4004b1:       xor    %edi,%edi
                         :                    srand(s_randseed);
            0.00    0.00 :   4004b3:       mov    $0x77359400,%ebx
                         :
                         :                    return i;
                         :            }
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Fixes: f681d593 ("perf annotate: Remove disasm__calc_percent() from disasm_line__print()")
      Link: http://lkml.kernel.org/r/1525881435-4092-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      04d2600a
    • T
      perf test: "probe libc's inet_pton" fails on s390 due to missing inline · f8207b98
      Thomas Richter 提交于
      perf test "probe libc's inet_pton & backtrace it with ping" fails on
      4.17.0rc3 on s/390. It turned out that function __inet_pton is reported
      as inline:
      
        [root@s8360047 perf]# ./perf script -i /tmp/perf.data.111
        ping 12457 [000]  1584.478959: probe_libc:inet_pton: (3ffb5a347e8)
                          1347e8 __inet_pton (inlined)
                           f19d7 gaih_inet.constprop.5 (/usr/lib64/libc-2.24.so)
                           f4c3f __GI_getaddrinfo (inlined)
                            410b main (/usr/bin/ping)
      
      Allow __inet_pton listed as inline.
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20180503065837.71043-1-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f8207b98
  9. 08 5月, 2018 2 次提交