1. 23 Jun, 2021 3 commits
    • Kan Liang's avatar
      perf/x86/intel: Add more events requires FRONTEND MSR on Sapphire Rapids · d18216fa
      Kan Liang authored
      On Sapphire Rapids, there are two more events 0x40ad and 0x04c2 which
      rely on the FRONTEND MSR. If the FRONTEND MSR is not set correctly, the
      count value is not correct.
      
      Update intel_spr_extra_regs[] to support them.
      
      Fixes: 61b985e3 ("perf/x86/intel: Add perf core PMU support for Sapphire Rapids")
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/1624029174-122219-3-git-send-email-kan.liang@linux.intel.com
      d18216fa
    • Kan Liang's avatar
      perf/x86/intel: Fix fixed counter check warning for some Alder Lake · ee72a94e
      Kan Liang authored
      For some Alder Lake machine, the below fixed counter check warning may be
      triggered.
      
      [    2.010766] hw perf events fixed 5 > max(4), clipping!
      
      Current perf unconditionally increases the number of the GP counters and
      the fixed counters for a big core PMU on an Alder Lake system, because
      the number enumerated in the CPUID only reflects the common counters.
      The big core may has more counters. However, Alder Lake may have an
      alternative configuration. With that configuration,
      the X86_FEATURE_HYBRID_CPU is not set. The number of the GP counters and
      fixed counters enumerated in the CPUID is accurate. Perf mistakenly
      increases the number of counters. The warning is triggered.
      
      Directly use the enumerated value on the system with the alternative
      configuration.
      
      Fixes: f83d2f91 ("perf/x86/intel: Add Alder Lake Hybrid support")
      Reported-by: default avatarJin Yao <yao.jin@linux.intel.com>
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/1624029174-122219-2-git-send-email-kan.liang@linux.intel.com
      ee72a94e
    • Like Xu's avatar
      perf/x86/intel: Fix PEBS-via-PT reload base value for Extended PEBS · 4c58d922
      Like Xu authored
      If we use the "PEBS-via-PT" feature on a platform that supports
      extended PBES, like this:
      
          perf record -c 10000 \
          -e '{intel_pt/branch=0/,branch-instructions/aux-output/p}' uname
      
      we will encounter the following call trace:
      
      [  250.906542] unchecked MSR access error: WRMSR to 0x14e1 (tried to write
      0x0000000000000000) at rIP: 0xffffffff88073624 (native_write_msr+0x4/0x20)
      [  250.920779] Call Trace:
      [  250.923508]  intel_pmu_pebs_enable+0x12c/0x190
      [  250.928359]  intel_pmu_enable_event+0x346/0x390
      [  250.933300]  x86_pmu_start+0x64/0x80
      [  250.937231]  x86_pmu_enable+0x16a/0x2f0
      [  250.941434]  perf_event_exec+0x144/0x4c0
      [  250.945731]  begin_new_exec+0x650/0xbf0
      [  250.949933]  load_elf_binary+0x13e/0x1700
      [  250.954321]  ? lock_acquire+0xc2/0x390
      [  250.958430]  ? bprm_execve+0x34f/0x8a0
      [  250.962544]  ? lock_is_held_type+0xa7/0x120
      [  250.967118]  ? find_held_lock+0x32/0x90
      [  250.971321]  ? sched_clock_cpu+0xc/0xb0
      [  250.975527]  bprm_execve+0x33d/0x8a0
      [  250.979452]  do_execveat_common.isra.0+0x161/0x1d0
      [  250.984673]  __x64_sys_execve+0x33/0x40
      [  250.988877]  do_syscall_64+0x3d/0x80
      [  250.992806]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [  250.998302] RIP: 0033:0x7fbc971d82fb
      [  251.002235] Code: Unable to access opcode bytes at RIP 0x7fbc971d82d1.
      [  251.009303] RSP: 002b:00007fffb8aed808 EFLAGS: 00000202 ORIG_RAX: 000000000000003b
      [  251.017478] RAX: ffffffffffffffda RBX: 00007fffb8af2f00 RCX: 00007fbc971d82fb
      [  251.025187] RDX: 00005574792aac50 RSI: 00007fffb8af2f00 RDI: 00007fffb8aed810
      [  251.032901] RBP: 00007fffb8aed970 R08: 0000000000000020 R09: 00007fbc9725c8b0
      [  251.040613] R10: 6d6c61632f6d6f63 R11: 0000000000000202 R12: 00005574792aac50
      [  251.048327] R13: 00007fffb8af35f0 R14: 00005574792aafdf R15: 00005574792aafe7
      
      This is because the target reload msr address is calculated
      based on the wrong base msr and the target reload msr value
      is accessed from ds->pebs_event_reset[] with the wrong offset.
      
      According to Intel SDM Table 2-14, for extended PBES feature,
      the reload msr for MSR_IA32_FIXED_CTRx should be based on
      MSR_RELOAD_FIXED_CTRx.
      
      For fixed counters, let's fix it by overriding the reload msr
      address and its value, thus avoiding out-of-bounds access.
      
      Fixes: 42880f72("perf/x86/intel: Support PEBS output to PT")
      Signed-off-by: default avatarLike Xu <likexu@tencent.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20210621034710.31107-1-likexu@tencent.com
      4c58d922
  2. 17 Jun, 2021 1 commit
    • Kan Liang's avatar
      perf/x86: Reset the dirty counter to prevent the leak for an RDPMC task · 5471eea5
      Kan Liang authored
      The counter value of a perf task may leak to another RDPMC task.
      For example, a perf stat task as below is running on CPU 0.
      
          perf stat -e 'branches,cycles' -- taskset -c 0 ./workload
      
      In the meantime, an RDPMC task, which is also running on CPU 0, may read
      the GP counters periodically. (The RDPMC task creates a fixed event,
      but read four GP counters.)
      
          $./rdpmc_read_all_counters
          index 0x0 value 0x8001e5970f99
          index 0x1 value 0x8005d750edb6
          index 0x2 value 0x0
          index 0x3 value 0x0
      
          index 0x0 value 0x8002358e48a5
          index 0x1 value 0x8006bd1e3bc9
          index 0x2 value 0x0
          index 0x3 value 0x0
      
      It is a potential security issue. Once the attacker knows what the other
      thread is counting. The PerfMon counter can be used as a side-channel to
      attack cryptosystems.
      
      The counter value of the perf stat task leaks to the RDPMC task because
      perf never clears the counter when it's stopped.
      
      Three methods were considered to address the issue.
      
       - Unconditionally reset the counter in x86_pmu_del(). It can bring extra
         overhead even when there is no RDPMC task running.
      
       - Only reset the un-assigned dirty counters when the RDPMC task is
         scheduled in via sched_task(). It fails for the below case.
      
      	Thread A			Thread B
      
      	clone(CLONE_THREAD) --->
      	set_affine(0)
      					set_affine(1)
      					while (!event-enabled)
      						;
      	event = perf_event_open()
      	mmap(event)
      	ioctl(event, IOC_ENABLE); --->
      					RDPMC
      
         Counters are still leaked to the thread B.
      
       - Only reset the un-assigned dirty counters before updating the CR4.PCE
         bit. The method is implemented here.
      
      The dirty counter is a counter, on which the assigned event has been
      deleted, but the counter is not reset. To track the dirty counters,
      add a 'dirty' variable in the struct cpu_hw_events.
      
      The security issue can only be found with an RDPMC task. To enable the
      RDMPC, the CR4.PCE bit has to be updated. Add a
      perf_clear_dirty_counters() right before updating the CR4.PCE bit to
      clear the existing dirty counters. Only the current un-assigned dirty
      counters are reset, because the RDPMC assigned dirty counters will be
      updated soon.
      
      After applying the patch,
      
              $ ./rdpmc_read_all_counters
              index 0x0 value 0x0
              index 0x1 value 0x0
              index 0x2 value 0x0
              index 0x3 value 0x0
      
              index 0x0 value 0x0
              index 0x1 value 0x0
              index 0x2 value 0x0
              index 0x3 value 0x0
      
      Performance
      
      The performance of a context switch only be impacted when there are two
      or more perf users and one of the users must be an RDPMC user. In other
      cases, there is no performance impact.
      
      The worst-case occurs when there are two users: the RDPMC user only
      uses one counter; while the other user uses all available counters.
      When the RDPMC task is scheduled in, all the counters, other than the
      RDPMC assigned one, have to be reset.
      
      Test results for the worst-case, using a modified lat_ctx as measured
      on an Ice Lake platform, which has 8 GP and 3 FP counters (ignoring
      SLOTS).
      
          lat_ctx -s 128K -N 1000 processes 2
      
      Without the patch:
        The context switch time is 4.97 us
      
      With the patch:
        The context switch time is 5.16 us
      
      There is ~4% performance drop for the context switching time in the
      worst-case.
      Suggested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/1623693582-187370-1-git-send-email-kan.liang@linux.intel.com
      5471eea5
  3. 03 Jun, 2021 1 commit
  4. 01 Jun, 2021 3 commits
  5. 27 May, 2021 3 commits
  6. 18 May, 2021 3 commits
  7. 12 May, 2021 1 commit
  8. 11 May, 2021 2 commits
  9. 10 May, 2021 19 commits
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.13-2021-05-10' of... · 1140ab59
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.13-2021-05-10' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Fix swapping of cpu_map and stat_config records.
      
       - Fix dynamic libbpf linking.
      
       - Disallow -c and -F option at the same time in 'perf record'.
      
       - Update headers with the kernel originals.
      
       - Silence warning for JSON ArchStd files.
      
       - Fix a build error on arm64 with clang.
      
      * tag 'perf-tools-fixes-for-v5.13-2021-05-10' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        tools headers UAPI: Sync perf_event.h with the kernel sources
        tools headers cpufeatures: Sync with the kernel sources
        tools include UAPI powerpc: Sync errno.h with the kernel headers
        tools arch: Update arch/x86/lib/mem{cpy,set}_64.S copies used in 'perf bench mem memcpy'
        tools headers UAPI: Sync linux/prctl.h with the kernel sources
        tools headers UAPI: Sync files changed by landlock, quotactl_path and mount_settattr new syscalls
        perf tools: Fix a build error on arm64 with clang
        tools headers kvm: Sync kvm headers with the kernel sources
        tools headers UAPI: Sync linux/kvm.h with the kernel sources
        perf tools: Fix dynamic libbpf link
        perf session: Fix swapping of cpu_map and stat_config records
        perf jevents: Silence warning for ArchStd files
        perf record: Disallow -c and -F option at the same time
        tools arch x86: Sync the msr-index.h copy with the kernel sources
        tools headers UAPI: Sync drm/i915_drm.h with the kernel sources
        tools headers UAPI: Update tools's copy of drm.h headers
      1140ab59
    • Linus Torvalds's avatar
      Merge tag 'for-5.13-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · 142b507f
      Linus Torvalds authored
      Pull btrfs fixes from David Sterba:
       "First batch of various fixes, here's a list of notable ones:
      
         - fix unmountable seed device after fstrim
      
         - fix silent data loss in zoned mode due to ordered extent splitting
      
         - fix race leading to unpersisted data and metadata on fsync
      
         - fix deadlock when cloning inline extents and using qgroups"
      
      * tag 'for-5.13-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: initialize return variable in cleanup_free_space_cache_v1
        btrfs: zoned: sanity check zone type
        btrfs: fix unmountable seed device after fstrim
        btrfs: fix deadlock when cloning inline extents and using qgroups
        btrfs: fix race leading to unpersisted data and metadata on fsync
        btrfs: do not consider send context as valid when trying to flush qgroups
        btrfs: zoned: fix silent data loss after failure splitting ordered extent
      142b507f
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 0aa099a3
      Linus Torvalds authored
      Pull kvm fixes from Paolo Bonzini:
      
       - Lots of bug fixes.
      
       - Fix virtualization of RDPID
      
       - Virtualization of DR6_BUS_LOCK, which on bare metal is new to this
         release
      
       - More nested virtualization migration fixes (nSVM and eVMCS)
      
       - Fix for KVM guest hibernation
      
       - Fix for warning in SEV-ES SRCU usage
      
       - Block KVM from loading on AMD machines with 5-level page tables, due
         to the APM not mentioning how host CR4.LA57 exactly impacts the
         guest.
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (48 commits)
        KVM: SVM: Move GHCB unmapping to fix RCU warning
        KVM: SVM: Invert user pointer casting in SEV {en,de}crypt helpers
        kvm: Cap halt polling at kvm->max_halt_poll_ns
        tools/kvm_stat: Fix documentation typo
        KVM: x86: Prevent deadlock against tk_core.seq
        KVM: x86: Cancel pvclock_gtod_work on module removal
        KVM: x86: Prevent KVM SVM from loading on kernels with 5-level paging
        KVM: X86: Expose bus lock debug exception to guest
        KVM: X86: Add support for the emulation of DR6_BUS_LOCK bit
        KVM: PPC: Book3S HV: Fix conversion to gfn-based MMU notifier callbacks
        KVM: x86: Hide RDTSCP and RDPID if MSR_TSC_AUX probing failed
        KVM: x86: Tie Intel and AMD behavior for MSR_TSC_AUX to guest CPU model
        KVM: x86: Move uret MSR slot management to common x86
        KVM: x86: Export the number of uret MSRs to vendor modules
        KVM: VMX: Disable loading of TSX_CTRL MSR the more conventional way
        KVM: VMX: Use common x86's uret MSR list as the one true list
        KVM: VMX: Use flag to indicate "active" uret MSRs instead of sorting list
        KVM: VMX: Configure list of user return MSRs at module init
        KVM: x86: Add support for RDPID without RDTSCP
        KVM: SVM: Probe and load MSR_TSC_AUX regardless of RDTSCP support in host
        ...
      0aa099a3
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync perf_event.h with the kernel sources · 71d7924b
      Arnaldo Carvalho de Melo authored
      To pick up the changes in:
      
        2b26f0aa ("perf: Support only inheriting events if cloned with CLONE_THREAD")
        2e498d0a ("perf: Add support for event removal on exec")
        547b6098 ("perf: aux: Add flags for the buffer format")
        55bcf6ef ("perf: Extend PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE")
        7dde5176 ("perf: aux: Add CoreSight PMU buffer formats")
        97ba62b2 ("perf: Add support for SIGTRAP on perf events")
        d0d1dd62 ("perf core: Add PERF_COUNT_SW_CGROUP_SWITCHES event")
      
      Also change the expected sizeof(struct perf_event_attr) from 120 to 128 due to
      fields being added for the SIGTRAP changes.
      
      Addressing this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h' differs from latest version at 'include/uapi/linux/perf_event.h'
        diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h
      
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      71d7924b
    • Arnaldo Carvalho de Melo's avatar
      tools headers cpufeatures: Sync with the kernel sources · 6faf64f5
      Arnaldo Carvalho de Melo authored
      To pick the changes from:
      
        4e629211 ("x86/paravirt: Add new features for paravirt patching")
        a161545a ("x86/cpufeatures: Enumerate Intel Hybrid Technology feature bit")
        a89dfde3 ("x86: Remove dynamic NOP selection")
        b8921dcc ("x86/cpufeatures: Add SGX1 and SGX2 sub-features")
        f21d4d3b ("x86/cpufeatures: Enumerate #DB for bus lock detection")
        f333374e ("x86/cpufeatures: Add the Virtual SPEC_CTRL feature")
      
      This only causes these perf files to be rebuilt:
      
        CC       /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o
        CC       /tmp/build/perf/bench/mem-memset-x86-64-asm.o
      
      And addresses this perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
        diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
      
      Cc: Babu Moger <babu.moger@amd.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6faf64f5
    • Arnaldo Carvalho de Melo's avatar
      tools include UAPI powerpc: Sync errno.h with the kernel headers · 39163293
      Arnaldo Carvalho de Melo authored
      To pick the change in:
      
        7de21e67 ("powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h")
      
      That will make the errno number -> string tables to pick this change on powerpc.
      
      Silencing this perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/powerpc/include/uapi/asm/errno.h' differs from latest version at 'arch/powerpc/include/uapi/asm/errno.h'
        diff -u tools/arch/powerpc/include/uapi/asm/errno.h arch/powerpc/include/uapi/asm/errno.h
      
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Tony Ambardar <tony.ambardar@gmail.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      39163293
    • Arnaldo Carvalho de Melo's avatar
      tools arch: Update arch/x86/lib/mem{cpy,set}_64.S copies used in 'perf bench mem memcpy' · fb24e308
      Arnaldo Carvalho de Melo authored
      To bring in the change made in this cset:
      
       5e21a3ec ("x86/alternative: Merge include files")
      
      This just silences these perf tools build warnings, no change in the tools:
      
        Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs from latest version at 'arch/x86/lib/memcpy_64.S'
        diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S
        Warning: Kernel ABI header at 'tools/arch/x86/lib/memset_64.S' differs from latest version at 'arch/x86/lib/memset_64.S'
        diff -u tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S
      
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Juergen Gross <jgross@suse.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fb24e308
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/prctl.h with the kernel sources · 5a80ee42
      Arnaldo Carvalho de Melo authored
      To pick a new prctl introduced in:
      
        20169862 ("arm64: Introduce prctl(PR_PAC_{SET,GET}_ENABLED_KEYS)")
      
      That results in
      
        $ grep prctl tools/perf/trace/beauty/*.sh
        tools/perf/trace/beauty/prctl_option.sh:printf "static const char *prctl_options[] = {\n"
        tools/perf/trace/beauty/prctl_option.sh:egrep $regex ${header_dir}/prctl.h | grep -v PR_SET_PTRACER | \
        tools/perf/trace/beauty/prctl_option.sh:printf "static const char *prctl_set_mm_options[] = {\n"
        tools/perf/trace/beauty/prctl_option.sh:egrep $regex ${header_dir}/prctl.h | \
        tools/perf/trace/beauty/x86_arch_prctl.sh:prctl_arch_header=${x86_header_dir}/prctl.h
        tools/perf/trace/beauty/x86_arch_prctl.sh:	printf "#define x86_arch_prctl_codes_%d_offset %s\n" $idx $first_entry
        tools/perf/trace/beauty/x86_arch_prctl.sh:	printf "static const char *x86_arch_prctl_codes_%d[] = {\n" $idx
        tools/perf/trace/beauty/x86_arch_prctl.sh:	egrep -q $regex ${prctl_arch_header} && \
        tools/perf/trace/beauty/x86_arch_prctl.sh:	(egrep $regex ${prctl_arch_header} | \
        $ tools/perf/trace/beauty/prctl_option.sh > before
        $ cp include/uapi/linux/prctl.h tools/include/uapi/linux/prctl.h
        $ tools/perf/trace/beauty/prctl_option.sh > after
        $ diff -u before after
        --- before	2021-05-09 10:06:10.064559675 -0300
        +++ after	2021-05-09 10:06:21.319791396 -0300
        @@ -54,6 +54,8 @@
         	[57] = "SET_IO_FLUSHER",
         	[58] = "GET_IO_FLUSHER",
         	[59] = "SET_SYSCALL_USER_DISPATCH",
        +	[60] = "PAC_SET_ENABLED_KEYS",
        +	[61] = "PAC_GET_ENABLED_KEYS",
         };
         static const char *prctl_set_mm_options[] = {
         	[1] = "START_CODE",
        $
      
      Now users can do:
      
        # perf trace -e syscalls:sys_enter_prctl --filter "option==PAC_GET_ENABLED_KEYS"
      ^C#
        # trace -v -e syscalls:sys_enter_prctl --filter "option==PAC_GET_ENABLED_KEYS"
        New filter for syscalls:sys_enter_prctl: (option==0x3d) && (common_pid != 5519 && common_pid != 3404)
      ^C#
      
      And also when prctl appears in a session, its options will be
      translated to the string.
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Peter Collingbourne <pcc@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5a80ee42
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync files changed by landlock, quotactl_path and mount_settattr new syscalls · f8bcb061
      Arnaldo Carvalho de Melo authored
      To pick the changes in these csets:
      
        a49f4f81 ("arch: Wire up Landlock syscalls")
        2a186721 ("fs: add mount_setattr()")
        fa8b9007 ("quota: wire up quotactl_path")
      
      That silences these perf build warnings and add support for those new
      syscalls in tools such as 'perf trace'.
      
      For instance, this is now possible:
      
        # ~acme/bin/perf trace -v -e landlock*
        event qualifier tracepoint filter: (common_pid != 129365 && common_pid != 3502) && (id == 444 || id == 445 || id == 446)
        ^C#
      
      That is tha filter expression attached to the raw_syscalls:sys_{enter,exit}
      tracepoints.
      
        $ grep landlock tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
        444	common	landlock_create_ruleset	sys_landlock_create_ruleset
        445	common	landlock_add_rule	sys_landlock_add_rule
        446	common	landlock_restrict_self	sys_landlock_restrict_self
        $
      
      This addresses these perf build warnings:
      
        Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/unistd.h' differs from latest version at 'include/uapi/asm-generic/unistd.h'
        diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
        Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'
        diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
        Warning: Kernel ABI header at 'tools/perf/arch/powerpc/entry/syscalls/syscall.tbl' differs from latest version at 'arch/powerpc/kernel/syscalls/syscall.tbl'
        diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
        Warning: Kernel ABI header at 'tools/perf/arch/s390/entry/syscalls/syscall.tbl' differs from latest version at 'arch/s390/kernel/syscalls/syscall.tbl'
        diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
        Warning: Kernel ABI header at 'tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl' differs from latest version at 'arch/mips/kernel/syscalls/syscall_n64.tbl'
        diff -u tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
      
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: James Morris <jamorris@linux.microsoft.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Mickaël Salaün <mic@linux.microsoft.com>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f8bcb061
    • Masami Hiramatsu's avatar
      perf tools: Fix a build error on arm64 with clang · a00b7e39
      Masami Hiramatsu authored
      Since clang's -Wmissing-field-initializers warns if a data
      structure is initialized with a signle NULL as below,
      
       ----
       tools/perf $ make CC=clang LLVM=1
       ...
       arch/arm64/util/kvm-stat.c:74:9: error: missing field 'ops' initializer [-Werror,-Wmissing-field-initializers]
               { NULL },
                      ^
       1 error generated.
       ----
      
      add another field initializer expressly as same as other
      arch's kvm-stat.c code.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Anders Roxell <anders.roxell@linaro.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Link: http://lore.kernel.org/lkml/162037767540.94840.15758657049033010518.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a00b7e39
    • Arnaldo Carvalho de Melo's avatar
      tools headers kvm: Sync kvm headers with the kernel sources · b35629bc
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        3c0c2ad1 ("KVM: VMX: Add basic handling of VM-Exit from SGX enclave")
      
      None of them trigger any changes in tooling, this time this is just to silence
      these perf build warnings:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/vmx.h' differs from latest version at 'arch/x86/include/uapi/asm/vmx.h'
        diff -u tools/arch/x86/include/uapi/asm/vmx.h arch/x86/include/uapi/asm/vmx.h
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b35629bc
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/kvm.h with the kernel sources · 0d943d5f
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        15fb7de1 ("KVM: SVM: Add KVM_SEV_RECEIVE_UPDATE_DATA command")
        3bf72569 ("KVM: arm64: Add support for the KVM PTP service")
        4cfdd47d ("KVM: SVM: Add KVM_SEV SEND_START command")
        54526d1f ("KVM: x86: Support KVM VMs sharing SEV context")
        5569e2e7 ("KVM: SVM: Add support for KVM_SEV_SEND_CANCEL command")
        8b13c364 ("KVM: introduce KVM_CAP_SET_GUEST_DEBUG2")
        af43cbbf ("KVM: SVM: Add support for KVM_SEV_RECEIVE_START command")
        d3d1af85 ("KVM: SVM: Add KVM_SEND_UPDATE_DATA command")
        fe7e9488 ("KVM: x86: Add capability to grant VM access to privileged SGX attribute")
      
      That don't cause any change in tooling as it doesn't introduce any new
      ioctl.
      
        $ grep kvm tools/perf/trace/beauty/*.sh
        tools/perf/trace/beauty/kvm_ioctl.sh:printf "static const char *kvm_ioctl_cmds[] = {\n"
        tools/perf/trace/beauty/kvm_ioctl.sh:egrep $regex ${header_dir}/kvm.h	| \
        $
        $ tools/perf/trace/beauty/kvm_ioctl.sh > before
        $ cp include/uapi/linux/kvm.h tools/include/uapi/linux/kvm.h
        $ tools/perf/trace/beauty/kvm_ioctl.sh > after
        $ diff -u before after
        $
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
        diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
      
      Cc: Brijesh Singh <brijesh.singh@amd.com>
      Cc: Jianyong Wu <jianyong.wu@arm.com>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Nathan Tempelman <natet@google.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steve Rutherford <srutherford@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0d943d5f
    • Jiri Olsa's avatar
      perf tools: Fix dynamic libbpf link · ad1237c3
      Jiri Olsa authored
      Justin reported broken build with LIBBPF_DYNAMIC=1.
      
      When linking libbpf dynamically we need to use perf's
      hashmap object, because it's not exported in libbpf.so
      (only in libbpf.a).
      
      Following build is now passing:
      
        $ make LIBBPF_DYNAMIC=1
          BUILD:   Doing 'make -j8' parallel build
          ...
        $ ldd perf | grep libbpf
              libbpf.so.0 => /lib64/libbpf.so.0 (0x00007fa7630db000)
      
      Fixes: eee19501 ("perf tools: Grab a copy of libbpf's hashmap")
      Reported-by: default avatarJustin M. Forbes <jforbes@redhat.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210508205020.617984-1-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ad1237c3
    • Dmitry Koshelev's avatar
      perf session: Fix swapping of cpu_map and stat_config records · a11c9a6e
      Dmitry Koshelev authored
      'data' field in perf_record_cpu_map_data struct is 16-bit
      wide and so should be swapped using bswap_16().
      
      'nr' field in perf_record_stat_config struct should be
      swapped before being used for size calculation.
      Signed-off-by: default avatarDmitry Koshelev <karaghiozis@gmail.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210506131244.13328-1-karaghiozis@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a11c9a6e
    • Ian Rogers's avatar
      perf jevents: Silence warning for ArchStd files · 7aa3c9ea
      Ian Rogers authored
      JSON files in the level 1 directory are used for ArchStd events (see
      preprocess_arch_std_files), as such they shouldn't be warned about.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210506225640.1461000-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7aa3c9ea
    • Namhyung Kim's avatar
      perf record: Disallow -c and -F option at the same time · e8c11676
      Namhyung Kim authored
      It's confusing which one is effective when the both options are given.
      The current code happens to use -c in this case but users might not be
      aware of it.  We can change it to complain about that instead of relying
      on the implicit priority.
      
      Before:
      
        $ perf record -c 111111 -F 99 true
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.031 MB perf.data (8 samples) ]
      
        $ perf evlist -F
        cycles: sample_period=111111
        $
      
      After:
        $ perf record -c 111111 -F 99 true
        cannot set frequency and period at the same time
        $
      
      So this change can break existing usages, but I think it's rare to have
      both options and it'd be better changing them.
      Suggested-by: default avatarAlexey Alexandrov <aalexand@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210402094020.28164-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e8c11676
    • Arnaldo Carvalho de Melo's avatar
      tools arch x86: Sync the msr-index.h copy with the kernel sources · b3172585
      Arnaldo Carvalho de Melo authored
      To pick up the changes from these csets:
      
        d0946a88 ("perf/x86/intel: Hybrid PMU support for perf capabilities")
      
      That cause no changes to tooling as it isn't adding any new MSR, just
      some capabilities for a pre-existing one:
      
        $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > before
        $ cp arch/x86/include/asm/msr-index.h tools/arch/x86/include/asm/msr-index.h
        $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > after
        $ diff -u before after
        $
      
      Just silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h' differs from latest version at 'arch/x86/include/asm/msr-index.h'
        diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
      
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b3172585
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync drm/i915_drm.h with the kernel sources · 0fdee797
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        b5b6f6a6 ("drm/i915/gem: Drop legacy execbuffer support (v2)")
      
      That don't result in any change in tooling as this is just adding a
      comment.
      
      Only silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/drm/i915_drm.h' differs from latest version at 'include/uapi/drm/i915_drm.h'
        diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
      
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Jason Ekstrand <jason@jlekstrand.net>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0fdee797
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Update tools's copy of drm.h headers · a3bc4ffe
      Arnaldo Carvalho de Melo authored
      Picking the changes from:
      
        b603e810 ("drm/uapi: document kernel capabilities")
      
      Doesn't result in any tooling changes:
      
        $ tools/perf/trace/beauty/drm_ioctl.sh  > before
        $ cp include/uapi/drm/drm.h tools/include/uapi/drm/drm.h
        $ tools/perf/trace/beauty/drm_ioctl.sh  > after
        $ diff -u before after
      
      Silencing these perf build warnings:
      
        Warning: Kernel ABI header at 'tools/include/uapi/drm/drm.h' differs from latest version at 'include/uapi/drm/drm.h'
        diff -u tools/include/uapi/drm/drm.h include/uapi/drm/drm.h
      
      Cc: Simon Ser <contact@emersion.fr>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a3bc4ffe
  10. 09 May, 2021 4 commits
    • Linus Torvalds's avatar
      Linux 5.13-rc1 · 6efb943b
      Linus Torvalds authored
      6efb943b
    • Linus Torvalds's avatar
      fbmem: fix horribly incorrect placement of __maybe_unused · 6dae40ae
      Linus Torvalds authored
      Commit b9d79e4c ("fbmem: Mark proc_fb_seq_ops as __maybe_unused")
      places the '__maybe_unused' in an entirely incorrect location between
      the "struct" keyword and the structure name.
      
      It's a wonder that gcc accepts that silently, but clang quite reasonably
      warns about it:
      
          drivers/video/fbdev/core/fbmem.c:736:21: warning: attribute declaration must precede definition [-Wignored-attributes]
          static const struct __maybe_unused seq_operations proc_fb_seq_ops = {
                              ^
      
      Fix it.
      
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6dae40ae
    • Linus Torvalds's avatar
      Merge tag 'drm-next-2021-05-10' of git://anongit.freedesktop.org/drm/drm · efc58a96
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Bit later than usual, I queued them all up on Friday then promptly
        forgot to write the pull request email. This is mainly amdgpu fixes,
        with some radeon/msm/fbdev and one i915 gvt fix thrown in.
      
        amdgpu:
         - MPO hang workaround
         - Fix for concurrent VM flushes on vega/navi
         - dcefclk is not adjustable on navi1x and newer
         - MST HPD debugfs fix
         - Suspend/resumes fixes
         - Register VGA clients late in case driver fails to load
         - Fix GEM leak in user framebuffer create
         - Add support for polaris12 with 32 bit memory interface
         - Fix duplicate cursor issue when using overlay
         - Fix corruption with tiled surfaces on VCN3
         - Add BO size and stride check to fix BO size verification
      
        radeon:
         - Fix off-by-one in power state parsing
         - Fix possible memory leak in power state parsing
      
        msm:
         - NULL ptr dereference fix
      
        fbdev:
         - procfs disabled warning fix
      
        i915:
         - gvt: Fix a possible division by zero in vgpu display rate
           calculation"
      
      * tag 'drm-next-2021-05-10' of git://anongit.freedesktop.org/drm/drm:
        drm/amdgpu: Use device specific BO size & stride check.
        drm/amdgpu: Init GFX10_ADDR_CONFIG for VCN v3 in DPG mode.
        drm/amd/pm: initialize variable
        drm/radeon: Avoid power table parsing memory leaks
        drm/radeon: Fix off-by-one power_state index heap overwrite
        drm/amd/display: Fix two cursor duplication when using overlay
        drm/amdgpu: add new MC firmware for Polaris12 32bit ASIC
        fbmem: Mark proc_fb_seq_ops as __maybe_unused
        drm/msm/dpu: Delete bonkers code
        drm/i915/gvt: Prevent divided by zero when calculating refresh rate
        amdgpu: fix GEM obj leak in amdgpu_display_user_framebuffer_create
        drm/amdgpu: Register VGA clients after init can no longer fail
        drm/amdgpu: Handling of amdgpu_device_resume return value for graceful teardown
        drm/amdgpu: fix r initial values
        drm/amd/display: fix wrong statement in mst hpd debugfs
        amdgpu/pm: set pp_dpm_dcefclk to readonly on NAVI10 and newer gpus
        amdgpu/pm: Prevent force of DCEFCLK on NAVI10 and SIENNA_CICHLID
        drm/amdgpu: fix concurrent VM flushes on Vega/Navi v2
        drm/amd/display: Reject non-zero src_y and src_x for video planes
      efc58a96
    • Linus Torvalds's avatar
      Merge tag 'block-5.13-2021-05-09' of git://git.kernel.dk/linux-block · 506c3079
      Linus Torvalds authored
      Pull block fix from Jens Axboe:
       "Turns out the bio max size change still has issues, so let's get it
        reverted for 5.13-rc1. We'll shake out the issues there and defer it
        to 5.14 instead"
      
      * tag 'block-5.13-2021-05-09' of git://git.kernel.dk/linux-block:
        Revert "bio: limit bio max size"
      506c3079