1. 13 12月, 2019 6 次提交
    • A
      perf script: Fix invalid LBR/binary mismatch error · 484c4d9a
      Adrian Hunter 提交于
      [ Upstream commit 5172672da02e483d9b3c4d814c3482d0c8ffb1a6 ]
      
      The 'len' returned by grab_bb() includes an extra MAXINSN bytes to allow
      for the last instruction, so the the final 'offs' will not be 'len'.
      Fix the error condition logic accordingly.
      
      Before:
      
        $ perf record -e '{intel_pt//,cpu/mem_inst_retired.all_loads,aux-sample-size=8192/pp}:u' grep -rqs jhgjhg /boot
        [ perf record: Woken up 19 times to write data ]
        [ perf record: Captured and wrote 2.274 MB perf.data ]
        $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
                  grep 13759 [002]  8091.310257:       1862                                        instructions:uH:      5641d58069eb bmexec+0x86b (/bin/grep)
              bmexec+2485:
              00005641d5806b35                        jnz 0x5641d5806bd0              # MISPRED
              00005641d5806bd0                        movzxb  (%r13,%rdx,1), %eax
              00005641d5806bd6                        add %rdi, %rax
              00005641d5806bd9                        movzxb  -0x1(%rax), %edx
              00005641d5806bdd                        cmp %rax, %r14
              00005641d5806be0                        jnb 0x5641d58069c0              # MISPRED
              mismatch of LBR data and executable
              00005641d58069c0                        movzxb  (%r13,%rdx,1), %edi
      
      After:
      
        $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
                  grep 13759 [002]  8091.310257:       1862                                        instructions:uH:      5641d58069eb bmexec+0x86b (/bin/grep)
              bmexec+2485:
              00005641d5806b35                        jnz 0x5641d5806bd0              # MISPRED
              00005641d5806bd0                        movzxb  (%r13,%rdx,1), %eax
              00005641d5806bd6                        add %rdi, %rax
              00005641d5806bd9                        movzxb  -0x1(%rax), %edx
              00005641d5806bdd                        cmp %rax, %r14
              00005641d5806be0                        jnb 0x5641d58069c0              # MISPRED
              00005641d58069c0                        movzxb  (%r13,%rdx,1), %edi
              00005641d58069c6                        add %rax, %rdi
      
      Fixes: e98df280bc2a ("perf script brstackinsn: Fix recovery from LBR/binary mismatch")
      Reported-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lore.kernel.org/lkml/20191127095631.15663-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      484c4d9a
    • Y
      tools/bpf: make libbpf _GNU_SOURCE friendly · 043a7151
      Yonghong Song 提交于
      [ Upstream commit b42699547fc9fb1057795bccc21a6445743a7fde ]
      
      During porting libbpf to bcc, I got some warnings like below:
        ...
        [  2%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf.c.o
        /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf.c:12:0:
        warning: "_GNU_SOURCE" redefined [enabled by default]
         #define _GNU_SOURCE
        ...
        [  3%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf_errno.c.o
        /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c: In function ‘libbpf_strerror’:
        /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c:45:7:
        warning: assignment makes integer from pointer without a cast [enabled by default]
           ret = strerror_r(err, buf, size);
        ...
      
      bcc is built with _GNU_SOURCE defined and this caused the above warning.
      This patch intends to make libpf _GNU_SOURCE friendly by
        . define _GNU_SOURCE in libbpf.c unless it is not defined
        . undefine _GNU_SOURCE as non-gnu version of strerror_r is expected.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Acked-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      043a7151
    • Y
      tools: bpftool: fix a bitfield pretty print issue · 29e704b7
      Yonghong Song 提交于
      [ Upstream commit 528bff0cdb6649f97f2c4802e4ac7a4b50645f2f ]
      
      Commit b12d6ec0 ("bpf: btf: add btf print functionality")
      added btf pretty print functionality to bpftool.
      There is a problem though in printing a bitfield whose type
      has modifiers.
      
      For example, for a type like
        typedef int ___int;
        struct tmp_t {
                int a:3;
                ___int b:3;
        };
      Suppose we have a map
        struct bpf_map_def SEC("maps") tmpmap = {
                .type = BPF_MAP_TYPE_HASH,
                .key_size = sizeof(__u32),
                .value_size = sizeof(struct tmp_t),
                .max_entries = 1,
        };
      and the hash table is populated with one element with
      key 0 and value (.a = 1 and .b = 2).
      
      In BTF, the struct member "b" will have a type "typedef" which
      points to an int type. The current implementation does not
      pass the bit offset during transition from typedef to int type,
      hence incorrectly print the value as
        $ bpftool m d id 79
        [{
                "key": 0,
                "value": {
                    "a": 0x1,
                    "b": 0x1
                }
            }
        ]
      
      This patch fixed the issue by carrying bit_offset along the type
      chain during bit_field print. The correct result can be printed as
        $ bpftool m d id 76
        [{
                "key": 0,
                "value": {
                    "a": 0x1,
                    "b": 0x2
                }
            }
        ]
      
      The kernel pretty print is implemented correctly and does not
      have this issue.
      
      Fixes: b12d6ec0 ("bpf: btf: add btf print functionality")
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      29e704b7
    • B
      selftests/powerpc: Skip test instead of failing · 5aba7739
      Breno Leitao 提交于
      [ Upstream commit eafcd8e3fbad4f426a40ed2b6a8c697c3a4ef36a ]
      
      Current core-pkey selftest fails if the test runs without privileges to
      write into the core pattern file (/proc/sys/kernel/core_pattern). This
      causes the test to fail and give the impression that the subsystem being
      tested is broken, when, in fact, the test is being executed without the
      proper privileges. This is the current error:
      
      	test: core_pkey
      	tags: git_version:v4.19-3-g9e3363be9bce-dirty
      	Error writing to core_pattern file: Permission denied
      	failure: core_pkey
      
      This patch simply skips this test if it runs without the proper privileges,
      avoiding this undesired failure.
      
      CC: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
      CC: Thiago Jung Bauermann <bauerman@linux.ibm.com>
      Signed-off-by: NBreno Leitao <leitao@debian.org>
      Reviewed-by: NThiago Jung Bauermann <bauerman@linux.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      5aba7739
    • B
      selftests/powerpc: Allocate base registers · 104d0d63
      Breno Leitao 提交于
      [ Upstream commit 5249497a7bb6334fcc128588d6a7e1e21786515a ]
      
      Some ptrace selftests are passing input operands using a constraint that
      can allocate any register for the operand, and using these registers on
      load/store operations.
      
      If the register allocated by the compiler happens to be zero (r0), it might
      cause an invalid memory address access, since load and store operations
      consider the content of 0x0 address if the base register is r0, instead of
      the content of the r0 register. For example:
      
      	r1 := 0xdeadbeef
      	r0 := 0xdeadbeef
      
      	ld r2, 0(1) /* will load into r2 the content of r1 address */
      	ld r2, 0(0) /* will load into r2 the content of 0x0 */
      
      In order to avoid this possible problem, the inline assembly constraint
      should be aware that these registers will be used as a base register, thus,
      r0 should not be allocated.
      
      Other than that, this patch removes inline assembly operands that are not
      used by the tests.
      Signed-off-by: NBreno Leitao <leitao@debian.org>
      Reviewed-by: NSegher Boessenkool <segher@kernel.crashing.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      104d0d63
    • V
      selftests: kvm: fix build with glibc >= 2.30 · a806e2a3
      Vitaly Kuznetsov 提交于
      [ Upstream commit e37f9f139f62deddff90c7298ae3a85026a71067 ]
      
      Glibc-2.30 gained gettid() wrapper, selftests fail to compile:
      
      lib/assert.c:58:14: error: static declaration of ‘gettid’ follows non-static declaration
         58 | static pid_t gettid(void)
            |              ^~~~~~
      In file included from /usr/include/unistd.h:1170,
                       from include/test_util.h:18,
                       from lib/assert.c:10:
      /usr/include/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here
         34 | extern __pid_t gettid (void) __THROW;
            |                ^~~~~~
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a806e2a3
  2. 05 12月, 2019 2 次提交
  3. 01 12月, 2019 20 次提交
  4. 24 11月, 2019 6 次提交
  5. 21 11月, 2019 1 次提交
    • B
      selftests/powerpc: Do not fail with reschedule · a3581509
      Breno Leitao 提交于
      [ Upstream commit 44d947eff19d64384efc06069509db7a0a1103b0 ]
      
      There are cases where the test is not expecting to have the transaction
      aborted, but, the test process might have been rescheduled, either in the
      OS level or by KVM (if it is running on a KVM guest machine). The process
      reschedule will cause a treclaim/recheckpoint which will cause the
      transaction to doom, aborting the transaction as soon as the process is
      rescheduled back to the CPU. This might cause the test to fail, but this is
      not a failure in essence.
      
      If that is the case, TEXASR[FC] is indicated with either
      TM_CAUSE_RESCHEDULE or TM_CAUSE_KVM_RESCHEDULE for KVM interruptions.
      
      In this scenario, ignore these two failures and avoid the whole test to
      return failure.
      Signed-off-by: NBreno Leitao <leitao@debian.org>
      Reviewed-by: NGustavo Romero <gromero@linux.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a3581509
  6. 13 11月, 2019 3 次提交
  7. 10 11月, 2019 2 次提交