1. 14 Feb, 2022 12 commits
    • Kees Cook's avatar
      fortify: Add Clang support · 281d0c96
      Kees Cook authored
      Enable FORTIFY_SOURCE support for Clang:
      
      Use the new __pass_object_size and __overloadable attributes so that
      Clang will have appropriate visibility into argument sizes such that
      __builtin_object_size(p, 1) will behave correctly. Additional details
      available here:
          https://github.com/llvm/llvm-project/issues/53516
          https://github.com/ClangBuiltLinux/linux/issues/1401
      
      A bug with __builtin_constant_p() of globally defined variables was
      fixed in Clang 13 (and backported to 12.0.1), so FORTIFY support must
      depend on that version or later. Additional details here:
          https://bugs.llvm.org/show_bug.cgi?id=41459
          commit a52f8a59 ("fortify: Explicitly disable Clang support")
      
      A bug with Clang's -mregparm=3 and -m32 makes some builtins unusable,
      so removing -ffreestanding (to gain the needed libcall optimizations
      with Clang) cannot be done. Without the libcall optimizations, Clang
      cannot provide appropriate FORTIFY coverage, so it must be disabled
      for CONFIG_X86_32. Additional details here;
          https://github.com/llvm/llvm-project/issues/53645
      
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: George Burgess IV <gbiv@google.com>
      Cc: llvm@lists.linux.dev
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20220208225350.1331628-9-keescook@chromium.org
      281d0c96
    • Kees Cook's avatar
      fortify: Make sure strlen() may still be used as a constant expression · 67ebc3ab
      Kees Cook authored
      In preparation for enabling Clang FORTIFY_SOURCE support, redefine
      strlen() as a macro that tests for being a constant expression
      so that strlen() can still be used in static initializers, which is
      lost when adding __pass_object_size and __overloadable.
      
      An example of this usage can be seen here:
      	https://lore.kernel.org/all/202201252321.dRmWZ8wW-lkp@intel.com/
      
      Notably, this constant expression feature of strlen() is not available
      for architectures that build with -ffreestanding. This means the kernel
      currently does not universally expect strlen() to be used this way, but
      since there _are_ some build configurations that depend on it, retain
      the characteristic for Clang FORTIFY_SOURCE builds too.
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20220208225350.1331628-8-keescook@chromium.org
      67ebc3ab
    • Kees Cook's avatar
      fortify: Use __diagnose_as() for better diagnostic coverage · 92df138a
      Kees Cook authored
      In preparation for using Clang's __pass_object_size, add __diagnose_as()
      attributes to mark the functions as being the same as the indicated
      builtins. When __daignose_as() is available, Clang will have a more
      complete ability to apply its own diagnostic analysis to callers of these
      functions, as if they were the builtins themselves. Without __diagnose_as,
      Clang's compile time diagnostic messages won't be as precise as they
      could be, but at least users of older toolchains will still benefit from
      having fortified routines.
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20220208225350.1331628-7-keescook@chromium.org
      92df138a
    • Kees Cook's avatar
      fortify: Make pointer arguments const · 0a2b782a
      Kees Cook authored
      In preparation for using Clang's __pass_object_size attribute, make all
      the pointer arguments to the fortified string functions const. Nothing
      was changing their values anyway, so this added requirement (needed by
      __pass_object_size) requires no code changes and has no impact on
      the binary instruction output.
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20220208225350.1331628-6-keescook@chromium.org
      0a2b782a
    • Kees Cook's avatar
      Compiler Attributes: Add __diagnose_as for Clang · 1c7f4e5c
      Kees Cook authored
      Clang will perform various compile-time diagnostics on uses of various
      functions (e.g. simple bounds-checking on strcpy(), etc). These
      diagnostics can be assigned to other functions (for example, new
      implementations of the string functions under CONFIG_FORTIFY_SOURCE)
      using the "diagnose_as_builtin" attribute. This allows those functions
      to retain their compile-time diagnostic warnings.
      
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: llvm@lists.linux.dev
      Reviewed-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20220208225350.1331628-5-keescook@chromium.org
      1c7f4e5c
    • Kees Cook's avatar
      Compiler Attributes: Add __overloadable for Clang · d694dbae
      Kees Cook authored
      In order for FORTIFY_SOURCE to use __pass_object_size on an "extern
      inline" function, as all the fortified string functions are, the functions
      must be marked as being overloadable (i.e. different prototypes due
      to the implicitly injected object size arguments). This allows the
      __pass_object_size versions to take precedence.
      
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: llvm@lists.linux.dev
      Reviewed-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20220208225350.1331628-4-keescook@chromium.org
      d694dbae
    • Kees Cook's avatar
      Compiler Attributes: Add __pass_object_size for Clang · f0202b8c
      Kees Cook authored
      In order to gain greater visibility to type information when using
      __builtin_object_size(), Clang has a function attribute "pass_object_size"
      that will make size information available for marked arguments in
      a function by way of implicit additional function arguments that are
      then wired up the __builtin_object_size().
      
      This is needed to implement FORTIFY_SOURCE in Clang, as a workaround
      to Clang's __builtin_object_size() having limited visibility[1] into types
      across function calls (even inlines).
      
      This attribute has an additional benefit that it can be used even on
      non-inline functions to gain argument size information.
      
      [1] https://github.com/llvm/llvm-project/issues/53516
      
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: llvm@lists.linux.dev
      Reviewed-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20220208225350.1331628-3-keescook@chromium.org
      f0202b8c
    • Kees Cook's avatar
      fortify: Replace open-coded __gnu_inline attribute · f3611431
      Kees Cook authored
      Replace open-coded gnu_inline attribute with the normal kernel
      convention for attributes: __gnu_inline
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20220208225350.1331628-2-keescook@chromium.org
      f3611431
    • Kees Cook's avatar
      fortify: Update compile-time tests for Clang 14 · 818ab43f
      Kees Cook authored
      Clang 14 introduces support for compiletime_assert(). Update the
      compile-time warning regex to catch Clang's variant of the warning text
      in preparation for Clang supporting CONFIG_FORTIFY_SOURCE.
      
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: linux-hardening@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      Link: https://lore.kernel.org/lkml/YfbtQKtpyAM1hHiC@dev-arch.archlinux-ax161Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      818ab43f
    • Kees Cook's avatar
      fortify: Detect struct member overflows in memset() at compile-time · 28e77cc1
      Kees Cook authored
      As done for memcpy(), also update memset() to use the same tightened
      compile-time bounds checking under CONFIG_FORTIFY_SOURCE.
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      28e77cc1
    • Kees Cook's avatar
      fortify: Detect struct member overflows in memmove() at compile-time · 938a000e
      Kees Cook authored
      As done for memcpy(), also update memmove() to use the same tightened
      compile-time checks under CONFIG_FORTIFY_SOURCE.
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      938a000e
    • Kees Cook's avatar
      fortify: Detect struct member overflows in memcpy() at compile-time · f68f2ff9
      Kees Cook authored
      memcpy() is dead; long live memcpy()
      
      tl;dr: In order to eliminate a large class of common buffer overflow
      flaws that continue to persist in the kernel, have memcpy() (under
      CONFIG_FORTIFY_SOURCE) perform bounds checking of the destination struct
      member when they have a known size. This would have caught all of the
      memcpy()-related buffer write overflow flaws identified in at least the
      last three years.
      
      Background and analysis:
      
      While stack-based buffer overflow flaws are largely mitigated by stack
      canaries (and similar) features, heap-based buffer overflow flaws continue
      to regularly appear in the kernel. Many classes of heap buffer overflows
      are mitigated by FORTIFY_SOURCE when using the strcpy() family of
      functions, but a significant number remain exposed through the memcpy()
      family of functions.
      
      At its core, FORTIFY_SOURCE uses the compiler's __builtin_object_size()
      internal[0] to determine the available size at a target address based on
      the compile-time known structure layout details. It operates in two
      modes: outer bounds (0) and inner bounds (1). In mode 0, the size of the
      enclosing structure is used. In mode 1, the size of the specific field
      is used. For example:
      
      	struct object {
      		u16 scalar1;	/* 2 bytes */
      		char array[6];	/* 6 bytes */
      		u64 scalar2;	/* 8 bytes */
      		u32 scalar3;	/* 4 bytes */
      		u32 scalar4;	/* 4 bytes */
      	} instance;
      
      __builtin_object_size(instance.array, 0) == 22, since the remaining size
      of the enclosing structure starting from "array" is 22 bytes (6 + 8 +
      4 + 4).
      
      __builtin_object_size(instance.array, 1) == 6, since the remaining size
      of the specific field "array" is 6 bytes.
      
      The initial implementation of FORTIFY_SOURCE used mode 0 because there
      were many cases of both strcpy() and memcpy() functions being used to
      write (or read) across multiple fields in a structure. For example,
      it would catch this, which is writing 2 bytes beyond the end of
      "instance":
      
      	memcpy(&instance.array, data, 25);
      
      While this didn't protect against overwriting adjacent fields in a given
      structure, it would at least stop overflows from reaching beyond the
      end of the structure into neighboring memory, and provided a meaningful
      mitigation of a subset of buffer overflow flaws. However, many desirable
      targets remain within the enclosing structure (for example function
      pointers).
      
      As it happened, there were very few cases of strcpy() family functions
      intentionally writing beyond the end of a string buffer. Once all known
      cases were removed from the kernel, the strcpy() family was tightened[1]
      to use mode 1, providing greater mitigation coverage.
      
      What remains is switching memcpy() to mode 1 as well, but making the
      switch is much more difficult because of how frustrating it can be to
      find existing "normal" uses of memcpy() that expect to write (or read)
      across multiple fields. The root cause of the problem is that the C
      language lacks a common pattern to indicate the intent of an author's
      use of memcpy(), and is further complicated by the available compile-time
      and run-time mitigation behaviors.
      
      The FORTIFY_SOURCE mitigation comes in two halves: the compile-time half,
      when both the buffer size _and_ the length of the copy is known, and the
      run-time half, when only the buffer size is known. If neither size is
      known, there is no bounds checking possible. At compile-time when the
      compiler sees that a length will always exceed a known buffer size,
      a warning can be deterministically emitted. For the run-time half,
      the length is tested against the known size of the buffer, and the
      overflowing operation is detected. (The performance overhead for these
      tests is virtually zero.)
      
      It is relatively easy to find compile-time false-positives since a warning
      is always generated. Fixing the false positives, however, can be very
      time-consuming as there are hundreds of instances. While it's possible
      some over-read conditions could lead to kernel memory exposures, the bulk
      of the risk comes from the run-time flaws where the length of a write
      may end up being attacker-controlled and lead to an overflow.
      
      Many of the compile-time false-positives take a form similar to this:
      
      	memcpy(&instance.scalar2, data, sizeof(instance.scalar2) +
      					sizeof(instance.scalar3));
      
      and the run-time ones are similar, but lack a constant expression for the
      size of the copy:
      
      	memcpy(instance.array, data, length);
      
      The former is meant to cover multiple fields (though its style has been
      frowned upon more recently), but has been technically legal. Both lack
      any expressivity in the C language about the author's _intent_ in a way
      that a compiler can check when the length isn't known at compile time.
      A comment doesn't work well because what's needed is something a compiler
      can directly reason about. Is a given memcpy() call expected to overflow
      into neighbors? Is it not? By using the new struct_group() macro, this
      intent can be much more easily encoded.
      
      It is not as easy to find the run-time false-positives since the code path
      to exercise a seemingly out-of-bounds condition that is actually expected
      may not be trivially reachable. Tightening the restrictions to block an
      operation for a false positive will either potentially create a greater
      flaw (if a copy is truncated by the mitigation), or destabilize the kernel
      (e.g. with a BUG()), making things completely useless for the end user.
      
      As a result, tightening the memcpy() restriction (when there is a
      reasonable level of uncertainty of the number of false positives), needs
      to first WARN() with no truncation. (Though any sufficiently paranoid
      end-user can always opt to set the panic_on_warn=1 sysctl.) Once enough
      development time has passed, the mitigation can be further intensified.
      (Note that this patch is only the compile-time checking step, which is
      a prerequisite to doing run-time checking, which will come in future
      patches.)
      
      Given the potential frustrations of weeding out all the false positives
      when tightening the run-time checks, it is reasonable to wonder if these
      changes would actually add meaningful protection. Looking at just the
      last three years, there are 23 identified flaws with a CVE that mention
      "buffer overflow", and 11 are memcpy()-related buffer overflows.
      
      (For the remaining 12: 7 are array index overflows that would be
      mitigated by systems built with CONFIG_UBSAN_BOUNDS=y: CVE-2019-0145,
      CVE-2019-14835, CVE-2019-14896, CVE-2019-14897, CVE-2019-14901,
      CVE-2019-17666, CVE-2021-28952. 2 are miscalculated allocation
      sizes which could be mitigated with memory tagging: CVE-2019-16746,
      CVE-2019-2181. 1 is an iovec buffer bug maybe mitigated by memory tagging:
      CVE-2020-10742. 1 is a type confusion bug mitigated by stack canaries:
      CVE-2020-10942. 1 is a string handling logic bug with no mitigation I'm
      aware of: CVE-2021-28972.)
      
      At my last count on an x86_64 allmodconfig build, there are 35,294
      calls to memcpy(). With callers instrumented to report all places
      where the buffer size is known but the length remains unknown (i.e. a
      run-time bounds check is added), we can count how many new run-time
      bounds checks are added when the destination and source arguments of
      memcpy() are changed to use "mode 1" bounds checking: 1,276. This means
      for the future run-time checking, there is a worst-case upper bounds
      of 3.6% false positives to fix. In addition, there were around 150 new
      compile-time warnings to evaluate and fix (which have now been fixed).
      
      With this instrumentation it's also possible to compare the places where
      the known 11 memcpy() flaw overflows manifested against the resulting
      list of potential new run-time bounds checks, as a measure of potential
      efficacy of the tightened mitigation. Much to my surprise, horror, and
      delight, all 11 flaws would have been detected by the newly added run-time
      bounds checks, making this a distinctly clear mitigation improvement: 100%
      coverage for known memcpy() flaws, with a possible 2 orders of magnitude
      gain in coverage over existing but undiscovered run-time dynamic length
      flaws (i.e. 1265 newly covered sites in addition to the 11 known), against
      only <4% of all memcpy() callers maybe gaining a false positive run-time
      check, with only about 150 new compile-time instances needing evaluation.
      
      Specifically these would have been mitigated:
      CVE-2020-24490 https://git.kernel.org/linus/a2ec905d1e160a33b2e210e45ad30445ef26ce0e
      CVE-2020-12654 https://git.kernel.org/linus/3a9b153c5591548612c3955c9600a98150c81875
      CVE-2020-12653 https://git.kernel.org/linus/b70261a288ea4d2f4ac7cd04be08a9f0f2de4f4d
      CVE-2019-14895 https://git.kernel.org/linus/3d94a4a8373bf5f45cf5f939e88b8354dbf2311b
      CVE-2019-14816 https://git.kernel.org/linus/7caac62ed598a196d6ddf8d9c121e12e082cac3a
      CVE-2019-14815 https://git.kernel.org/linus/7caac62ed598a196d6ddf8d9c121e12e082cac3a
      CVE-2019-14814 https://git.kernel.org/linus/7caac62ed598a196d6ddf8d9c121e12e082cac3a
      CVE-2019-10126 https://git.kernel.org/linus/69ae4f6aac1578575126319d3f55550e7e440449
      CVE-2019-9500  https://git.kernel.org/linus/1b5e2423164b3670e8bc9174e4762d297990deff
      no-CVE-yet     https://git.kernel.org/linus/130f634da1af649205f4a3dd86cbe5c126b57914
      no-CVE-yet     https://git.kernel.org/linus/d10a87a3535cce2b890897914f5d0d83df669c63
      
      To accelerate the review of potential run-time false positives, it's
      also worth noting that it is possible to partially automate checking
      by examining the memcpy() buffer argument to check for the destination
      struct member having a neighboring array member. It is reasonable to
      expect that the vast majority of run-time false positives would look like
      the already evaluated and fixed compile-time false positives, where the
      most common pattern is neighboring arrays. (And, FWIW, many of the
      compile-time fixes were actual bugs, so it is reasonable to assume we'll
      have similar cases of actual bugs getting fixed for run-time checks.)
      
      Implementation:
      
      Tighten the memcpy() destination buffer size checking to use the actual
      ("mode 1") target buffer size as the bounds check instead of their
      enclosing structure's ("mode 0") size. Use a common inline for memcpy()
      (and memmove() in a following patch), since all the tests are the
      same. All new cross-field memcpy() uses must use the struct_group() macro
      or similar to target a specific range of fields, so that FORTIFY_SOURCE
      can reason about the size and safety of the copy.
      
      For now, cross-member "mode 1" _read_ detection at compile-time will be
      limited to W=1 builds, since it is, unfortunately, very common. As the
      priority is solving write overflows, read overflows will be part of a
      future phase (and can be fixed in parallel, for anyone wanting to look
      at W=1 build output).
      
      For run-time, the "mode 0" size checking and mitigation is left unchanged,
      with "mode 1" to be added in stages. In this patch, no new run-time
      checks are added. Future patches will first bounds-check writes,
      and only perform a WARN() for now. This way any missed run-time false
      positives can be flushed out over the coming several development cycles,
      but system builders who have tested their workloads to be WARN()-free
      can enable the panic_on_warn=1 sysctl to immediately gain a mitigation
      against this class of buffer overflows. Once that is under way, run-time
      bounds-checking of reads can be similarly enabled.
      
      Related classes of flaws that will remain unmitigated:
      
      - memcpy() with flexible array structures, as the compiler does not
        currently have visibility into the size of the trailing flexible
        array. These can be fixed in the future by refactoring such cases
        to use a new set of flexible array structure helpers to perform the
        common serialization/deserialization code patterns doing allocation
        and/or copying.
      
      - memcpy() with raw pointers (e.g. void *, char *, etc), or otherwise
        having their buffer size unknown at compile time, have no good
        mitigation beyond memory tagging (and even that would only protect
        against inter-object overflow, not intra-object neighboring field
        overflows), or refactoring. Some kind of "fat pointer" solution is
        likely needed to gain proper size-of-buffer awareness. (e.g. see
        struct membuf)
      
      - type confusion where a higher level type's allocation size does
        not match the resulting cast type eventually passed to a deeper
        memcpy() call where the compiler cannot see the true type. In
        theory, greater static analysis could catch these, and the use
        of -Warray-bounds will help find some of these.
      
      [0] https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
      [1] https://git.kernel.org/linus/6a39e62abbafd1d58d1722f40c7d26ef379c6a2fSigned-off-by: default avatarKees Cook <keescook@chromium.org>
      f68f2ff9
  2. 06 Feb, 2022 19 commits
    • Linus Torvalds's avatar
      Linux 5.17-rc3 · dfd42fac
      Linus Torvalds authored
      dfd42fac
    • Linus Torvalds's avatar
      Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 · d8ad2ce8
      Linus Torvalds authored
      Pull ext4 fixes from Ted Ts'o:
       "Various bug fixes for ext4 fast commit and inline data handling.
      
        Also fix regression introduced as part of moving to the new mount API"
      
      * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
        fs/ext4: fix comments mentioning i_mutex
        ext4: fix incorrect type issue during replay_del_range
        jbd2: fix kernel-doc descriptions for jbd2_journal_shrink_{scan,count}()
        ext4: fix potential NULL pointer dereference in ext4_fill_super()
        jbd2: refactor wait logic for transaction updates into a common function
        jbd2: cleanup unused functions declarations from jbd2.h
        ext4: fix error handling in ext4_fc_record_modified_inode()
        ext4: remove redundant max inline_size check in ext4_da_write_inline_data_begin()
        ext4: fix error handling in ext4_restore_inline_data()
        ext4: fast commit may miss file actions
        ext4: fast commit may not fallback for ineligible commit
        ext4: modify the logic of ext4_mb_new_blocks_simple
        ext4: prevent used blocks from being allocated during fast commit replay
      d8ad2ce8
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.17-2022-02-06' of... · 18118a42
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.17-2022-02-06' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Fix display of grouped aliased events in 'perf stat'.
      
       - Add missing branch_sample_type to perf_event_attr__fprintf().
      
       - Apply correct label to user/kernel symbols in branch mode.
      
       - Fix 'perf ftrace' system_wide tracing, it has to be set before
         creating the maps.
      
       - Return error if procfs isn't mounted for PID namespaces when
         synthesizing records for pre-existing processes.
      
       - Set error stream of objdump process for 'perf annotate' TUI, to avoid
         garbling the screen.
      
       - Add missing arm64 support to perf_mmap__read_self(), the kernel part
         got into 5.17.
      
       - Check for NULL pointer before dereference writing debug info about a
         sample.
      
       - Update UAPI copies for asound, perf_event, prctl and kvm headers.
      
       - Fix a typo in bpf_counter_cgroup.c.
      
      * tag 'perf-tools-fixes-for-v5.17-2022-02-06' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf ftrace: system_wide collection is not effective by default
        libperf: Add arm64 support to perf_mmap__read_self()
        tools include UAPI: Sync sound/asound.h copy with the kernel sources
        perf stat: Fix display of grouped aliased events
        perf tools: Apply correct label to user/kernel symbols in branch mode
        perf bpf: Fix a typo in bpf_counter_cgroup.c
        perf synthetic-events: Return error if procfs isn't mounted for PID namespaces
        perf session: Check for NULL pointer before dereference
        perf annotate: Set error stream of objdump process for TUI
        perf tools: Add missing branch_sample_type to perf_event_attr__fprintf()
        tools headers UAPI: Sync linux/kvm.h with the kernel sources
        tools headers UAPI: Sync linux/prctl.h with the kernel sources
        perf beauty: Make the prctl arg regexp more strict to cope with PR_SET_VMA
        tools headers cpufeatures: Sync with the kernel sources
        tools headers UAPI: Sync linux/perf_event.h with the kernel sources
        tools include UAPI: Sync sound/asound.h copy with the kernel sources
      18118a42
    • Linus Torvalds's avatar
      Merge tag 'perf_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · c3bf8a14
      Linus Torvalds authored
      Pull perf fixes from Borislav Petkov:
      
       - Intel/PT: filters could crash the kernel
      
       - Intel: default disable the PMU for SMM, some new-ish EFI firmware has
         started using CPL3 and the PMU CPL filters don't discriminate against
         SMM, meaning that CPL3 (userspace only) events now also count EFI/SMM
         cycles.
      
       - Fixup for perf_event_attr::sig_data
      
      * tag 'perf_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        perf/x86/intel/pt: Fix crash with stop filters in single-range mode
        perf: uapi: Document perf_event_attr::sig_data truncation on 32 bit architectures
        selftests/perf_events: Test modification of perf_event_attr::sig_data
        perf: Copy perf_event_attr::sig_data on modification
        x86/perf: Default set FREEZE_ON_SMI for all
      c3bf8a14
    • Linus Torvalds's avatar
      Merge tag 'objtool_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · aeabe1e0
      Linus Torvalds authored
      Pull objtool fix from Borislav Petkov:
       "Fix a potential truncated string warning triggered by gcc12"
      
      * tag 'objtool_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        objtool: Fix truncated string warning
      aeabe1e0
    • Linus Torvalds's avatar
      Merge tag 'irq_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · b72e40b1
      Linus Torvalds authored
      Pull irq fix from Borislav Petkov:
       "Remove a bogus warning introduced by the recent PCI MSI irq affinity
        overhaul"
      
      * tag 'irq_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        PCI/MSI: Remove bogus warning in pci_irq_get_affinity()
      b72e40b1
    • Linus Torvalds's avatar
      Merge tag 'edac_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras · 898b5841
      Linus Torvalds authored
      Pull EDAC fixes from Borislav Petkov:
       "Fix altera and xgene EDAC drivers to propagate the correct error code
        from platform_get_irq() so that deferred probing still works"
      
      * tag 'edac_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras:
        EDAC/xgene: Fix deferred probing
        EDAC/altera: Fix deferred probing
      898b5841
    • Changbin Du's avatar
      perf ftrace: system_wide collection is not effective by default · fceb6212
      Changbin Du authored
      The ftrace.target.system_wide must be set before invoking
      evlist__create_maps(), otherwise it has no effect.
      
      Fixes: 53be5028 ("perf ftrace: Add 'latency' subcommand")
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220127132010.4836-1-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fceb6212
    • Rob Herring's avatar
      libperf: Add arm64 support to perf_mmap__read_self() · 407eb43a
      Rob Herring authored
      Add the arm64 variants for read_perf_counter() and read_timestamp().
      Unfortunately the counter number is encoded into the instruction, so the
      code is a bit verbose to enumerate all possible counters.
      Tested-by: default avatarMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Tested-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Link: https://lore.kernel.org/r/20220201214056.702854-1-robh@kernel.org
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-perf-users@vger.kernel.org
      407eb43a
    • Arnaldo Carvalho de Melo's avatar
      tools include UAPI: Sync sound/asound.h copy with the kernel sources · 4f249273
      Arnaldo Carvalho de Melo authored
      Picking the changes from:
      
        06feec60 ("ASoC: hdmi-codec: Fix OOB memory accesses")
      
      Which entails no changes in the tooling side as it doesn't introduce new
      SNDRV_PCM_IOCTL_ ioctls.
      
      To silence this perf tools build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/sound/asound.h' differs from latest version at 'include/uapi/sound/asound.h'
        diff -u tools/include/uapi/sound/asound.h include/uapi/sound/asound.h
      
      Cc: Dmitry Osipenko <digetx@gmail.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Takashi Iwai <tiwai@suse.de>
      Link: https://lore.kernel.org/lkml/Yf+6OT+2eMrYDEeX@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4f249273
    • Ian Rogers's avatar
      perf stat: Fix display of grouped aliased events · b2b1aa73
      Ian Rogers authored
      An event may have a number of uncore aliases that when added to the
      evlist are consecutive.
      
      If there are multiple uncore events in a group then
      parse_events__set_leader_for_uncore_aliase will reorder the evlist so
      that events on the same PMU are adjacent.
      
      The collect_all_aliases function assumes that aliases are in blocks so
      that only the first counter is printed and all others are marked merged.
      
      The reordering for groups breaks the assumption and so all counts are
      printed.
      
      This change removes the assumption from collect_all_aliases
      that the events are in blocks and instead processes the entire evlist.
      
      Before:
      
        ```
        $ perf stat -e '{UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE,UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE},duration_time' -a -A -- sleep 1
      
         Performance counter stats for 'system wide':
      
        CPU0                  256,866      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 494,413      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      967      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,738      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  285,161      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 429,920      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,443      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  310,753      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 416,657      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,231      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,573      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  416,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 405,966      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,481      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,447      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  312,911      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 408,154      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,086      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,380      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  333,994      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 370,349      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,287      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,335      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  188,107      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 302,423      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      701      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,070      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  307,221      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 383,642      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,036      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,158      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  318,479      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 821,545      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,028      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,550      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  227,618      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 372,272      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      903      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  376,783      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 419,827      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,406      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,453      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  286,583      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 429,956      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      999      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,436      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  313,867      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 370,159      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,114      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 409,111      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,399      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,684      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  365,828      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 376,037      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,378      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,411      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  382,456      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 621,743      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,232      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,316      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 385,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,176      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,268      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  373,588      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 386,163      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,394      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,464      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  381,206      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 546,891      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,266      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,712      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  221,176      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 392,069      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      831      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  355,401      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 705,595      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,235      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,216      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  371,436      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 428,103      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,306      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,442      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  384,352      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 504,200      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,468      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,860      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  228,856      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 287,976      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      832      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,060      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  215,121      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 334,162      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      681      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,026      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  296,179      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 436,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,084      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,525      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  262,296      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 416,573      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      986      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,533      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  285,852      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 359,842      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,073      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,326      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  303,379      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 367,222      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,008      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,156      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  273,487      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 425,449      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      932      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,367      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  297,596      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 414,793      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,140      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,601      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,365      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 360,422      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,342      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  327,196      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 580,858      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,122      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,014      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  296,564      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 452,817      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,087      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,694      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  375,002      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 389,393      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,478      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,540      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  365,213      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 594,685      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,401      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,222      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0            1,000,749,060 ns   duration_time
      
               1.000749060 seconds time elapsed
        ```
      
      After:
      
        ```
         Performance counter stats for 'system wide':
      
        CPU0               20,547,434      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36              45,202,862      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                   82,001      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                 159,688      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0            1,000,464,828 ns   duration_time
      
               1.000464828 seconds time elapsed
        ```
      
      Fixes: 3cdc5c2c ("perf parse-events: Handle uncore event aliases in small groups properly")
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
      Cc: Asaf Yaffe <asaf.yaffe@intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vineet Singh <vineet.singh@intel.com>
      Cc: Zhengjun Xing <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220205010941.1065469-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b2b1aa73
    • German Gomez's avatar
      perf tools: Apply correct label to user/kernel symbols in branch mode · 05b5a9d6
      German Gomez authored
      In branch mode, the branch symbols were being displayed with incorrect
      cpumode labels. So fix this.
      
      For example, before:
        # perf record -b -a -- sleep 1
        # perf report -b
      
        Overhead  Command  Source Shared Object  Source Symbol               Target Symbol
           0.08%  swapper  [kernel.kallsyms]     [k] rcu_idle_enter          [k] cpuidle_enter_state
       ==> 0.08%  cmd0     [kernel.kallsyms]     [.] psi_group_change        [.] psi_group_change
           0.08%  cmd1     [kernel.kallsyms]     [k] psi_group_change        [k] psi_group_change
      
      After:
        # perf report -b
      
        Overhead  Command  Source Shared Object  Source Symbol               Target Symbol
           0.08%  swapper  [kernel.kallsyms]     [k] rcu_idle_enter          [k] cpuidle_enter_state
           0.08%  cmd0     [kernel.kallsyms]     [k] psi_group_change        [k] pei_group_change
           0.08%  cmd1     [kernel.kallsyms]     [k] psi_group_change        [k] psi_group_change
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarGerman Gomez <german.gomez@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20220126105927.3411216-1-german.gomez@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      05b5a9d6
    • Masanari Iida's avatar
      perf bpf: Fix a typo in bpf_counter_cgroup.c · a2887b9b
      Masanari Iida authored
      This patch fixes a spelling typo in error message.
      Signed-off-by: default avatarMasanari Iida <standby24x7@gmail.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20211225005558.503935-1-standby24x7@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a2887b9b
    • Leo Yan's avatar
      perf synthetic-events: Return error if procfs isn't mounted for PID namespaces · bc9c806e
      Leo Yan authored
      For perf recording, it retrieves process info by iterating nodes in proc
      fs.  If we run perf in a non-root PID namespace with command:
      
        # unshare --fork --pid perf record -e cycles -a -- test_program
      
      ... in this case, unshare command creates a child PID namespace and
      launches perf tool in it, but the issue is the proc fs is not mounted
      for the non-root PID namespace, this leads to the perf tool gathering
      process info from its parent PID namespace.
      
      We can use below command to observe the process nodes under proc fs:
      
        # unshare --pid --fork ls /proc
      1    137   1968  2128  3    342  48  62   78	     crypto	  kcore        net	      uptime
      10   138   2	 2142  30   35	 49  63   8	     devices	  keys	       pagetypeinfo   version
      11   139   20	 2143  304  36	 50  64   82	     device-tree  key-users    partitions     vmallocinfo
      12   14    2011  22    305  37	 51  65   83	     diskstats	  kmsg	       self	      vmstat
      128  140   2038  23    307  39	 52  656  84	     driver	  kpagecgroup  slabinfo       zoneinfo
      129  15    2074  24    309  4	 53  67   9	     execdomains  kpagecount   softirqs
      13   16    2094  241   31   40	 54  68   asound     fb		  kpageflags   stat
      130  164   2096  242   310  41	 55  69   buddyinfo  filesystems  loadavg      swaps
      131  17    2098  25    317  42	 56  70   bus	     fs		  locks        sys
      132  175   21	 26    32   43	 57  71   cgroups    interrupts   meminfo      sysrq-trigger
      133  179   2102  263   329  44	 58  75   cmdline    iomem	  misc	       sysvipc
      134  1875  2103  27    330  45	 59  76   config.gz  ioports	  modules      thread-self
      135  19    2117  29    333  46	 6   77   consoles   irq	  mounts       timer_list
      136  1941  2121  298   34   47	 60  773  cpuinfo    kallsyms	  mtd	       tty
      
      So it shows many existed tasks, since unshared command has not mounted
      the proc fs for the new created PID namespace, it still accesses the
      proc fs of the root PID namespace.  This leads to two prominent issues:
      
      - Firstly, PID values are mismatched between thread info and samples.
        The gathered thread info are coming from the proc fs of the root PID
        namespace, but samples record its PID from the child PID namespace.
      
      - The second issue is profiled program 'test_program' returns its forked
        PID number from the child PID namespace, perf tool wrongly uses this
        PID number to retrieve the process info via the proc fs of the root
        PID namespace.
      
      To avoid issues, we need to mount proc fs for the child PID namespace
      with the option '--mount-proc' when use unshare command:
      
        # unshare --fork --pid --mount-proc perf record -e cycles -a -- test_program
      
      Conversely, when the proc fs of the root PID namespace is used by child
      namespace, perf tool can detect the multiple PID levels and
      nsinfo__is_in_root_namespace() returns false, this patch reports error
      for this case:
      
        # unshare --fork --pid perf record -e cycles -a -- test_program
        Couldn't synthesize bpf events.
        Perf runs in non-root PID namespace but it tries to gather process info from its parent PID namespace.
        Please mount the proc file system properly, e.g. add the option '--mount-proc' for unshare command.
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/r/20211224124014.2492751-1-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bc9c806e
    • Ameer Hamza's avatar
      perf session: Check for NULL pointer before dereference · d792a7a9
      Ameer Hamza authored
      Move NULL pointer check before dereferencing the variable.
      
      Addresses-Coverity: 1497622 ("Derereference before null check")
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarAmeer Hamza <amhamza.mgc@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.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>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Link: https://lore.kernel.org/r/20220125121141.18347-1-amhamza.mgc@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d792a7a9
    • Namhyung Kim's avatar
      perf annotate: Set error stream of objdump process for TUI · a663520f
      Namhyung Kim authored
      The stderr should be set to a pipe when using TUI.  Otherwise it'd
      print to stdout and break TUI windows with an error message.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20220202070828.143303-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a663520f
    • Anshuman Khandual's avatar
      perf tools: Add missing branch_sample_type to perf_event_attr__fprintf() · ae65b443
      Anshuman Khandual authored
      This updates branch sample type with missing PERF_SAMPLE_BRANCH_TYPE_SAVE.
      Suggested-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/1643799443-15109-1-git-send-email-anshuman.khandual@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ae65b443
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/kvm.h with the kernel sources · b7b9825f
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        f6c6804c ("kvm: Move KVM_GET_XSAVE2 IOCTL definition at the end of kvm.h")
      
      That just rebuilds perf, as these patches don't add any new KVM ioctl to
      be harvested for the the 'perf trace' ioctl syscall argument
      beautifiers.
      
      This is also by now used by tools/testing/selftests/kvm/, a simple test
      build succeeded.
      
      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: Janosch Frank <frankja@linux.ibm.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Link: http://lore.kernel.org/lkml/Yf+4k5Fs5Q3HdSG9@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b7b9825f
    • Arnaldo Carvalho de Melo's avatar
      Merge remote-tracking branch 'torvalds/master' into perf/urgent · 9334030c
      Arnaldo Carvalho de Melo authored
      To check if more kernel API sync is needed and also to see if the perf
      build tests continue to pass.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9334030c
  3. 05 Feb, 2022 7 commits
    • Linus Torvalds's avatar
      Merge tag 'for-linus-5.17a-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · 90c9e950
      Linus Torvalds authored
      Pull xen fixes from Juergen Gross:
      
       - documentation fixes related to Xen
      
       - enable x2apic mode when available when running as hardware
         virtualized guest under Xen
      
       - cleanup and fix a corner case of vcpu enumeration when running a
         paravirtualized Xen guest
      
      * tag 'for-linus-5.17a-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        x86/Xen: streamline (and fix) PV CPU enumeration
        xen: update missing ioctl magic numers documentation
        Improve docs for IOCTL_GNTDEV_MAP_GRANT_REF
        xen: xenbus_dev.h: delete incorrect file name
        xen/x2apic: enable x2apic mode when supported for HVM
      90c9e950
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 5fdb2621
      Linus Torvalds authored
      Pull kvm fixes from Paolo Bonzini:
       "ARM:
      
         - A couple of fixes when handling an exception while a SError has
           been delivered
      
         - Workaround for Cortex-A510's single-step erratum
      
        RISC-V:
      
         - Make CY, TM, and IR counters accessible in VU mode
      
         - Fix SBI implementation version
      
        x86:
      
         - Report deprecation of x87 features in supported CPUID
      
         - Preparation for fixing an interrupt delivery race on AMD hardware
      
         - Sparse fix
      
        All except POWER and s390:
      
         - Rework guest entry code to correctly mark noinstr areas and fix
           vtime' accounting (for x86, this was already mostly correct but not
           entirely; for ARM, MIPS and RISC-V it wasn't)"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: x86: Use ERR_PTR_USR() to return -EFAULT as a __user pointer
        KVM: x86: Report deprecated x87 features in supported CPUID
        KVM: arm64: Workaround Cortex-A510's single-step and PAC trap errata
        KVM: arm64: Stop handle_exit() from handling HVC twice when an SError occurs
        KVM: arm64: Avoid consuming a stale esr value when SError occur
        RISC-V: KVM: Fix SBI implementation version
        RISC-V: KVM: make CY, TM, and IR counters accessible in VU mode
        kvm/riscv: rework guest entry logic
        kvm/arm64: rework guest entry logic
        kvm/x86: rework guest entry logic
        kvm/mips: rework guest entry logic
        kvm: add guest_state_{enter,exit}_irqoff()
        KVM: x86: Move delivery of non-APICv interrupt into vendor code
        kvm: Move KVM_GET_XSAVE2 IOCTL definition at the end of kvm.h
      5fdb2621
    • Linus Torvalds's avatar
      Merge tag 'xfs-5.17-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · fbc04bf0
      Linus Torvalds authored
      Pull xfs fixes from Darrick Wong:
       "I was auditing operations in XFS that clear file privileges, and
        realized that XFS' fallocate implementation drops suid/sgid but
        doesn't clear file capabilities the same way that file writes and
        reflink do.
      
        There are VFS helpers that do it correctly, so refactor XFS to use
        them. I also noticed that we weren't flushing the log at the correct
        point in the fallocate operation, so that's fixed too.
      
        Summary:
      
         - Fix fallocate so that it drops all file privileges when files are
           modified instead of open-coding that incompletely.
      
         - Fix fallocate to flush the log if the caller wanted synchronous
           file updates"
      
      * tag 'xfs-5.17-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: ensure log flush at the end of a synchronous fallocate call
        xfs: move xfs_update_prealloc_flags() to xfs_pnfs.c
        xfs: set prealloc flag in xfs_alloc_file_space()
        xfs: fallocate() should call file_modified()
        xfs: remove XFS_PREALLOC_SYNC
        xfs: reject crazy array sizes being fed to XFS_IOC_GETBMAP*
      fbc04bf0
    • Linus Torvalds's avatar
      Merge tag 'vfs-5.17-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · ea7b3e6d
      Linus Torvalds authored
      Pull vfs fixes from Darrick Wong:
       "I was auditing the sync_fs code paths recently and noticed that most
        callers of ->sync_fs ignore its return value (and many implementations
        never return nonzero even if the fs is broken!), which means that
        internal fs errors and corruption are not passed up to userspace
        callers of syncfs(2) or FIFREEZE. Hence fixing the common code and
        XFS, and I'll start working on the ext4/btrfs folks if this is merged.
      
        Summary:
      
         - Fix a bug where callers of ->sync_fs (e.g. sync_filesystem and
           syncfs(2)) ignore the return value.
      
         - Fix a bug where callers of sync_filesystem (e.g. fs freeze) ignore
           the return value.
      
         - Fix a bug in XFS where xfs_fs_sync_fs never passed back error
           returns"
      
      * tag 'vfs-5.17-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: return errors in xfs_fs_sync_fs
        quota: make dquot_quota_sync return errors from ->sync_fs
        vfs: make sync_filesystem return errors from ->sync_fs
        vfs: make freeze_super abort when sync_filesystem returns error
      ea7b3e6d
    • Linus Torvalds's avatar
      Merge tag 'iomap-5.17-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · 524446e2
      Linus Torvalds authored
      Pull iomap fix from Darrick Wong:
       "A single bugfix for iomap.
      
        The fix should eliminate occasional complaints about stall warnings
        when a lot of writeback IO completes all at once and we have to then
        go clearing status on a large number of folios.
      
        Summary:
      
         - Limit the length of ioend chains in writeback so that we don't trip
           the softlockup watchdog and to limit long tail latency on clearing
           PageWriteback"
      
      * tag 'iomap-5.17-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs, iomap: limit individual ioend chain lengths in writeback
      524446e2
    • Paolo Bonzini's avatar
      Merge tag 'kvmarm-fixes-5.17-2' of... · 7e6a6b40
      Paolo Bonzini authored
      Merge tag 'kvmarm-fixes-5.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
      
      KVM/arm64 fixes for 5.17, take #2
      
      - A couple of fixes when handling an exception while a SError has been
        delivered
      
      - Workaround for Cortex-A510's single-step[ erratum
      7e6a6b40
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · 0457e515
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "Some medium sized bugs in the various drivers. A couple are more
        recent regressions:
      
         - Fix two panics in hfi1 and two allocation problems
      
         - Send the IGMP to the correct address in cma
      
         - Squash a syzkaller bug related to races reading the multicast list
      
         - Memory leak in siw and cm
      
         - Fix a corner case spec compliance for HFI/QIB
      
         - Correct the implementation of fences in siw
      
         - Error unwind bug in mlx4"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA/mlx4: Don't continue event handler after memory allocation failure
        RDMA/siw: Fix broken RDMA Read Fence/Resume logic.
        IB/rdmavt: Validate remote_addr during loopback atomic tests
        IB/cm: Release previously acquired reference counter in the cm_id_priv
        RDMA/siw: Fix refcounting leak in siw_create_qp()
        RDMA/ucma: Protect mc during concurrent multicast leaves
        RDMA/cma: Use correct address when leaving multicast group
        IB/hfi1: Fix tstats alloc and dealloc
        IB/hfi1: Fix AIP early init panic
        IB/hfi1: Fix alloc failure with larger txqueuelen
        IB/hfi1: Fix panic with larger ipoib send_queue_size
      0457e515
  4. 04 Feb, 2022 2 commits
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · fc93310c
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "Seven fixes, six of which are fairly obvious driver fixes.
      
        The one core change to the device budget depth is to try to ensure
        that if the default depth is large (which can produce quite a sizeable
        bitmap allocation per device), we give back the memory we don't need
        if there's a queue size reduction in slave_configure (which happens to
        a lot of devices)"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: hisi_sas: Fix setting of hisi_sas_slot.is_internal
        scsi: pm8001: Fix use-after-free for aborted SSP/STP sas_task
        scsi: pm8001: Fix use-after-free for aborted TMF sas_task
        scsi: pm8001: Fix warning for undescribed param in process_one_iomb()
        scsi: core: Reallocate device's budget map on queue depth change
        scsi: bnx2fc: Make bnx2fc_recv_frame() mp safe
        scsi: pm80xx: Fix double completion for SATA devices
      fc93310c
    • Linus Torvalds's avatar
      Merge tag 'pci-v5.17-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci · e09e1a40
      Linus Torvalds authored
      Pull pci fixes from Bjorn Helgaas:
      
       - Restructure j721e_pcie_probe() so we don't dereference a NULL pointer
         (Bjorn Helgaas)
      
       - Add a kirin_pcie_data struct to identify different Kirin variants to
         fix probe failure for controllers with an internal PHY (Bjorn
         Helgaas)
      
      * tag 'pci-v5.17-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
        PCI: kirin: Add dev struct for of_device_get_match_data()
        PCI: j721e: Initialize pcie->cdns_pcie before using it
      e09e1a40