1. 11 Oct, 2021 3 commits
  2. 01 Oct, 2021 1 commit
  3. 29 Sep, 2021 2 commits
  4. 25 Sep, 2021 1 commit
    • Ariel Marcovitch's avatar
      kconfig: Create links to main menu items in search · d05377e1
      Ariel Marcovitch authored
      When one searches for a main menu item, links aren't created for it like
      with the rest of the symbols.
      
      This happens because we trace the item until we get to the rootmenu, but
      we don't include it in the path of the item. The rationale was probably
      that we don't want to show the main menu in the path of all items,
      because it is redundant.
      
      However, when an item has only the rootmenu in its path it should be
      included, because this way the user can jump to its location.
      
      Add a 'Main menu' entry in the 'Location:' section for the kconfig
      items.
      
      This makes the 'if (i > 0)' superfluous because each item with prompt
      will have at least one menu in its path.
      Signed-off-by: default avatarAriel Marcovitch <arielmarcovitch@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      d05377e1
  5. 22 Sep, 2021 8 commits
    • Masahiro Yamada's avatar
      kbuild: reuse $(cmd_objtool) for cmd_cc_lto_link_modules · 90a35349
      Masahiro Yamada authored
      For CONFIG_LTO_CLANG=y, the objtool processing is not possible at the
      compilation, hence postponed by the link time.
      
      Reuse $(cmd_objtool) for CONFIG_LTO_CLANG=y by defining objtool-enabled
      properly.
      
      For CONFIG_LTO_CLANG=y:
      
        objtool-enabled is off for %.o compilation
        objtool-enabled is on  for %.lto link
      
      For CONFIG_LTO_CLANG=n:
      
        objtool-enabled is on for %.o compilation
            (but, it depends on OBJECT_FILE_NON_STANDARD)
      
      Set part-of-module := y for %.lto.o to avoid repeating --module.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      90a35349
    • Masahiro Yamada's avatar
      kbuild: detect objtool update without using .SECONDEXPANSION · ef62588c
      Masahiro Yamada authored
      Redo commit 8852c552 ("kbuild: Fix objtool dependency for
      'OBJECT_FILES_NON_STANDARD_<obj> := n'") to add the objtool
      dependency in a cleaner way.
      
      Using .SECONDEXPANSION ends up with unreadable code due to escaped
      dollars. Also, it is not efficient because the second half of
      Makefile.build is parsed twice every time.
      
      Append the objtool dependency to the *.cmd files at the build time.
      
      This is what fixdep and gen_ksymdeps.sh already do. So, following the
      same pattern seems a natural solution.
      
      This allows us to drop $$(objtool_dep) entirely.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      ef62588c
    • Masahiro Yamada's avatar
      kbuild: factor out OBJECT_FILES_NON_STANDARD check into a macro · 918a6b7f
      Masahiro Yamada authored
      The OBJECT_FILES_NON_STANDARD check is quite long.
      
      Factor it out into a new macro, objtool-enabled, to not repeat it.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      918a6b7f
    • Masahiro Yamada's avatar
      kbuild: store the objtool command in *.cmd files · 92594d56
      Masahiro Yamada authored
      objtool_dep includes include/config/{ORC_UNWINDER,STACK_VALIDATION}
      so that all the objects are rebuilt when CONFIG_ORC_UNWINDER or
      CONFIG_STACK_VALIDATION is toggled.
      
      BTW, the correct option name is not CONFIG_ORC_UNWINDER, but
      CONFIG_UNWINDER_ORC. Commit 11af8474 ("x86/unwind: Rename
      unwinder config options to 'CONFIG_UNWINDER_*'") missed to
      adjust this part. So, this dependency has been broken for a
      long time.
      
      As you can see in 'objtool_args', there are more CONFIG options
      that affect the objtool command line.
      
      Adding more and more include/config/* is ugly and unmaintainable.
      
      Another issue is that non-standard objects are needlessly rebuilt.
      Objects specified as OBJECT_FILES_NON_STANDARD is not processed by
      objtool, but they are rebuilt anyway when CONFIG_STACK_VALIDATION
      is toggled. This is not a big deal, but better to fix.
      
      A cleaner and more precise fix is to include the objtool command in
      *.cmd files so any command change is naturally detected by if_change.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      92594d56
    • Masahiro Yamada's avatar
      kbuild: rename __objtool_obj and reuse it for cmd_cc_lto_link_modules · 5c4859e7
      Masahiro Yamada authored
      Rename __objtool_obj to objtool, and move it out of the
      'ifndef CONFIG_LTO_CLANG' conditional, so it can be used for
      cmd_cc_lto_link_modules as well.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      5c4859e7
    • Masahiro Yamada's avatar
      kbuild: move objtool_args back to scripts/Makefile.build · 8f0c32c7
      Masahiro Yamada authored
      Commit b1a1a1a0 ("kbuild: lto: postpone objtool") moved objtool_args
      to Makefile.lib, so the arguments can be used in Makefile.modfinal as
      well as Makefile.build.
      
      With commit 850ded46 ("kbuild: Fix TRIM_UNUSED_KSYMS with
      LTO_CLANG"), module LTO linking came back to scripts/Makefile.build
      again.
      
      So, there is no more reason to keep objtool_args in a separate file.
      
      Get it back to the original place, close to the objtool command.
      
      Remove the stale comment too.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      8f0c32c7
    • Alexey Dobriyan's avatar
      isystem: delete global -isystem compile option · 04e85bbf
      Alexey Dobriyan authored
      Further isolate kernel from userspace, prevent accidental inclusion of
      undesireable headers, mainly float.h and stdatomic.h.
      
      nds32 keeps -isystem globally due to intrinsics used in entrenched header.
      
      -isystem is selectively reenabled for some files, again, for intrinsics.
      
      Compile tested on:
      
      hexagon-defconfig hexagon-allmodconfig
      alpha-allmodconfig alpha-allnoconfig alpha-defconfig arm64-allmodconfig
      arm64-allnoconfig arm64-defconfig arm-am200epdkit arm-aspeed_g4
      arm-aspeed_g5 arm-assabet arm-at91_dt arm-axm55xx arm-badge4 arm-bcm2835
      arm-cerfcube arm-clps711x arm-cm_x300 arm-cns3420vb arm-colibri_pxa270
      arm-colibri_pxa300 arm-collie arm-corgi arm-davinci_all arm-dove
      arm-ep93xx arm-eseries_pxa arm-exynos arm-ezx arm-footbridge arm-gemini
      arm-h3600 arm-h5000 arm-hackkit arm-hisi arm-imote2 arm-imx_v4_v5
      arm-imx_v6_v7 arm-integrator arm-iop32x arm-ixp4xx arm-jornada720
      arm-keystone arm-lart arm-lpc18xx arm-lpc32xx arm-lpd270 arm-lubbock
      arm-magician arm-mainstone arm-milbeaut_m10v arm-mini2440 arm-mmp2
      arm-moxart arm-mps2 arm-multi_v4t arm-multi_v5 arm-multi_v7 arm-mv78xx0
      arm-mvebu_v5 arm-mvebu_v7 arm-mxs arm-neponset arm-netwinder arm-nhk8815
      arm-omap1 arm-omap2plus arm-orion5x arm-oxnas_v6 arm-palmz72 arm-pcm027
      arm-pleb arm-pxa arm-pxa168 arm-pxa255-idp arm-pxa3xx arm-pxa910
      arm-qcom arm-realview arm-rpc arm-s3c2410 arm-s3c6400 arm-s5pv210
      arm-sama5 arm-shannon arm-shmobile arm-simpad arm-socfpga arm-spear13xx
      arm-spear3xx arm-spear6xx arm-spitz arm-stm32 arm-sunxi arm-tct_hammer
      arm-tegra arm-trizeps4 arm-u8500 arm-versatile arm-vexpress arm-vf610m4
      arm-viper arm-vt8500_v6_v7 arm-xcep arm-zeus csky-allmodconfig
      csky-allnoconfig csky-defconfig h8300-edosk2674 h8300-h8300h-sim
      h8300-h8s-sim i386-allmodconfig i386-allnoconfig i386-defconfig
      ia64-allmodconfig ia64-allnoconfig ia64-bigsur ia64-generic ia64-gensparse
      ia64-tiger ia64-zx1 m68k-amcore m68k-amiga m68k-apollo m68k-atari
      m68k-bvme6000 m68k-hp300 m68k-m5208evb m68k-m5249evb m68k-m5272c3
      m68k-m5275evb m68k-m5307c3 m68k-m5407c3 m68k-m5475evb m68k-mac
      m68k-multi m68k-mvme147 m68k-mvme16x m68k-q40 m68k-stmark2 m68k-sun3
      m68k-sun3x microblaze-allmodconfig microblaze-allnoconfig microblaze-mmu
      mips-ar7 mips-ath25 mips-ath79 mips-bcm47xx mips-bcm63xx mips-bigsur
      mips-bmips_be mips-bmips_stb mips-capcella mips-cavium_octeon mips-ci20
      mips-cobalt mips-cu1000-neo mips-cu1830-neo mips-db1xxx mips-decstation
      mips-decstation_64 mips-decstation_r4k mips-e55 mips-fuloong2e
      mips-gcw0 mips-generic mips-gpr mips-ip22 mips-ip27 mips-ip28 mips-ip32
      mips-jazz mips-jmr3927 mips-lemote2f mips-loongson1b mips-loongson1c
      mips-loongson2k mips-loongson3 mips-malta mips-maltaaprp mips-malta_kvm
      mips-malta_qemu_32r6 mips-maltasmvp mips-maltasmvp_eva mips-maltaup
      mips-maltaup_xpa mips-mpc30x mips-mtx1 mips-nlm_xlp mips-nlm_xlr
      mips-omega2p mips-pic32mzda mips-pistachio mips-qi_lb60 mips-rb532
      mips-rbtx49xx mips-rm200 mips-rs90 mips-rt305x mips-sb1250_swarm
      mips-tb0219 mips-tb0226 mips-tb0287 mips-vocore2 mips-workpad mips-xway
      nds32-allmodconfig nds32-allnoconfig nds32-defconfig nios2-10m50
      nios2-3c120 nios2-allmodconfig nios2-allnoconfig openrisc-allmodconfig
      openrisc-allnoconfig openrisc-or1klitex openrisc-or1ksim
      openrisc-simple_smp parisc-allnoconfig parisc-generic-32bit
      parisc-generic-64bit powerpc-acadia powerpc-adder875 powerpc-akebono
      powerpc-amigaone powerpc-arches powerpc-asp8347 powerpc-bamboo
      powerpc-bluestone powerpc-canyonlands powerpc-cell powerpc-chrp32
      powerpc-cm5200 powerpc-currituck powerpc-ebony powerpc-eiger
      powerpc-ep8248e powerpc-ep88xc powerpc-fsp2 powerpc-g5 powerpc-gamecube
      powerpc-ge_imp3a powerpc-holly powerpc-icon powerpc-iss476-smp
      powerpc-katmai powerpc-kilauea powerpc-klondike powerpc-kmeter1
      powerpc-ksi8560 powerpc-linkstation powerpc-lite5200b powerpc-makalu
      powerpc-maple powerpc-mgcoge powerpc-microwatt powerpc-motionpro
      powerpc-mpc512x powerpc-mpc5200 powerpc-mpc7448_hpc2 powerpc-mpc8272_ads
      powerpc-mpc8313_rdb powerpc-mpc8315_rdb powerpc-mpc832x_mds
      powerpc-mpc832x_rdb powerpc-mpc834x_itx powerpc-mpc834x_itxgp
      powerpc-mpc834x_mds powerpc-mpc836x_mds powerpc-mpc836x_rdk
      powerpc-mpc837x_mds powerpc-mpc837x_rdb powerpc-mpc83xx
      powerpc-mpc8540_ads powerpc-mpc8560_ads powerpc-mpc85xx_cds
      powerpc-mpc866_ads powerpc-mpc885_ads powerpc-mvme5100 powerpc-obs600
      powerpc-pasemi powerpc-pcm030 powerpc-pmac32 powerpc-powernv
      powerpc-ppa8548 powerpc-ppc40x powerpc-ppc44x powerpc-ppc64
      powerpc-ppc64e powerpc-ppc6xx powerpc-pq2fads powerpc-ps3
      powerpc-pseries powerpc-rainier powerpc-redwood powerpc-sam440ep
      powerpc-sbc8548 powerpc-sequoia powerpc-skiroot powerpc-socrates
      powerpc-storcenter powerpc-stx_gp3 powerpc-taishan powerpc-tqm5200
      powerpc-tqm8540 powerpc-tqm8541 powerpc-tqm8548 powerpc-tqm8555
      powerpc-tqm8560 powerpc-tqm8xx powerpc-walnut powerpc-warp powerpc-wii
      powerpc-xes_mpc85xx riscv-allmodconfig riscv-allnoconfig riscv-nommu_k210
      riscv-nommu_k210_sdcard riscv-nommu_virt riscv-rv32 s390-allmodconfig
      s390-allnoconfig s390-debug s390-zfcpdump sh-ap325rxa sh-apsh4a3a
      sh-apsh4ad0a sh-dreamcast sh-ecovec24 sh-ecovec24-romimage sh-edosk7705
      sh-edosk7760 sh-espt sh-hp6xx sh-j2 sh-kfr2r09 sh-kfr2r09-romimage
      sh-landisk sh-lboxre2 sh-magicpanelr2 sh-microdev sh-migor sh-polaris
      sh-r7780mp sh-r7785rp sh-rsk7201 sh-rsk7203 sh-rsk7264 sh-rsk7269
      sh-rts7751r2d1 sh-rts7751r2dplus sh-sdk7780 sh-sdk7786 sh-se7206 sh-se7343
      sh-se7619 sh-se7705 sh-se7712 sh-se7721 sh-se7722 sh-se7724 sh-se7750
      sh-se7751 sh-se7780 sh-secureedge5410 sh-sh03 sh-sh2007 sh-sh7710voipgw
      sh-sh7724_generic sh-sh7757lcr sh-sh7763rdp sh-sh7770_generic sh-sh7785lcr
      sh-sh7785lcr_32bit sh-shmin sh-shx3 sh-titan sh-ul2 sh-urquell
      sparc-allmodconfig sparc-allnoconfig sparc-sparc32 sparc-sparc64
      um-i386-allmodconfig um-i386-allnoconfig um-i386-defconfig
      um-x86_64-allmodconfig um-x86_64-allnoconfig x86_64-allmodconfig
      x86_64-allnoconfig x86_64-defconfig xtensa-allmodconfig xtensa-allnoconfig
      xtensa-audio_kc705 xtensa-cadence_csp xtensa-common xtensa-generic_kc705
      xtensa-iss xtensa-nommu_kc705 xtensa-smp_lx200 xtensa-virt
      xtensa-xip_kc705
      
      Tested-by: Nathan Chancellor <nathan@kernel.org> # build (hexagon)
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      04e85bbf
    • Masahiro Yamada's avatar
      nios2: move the install rule to arch/nios2/Makefile · 89b4db61
      Masahiro Yamada authored
      Currently, the install target in arch/nios2/Makefile descends into
      arch/nios2/boot/Makefile to invoke the shell script, but it is no
      good reason to do so.
      
      arch/nios2/Makefile can run the shell script directly.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      89b4db61
  6. 20 Sep, 2021 2 commits
    • Linus Torvalds's avatar
      Linux 5.15-rc2 · e4e737bb
      Linus Torvalds authored
      e4e737bb
    • Linus Torvalds's avatar
      pci_iounmap'2: Electric Boogaloo: try to make sense of it all · 316e8d79
      Linus Torvalds authored
      Nathan Chancellor reports that the recent change to pci_iounmap in
      commit 9caea000 ("parisc: Declare pci_iounmap() parisc version only
      when CONFIG_PCI enabled") causes build errors on arm64.
      
      It took me about two hours to convince myself that I think I know what
      the logic of that mess of #ifdef's in the <asm-generic/io.h> header file
      really aim to do, and rewrite it to be easier to follow.
      
      Famous last words.
      
      Anyway, the code has now been lifted from that grotty header file into
      lib/pci_iomap.c, and has fairly extensive comments about what the logic
      is.  It also avoids indirecting through another confusing (and badly
      named) helper function that has other preprocessor config conditionals.
      
      Let's see what odd architecture did something else strange in this area
      to break things.  But my arm64 cross build is clean.
      
      Fixes: 9caea000 ("parisc: Declare pci_iounmap() parisc version only when CONFIG_PCI enabled")
      Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Ulrich Teichert <krypton@ulrich-teichert.org>
      Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      316e8d79
  7. 19 Sep, 2021 18 commits
  8. 18 Sep, 2021 5 commits
    • Linus Torvalds's avatar
      alpha: move __udiv_qrnnd library function to arch/alpha/lib/ · d4d016ca
      Linus Torvalds authored
      We already had the implementation for __udiv_qrnnd (unsigned divide for
      multi-precision arithmetic) as part of the alpha math emulation code.
      
      But you can disable the math emulation code - even if you shouldn't -
      and then the MPI code that actually wants this functionality (and is
      needed by various crypto functions) will fail to build.
      
      So move the extended-precision divide code to be a regular library
      function, just like all the regular division code is.  That way ie is
      available regardless of math-emulation.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d4d016ca
    • Linus Torvalds's avatar
      alpha: mark 'Jensen' platform as no longer broken · ab41f75e
      Linus Torvalds authored
      Ok, it almost certainly is still broken on actual hardware, but the
      immediate reason for it having been marked BROKEN was a build error that
      is fixed by just making sure the low-level IO header file is included
      sufficiently early that the __EXTERN_INLINE hackery takes effect.
      
      This was marked broken back in 2017 by commit 1883c9f4 ("alpha: mark
      jensen as broken"), but Ulrich Teichert made me look at it as part of my
      cross-build work to make sure -Werror actually does the right thing.
      
      There are lots of alpha configurations that do not build cleanly, but
      now it's no longer because Jensen wouldn't be buildable.  That said,
      because the Jensen platform doesn't force PCI to be enabled (Jensen only
      had EISA), it ends up being somewhat interesting as a source of odd
      configs.
      Reported-by: default avatarUlrich Teichert <krypton@ulrich-teichert.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ab41f75e
    • Andrii Nakryiko's avatar
      perf bpf: Ignore deprecation warning when using libbpf's btf__get_from_id() · 219d720e
      Andrii Nakryiko authored
      Perf code re-implements libbpf's btf__load_from_kernel_by_id() API as
      a weak function, presumably to dynamically link against old version of
      libbpf shared library. Unfortunately this causes compilation warning
      when perf is compiled against libbpf v0.6+.
      
      For now, just ignore deprecation warning, but there might be a better
      solution, depending on perf's needs.
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: kernel-team@fb.com
      LPU-Reference: 20210914170004.4185659-1-andrii@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      219d720e
    • Ian Rogers's avatar
      libperf evsel: Make use of FD robust. · aba5daeb
      Ian Rogers authored
      FD uses xyarray__entry that may return NULL if an index is out of
      bounds. If NULL is returned then a segv happens as FD unconditionally
      dereferences the pointer. This was happening in a case of with perf
      iostat as shown below. The fix is to make FD an "int*" rather than an
      int and handle the NULL case as either invalid input or a closed fd.
      
        $ sudo gdb --args perf stat --iostat  list
        ...
        Breakpoint 1, perf_evsel__alloc_fd (evsel=0x5555560951a0, ncpus=1, nthreads=1) at evsel.c:50
        50      {
        (gdb) bt
         #0  perf_evsel__alloc_fd (evsel=0x5555560951a0, ncpus=1, nthreads=1) at evsel.c:50
         #1  0x000055555585c188 in evsel__open_cpu (evsel=0x5555560951a0, cpus=0x555556093410,
            threads=0x555556086fb0, start_cpu=0, end_cpu=1) at util/evsel.c:1792
         #2  0x000055555585cfb2 in evsel__open (evsel=0x5555560951a0, cpus=0x0, threads=0x555556086fb0)
            at util/evsel.c:2045
         #3  0x000055555585d0db in evsel__open_per_thread (evsel=0x5555560951a0, threads=0x555556086fb0)
            at util/evsel.c:2065
         #4  0x00005555558ece64 in create_perf_stat_counter (evsel=0x5555560951a0,
            config=0x555555c34700 <stat_config>, target=0x555555c2f1c0 <target>, cpu=0) at util/stat.c:590
         #5  0x000055555578e927 in __run_perf_stat (argc=1, argv=0x7fffffffe4a0, run_idx=0)
            at builtin-stat.c:833
         #6  0x000055555578f3c6 in run_perf_stat (argc=1, argv=0x7fffffffe4a0, run_idx=0)
            at builtin-stat.c:1048
         #7  0x0000555555792ee5 in cmd_stat (argc=1, argv=0x7fffffffe4a0) at builtin-stat.c:2534
         #8  0x0000555555835ed3 in run_builtin (p=0x555555c3f540 <commands+288>, argc=3,
            argv=0x7fffffffe4a0) at perf.c:313
         #9  0x0000555555836154 in handle_internal_command (argc=3, argv=0x7fffffffe4a0) at perf.c:365
         #10 0x000055555583629f in run_argv (argcp=0x7fffffffe2ec, argv=0x7fffffffe2e0) at perf.c:409
         #11 0x0000555555836692 in main (argc=3, argv=0x7fffffffe4a0) at perf.c:539
        ...
        (gdb) c
        Continuing.
        Error:
        The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_iio_0/event=0x83,umask=0x04,ch_mask=0xF,fc_mask=0x07/).
        /bin/dmesg | grep -i perf may provide additional information.
      
        Program received signal SIGSEGV, Segmentation fault.
        0x00005555559b03ea in perf_evsel__close_fd_cpu (evsel=0x5555560951a0, cpu=1) at evsel.c:166
        166                     if (FD(evsel, cpu, thread) >= 0)
      
      v3. fixes a bug in perf_evsel__run_ioctl where the sense of a branch was
          backward.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210918054440.2350466-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      aba5daeb
    • Michael Petlan's avatar
      perf machine: Initialize srcline string member in add_location struct · 57f0ff05
      Michael Petlan authored
      It's later supposed to be either a correct address or NULL. Without the
      initialization, it may contain an undefined value which results in the
      following segmentation fault:
      
        # perf top --sort comm -g --ignore-callees=do_idle
      
      terminates with:
      
        #0  0x00007ffff56b7685 in __strlen_avx2 () from /lib64/libc.so.6
        #1  0x00007ffff55e3802 in strdup () from /lib64/libc.so.6
        #2  0x00005555558cb139 in hist_entry__init (callchain_size=<optimized out>, sample_self=true, template=0x7fffde7fb110, he=0x7fffd801c250) at util/hist.c:489
        #3  hist_entry__new (template=template@entry=0x7fffde7fb110, sample_self=sample_self@entry=true) at util/hist.c:564
        #4  0x00005555558cb4ba in hists__findnew_entry (hists=hists@entry=0x5555561d9e38, entry=entry@entry=0x7fffde7fb110, al=al@entry=0x7fffde7fb420,
            sample_self=sample_self@entry=true) at util/hist.c:657
        #5  0x00005555558cba1b in __hists__add_entry (hists=hists@entry=0x5555561d9e38, al=0x7fffde7fb420, sym_parent=<optimized out>, bi=bi@entry=0x0, mi=mi@entry=0x0,
            sample=sample@entry=0x7fffde7fb4b0, sample_self=true, ops=0x0, block_info=0x0) at util/hist.c:288
        #6  0x00005555558cbb70 in hists__add_entry (sample_self=true, sample=0x7fffde7fb4b0, mi=0x0, bi=0x0, sym_parent=<optimized out>, al=<optimized out>, hists=0x5555561d9e38)
            at util/hist.c:1056
        #7  iter_add_single_cumulative_entry (iter=0x7fffde7fb460, al=<optimized out>) at util/hist.c:1056
        #8  0x00005555558cc8a4 in hist_entry_iter__add (iter=iter@entry=0x7fffde7fb460, al=al@entry=0x7fffde7fb420, max_stack_depth=<optimized out>, arg=arg@entry=0x7fffffff7db0)
            at util/hist.c:1231
        #9  0x00005555557cdc9a in perf_event__process_sample (machine=<optimized out>, sample=0x7fffde7fb4b0, evsel=<optimized out>, event=<optimized out>, tool=0x7fffffff7db0)
            at builtin-top.c:842
        #10 deliver_event (qe=<optimized out>, qevent=<optimized out>) at builtin-top.c:1202
        #11 0x00005555558a9318 in do_flush (show_progress=false, oe=0x7fffffff80e0) at util/ordered-events.c:244
        #12 __ordered_events__flush (oe=oe@entry=0x7fffffff80e0, how=how@entry=OE_FLUSH__TOP, timestamp=timestamp@entry=0) at util/ordered-events.c:323
        #13 0x00005555558a9789 in __ordered_events__flush (timestamp=<optimized out>, how=<optimized out>, oe=<optimized out>) at util/ordered-events.c:339
        #14 ordered_events__flush (how=OE_FLUSH__TOP, oe=0x7fffffff80e0) at util/ordered-events.c:341
        #15 ordered_events__flush (oe=oe@entry=0x7fffffff80e0, how=how@entry=OE_FLUSH__TOP) at util/ordered-events.c:339
        #16 0x00005555557cd631 in process_thread (arg=0x7fffffff7db0) at builtin-top.c:1114
        #17 0x00007ffff7bb817a in start_thread () from /lib64/libpthread.so.0
        #18 0x00007ffff5656dc3 in clone () from /lib64/libc.so.6
      
      If you look at the frame #2, the code is:
      
      488	 if (he->srcline) {
      489          he->srcline = strdup(he->srcline);
      490          if (he->srcline == NULL)
      491              goto err_rawdata;
      492	 }
      
      If he->srcline is not NULL (it is not NULL if it is uninitialized rubbish),
      it gets strdupped and strdupping a rubbish random string causes the problem.
      
      Also, if you look at the commit 1fb7d06a, it adds the srcline property
      into the struct, but not initializing it everywhere needed.
      
      Committer notes:
      
      Now I see, when using --ignore-callees=do_idle we end up here at line
      2189 in add_callchain_ip():
      
      2181         if (al.sym != NULL) {
      2182                 if (perf_hpp_list.parent && !*parent &&
      2183                     symbol__match_regex(al.sym, &parent_regex))
      2184                         *parent = al.sym;
      2185                 else if (have_ignore_callees && root_al &&
      2186                   symbol__match_regex(al.sym, &ignore_callees_regex)) {
      2187                         /* Treat this symbol as the root,
      2188                            forgetting its callees. */
      2189                         *root_al = al;
      2190                         callchain_cursor_reset(cursor);
      2191                 }
      2192         }
      
      And the al that doesn't have the ->srcline field initialized will be
      copied to the root_al, so then, back to:
      
      1211 int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al,
      1212                          int max_stack_depth, void *arg)
      1213 {
      1214         int err, err2;
      1215         struct map *alm = NULL;
      1216
      1217         if (al)
      1218                 alm = map__get(al->map);
      1219
      1220         err = sample__resolve_callchain(iter->sample, &callchain_cursor, &iter->parent,
      1221                                         iter->evsel, al, max_stack_depth);
      1222         if (err) {
      1223                 map__put(alm);
      1224                 return err;
      1225         }
      1226
      1227         err = iter->ops->prepare_entry(iter, al);
      1228         if (err)
      1229                 goto out;
      1230
      1231         err = iter->ops->add_single_entry(iter, al);
      1232         if (err)
      1233                 goto out;
      1234
      
      That al at line 1221 is what hist_entry_iter__add() (called from
      sample__resolve_callchain()) saw as 'root_al', and then:
      
              iter->ops->add_single_entry(iter, al);
      
      will go on with al->srcline with a bogus value, I'll add the above
      sequence to the cset and apply, thanks!
      Signed-off-by: default avatarMichael Petlan <mpetlan@redhat.com>
      CC: Milian Wolff <milian.wolff@kdab.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Fixes: 1fb7d06a ("perf report Use srcline from callchain for hist entries")
      Link: https //lore.kernel.org/r/20210719145332.29747-1-mpetlan@redhat.com
      Reported-by: default avatarJuri Lelli <jlelli@redhat.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      57f0ff05