Skip to content
Snippets Groups Projects
  1. Nov 01, 2023
  2. Oct 30, 2023
  3. Oct 28, 2023
  4. Oct 27, 2023
  5. Oct 25, 2023
  6. Oct 23, 2023
    • Will Deacon's avatar
      scripts/faddr2line: Skip over mapping symbols in output from readelf · 60fd39af
      Will Deacon authored
      
      Mapping symbols emitted in the readelf output can confuse the
      'faddr2line' symbol size calculation, resulting in the erroneous
      rejection of valid offsets. This is especially prevalent when building
      an arm64 kernel with CONFIG_CFI_CLANG=y, where most functions are
      prefixed with a 32-bit data value in a '$d.n' section. For example:
      
      447538: ffff800080014b80   548 FUNC    GLOBAL DEFAULT    2 do_one_initcall
         104: ffff800080014c74     0 NOTYPE  LOCAL  DEFAULT    2 $x.73
         106: ffff800080014d30     0 NOTYPE  LOCAL  DEFAULT    2 $x.75
         111: ffff800080014da4     0 NOTYPE  LOCAL  DEFAULT    2 $d.78
         112: ffff800080014da8     0 NOTYPE  LOCAL  DEFAULT    2 $x.79
          36: ffff800080014de0   200 FUNC    LOCAL  DEFAULT    2 run_init_process
      
      Adding a warning to do_one_initcall() results in:
      
        | WARNING: CPU: 0 PID: 1 at init/main.c:1236 do_one_initcall+0xf4/0x260
      
      Which 'faddr2line' refuses to accept:
      
      $ ./scripts/faddr2line vmlinux do_one_initcall+0xf4/0x260
      skipping do_one_initcall address at 0xffff800080014c74 due to size mismatch (0x260 != 0x224)
      no match for do_one_initcall+0xf4/0x260
      
      Filter out these entries from readelf using a shell reimplementation of
      is_mapping_symbol(), so that the size of a symbol is calculated as a
      delta to the next symbol present in ksymtab.
      
      Suggested-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20231002165750.1661-4-will@kernel.org
      
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      60fd39af
    • Will Deacon's avatar
      scripts/faddr2line: Use LLVM addr2line and readelf if LLVM=1 · 86bf86e1
      Will Deacon authored
      
      GNU utilities cannot necessarily parse objects built by LLVM, which can
      result in confusing errors when using 'faddr2line':
      
      $ CROSS_COMPILE=aarch64-linux-gnu- ./scripts/faddr2line vmlinux do_one_initcall+0xf4/0x260
      aarch64-linux-gnu-addr2line: vmlinux: unknown type [0x13] section `.relr.dyn'
      aarch64-linux-gnu-addr2line: DWARF error: invalid or unhandled FORM value: 0x25
      do_one_initcall+0xf4/0x260:
      aarch64-linux-gnu-addr2line: vmlinux: unknown type [0x13] section `.relr.dyn'
      aarch64-linux-gnu-addr2line: DWARF error: invalid or unhandled FORM value: 0x25
      $x.73 at main.c:?
      
      Although this can be worked around by setting CROSS_COMPILE to "llvm=-",
      it's cleaner to follow the same syntax as the top-level Makefile and
      accept LLVM= as an indication to use the llvm- tools, optionally
      specifying their location or specific version number.
      
      Suggested-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20231002165750.1661-3-will@kernel.org
      
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      86bf86e1
    • Will Deacon's avatar
      scripts/faddr2line: Don't filter out non-function symbols from readelf · 180af1a5
      Will Deacon authored
      
      As Josh points out in 20230724234734.zy67gm674vl3p3wv@treble:
      
      > Problem is, I think the kernel's symbol printing code prints the
      > nearest kallsyms symbol, and there are some valid non-FUNC code
      > symbols.  For example, syscall_return_via_sysret.
      
      so we shouldn't be considering only 'FUNC'-type symbols in the output
      from readelf.
      
      Drop the function symbol type filtering from the faddr2line outer loop.
      
      Suggested-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Link: https://lore.kernel.org/r/20230724234734.zy67gm674vl3p3wv@treble
      
      
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20231002165750.1661-2-will@kernel.org
      
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      180af1a5
    • Yujie Liu's avatar
      scripts/kernel-doc: match -Werror flag strictly · 91f950e8
      Yujie Liu authored
      
      In our CI testing, we use some commands as below to only turn a specific
      type of warnings into errors, but we notice that kernel-doc warnings
      are also turned into errors unexpectedly.
      
      $ make KCFLAGS="-Werror=return-type" W=1 kernel/fork.o
      
      kernel/fork.c:1406: warning: Function parameter or member 'mm' not described in 'set_mm_exe_file'
      kernel/fork.c:1406: warning: Function parameter or member 'new_exe_file' not described in 'set_mm_exe_file'
      kernel/fork.c:1441: warning: Function parameter or member 'mm' not described in 'replace_mm_exe_file'
      kernel/fork.c:1441: warning: Function parameter or member 'new_exe_file' not described in 'replace_mm_exe_file'
      kernel/fork.c:1491: warning: Function parameter or member 'mm' not described in 'get_mm_exe_file'
      kernel/fork.c:1510: warning: Function parameter or member 'task' not described in 'get_task_exe_file'
      kernel/fork.c:1534: warning: Function parameter or member 'task' not described in 'get_task_mm'
      kernel/fork.c:2109: warning: bad line:
      kernel/fork.c:2130: warning: Function parameter or member 'ret' not described in '__pidfd_prepare'
      kernel/fork.c:2130: warning: Excess function parameter 'pidfd' description in '__pidfd_prepare'
      kernel/fork.c:2179: warning: Function parameter or member 'ret' not described in 'pidfd_prepare'
      kernel/fork.c:2179: warning: Excess function parameter 'pidfd' description in 'pidfd_prepare'
      kernel/fork.c:3195: warning: expecting prototype for clone3(). Prototype was for sys_clone3() instead
      13 warnings as Errors
      make[3]: *** [scripts/Makefile.build:243: kernel/fork.o] Error 13
      make[3]: *** Deleting file 'kernel/fork.o'
      make[2]: *** [scripts/Makefile.build:480: kernel] Error 2
      make[1]: *** [/root/linux/Makefile:1913: .] Error 2
      make: *** [Makefile:234: __sub-make] Error 2
      
      >From the git history, commit 2c12c810 ("scripts/kernel-doc:
      optionally treat warnings as errors") introduces a new command-line
      option to make kernel-doc warnings into errors. It can also read the
      KCFLAGS environment variable to decide whether to turn this option on,
      but the regex used for matching may not be accurate enough. It can match
      both "-Werror" and "-Werror=<diagnostic-type>", so the option is turned
      on by mistake in the latter case.
      
      Fix this by strictly matching the flag "-Werror": there must be a space
      or start of string in the front, and a space or end of string at the
      end. This can handle all the following cases correctly:
      
      KCFLAGS="-Werror" make W=1 [MATCH]
      KCFLAGS="-Werror=return-type" make W=1 [NO MATCH]
      KCFLAGS="-Wcomment -Werror -Wundef" make W=1 [MATCH]
      KCFLAGS="-Wcomment -Werror=return-type -Wundef" make W=1 [NO MATCH]
      
      Fixes: 2c12c810 ("scripts/kernel-doc: optionally treat warnings as errors")
      Signed-off-by: default avatarYujie Liu <yujie.liu@intel.com>
      Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
      Message-ID: <20231019095637.2471840-1-yujie.liu@intel.com>
      91f950e8
  7. Oct 21, 2023
  8. Oct 20, 2023
  9. Oct 18, 2023
  10. Oct 15, 2023
    • Miguel Ojeda's avatar
      rust: upgrade to Rust 1.73.0 · e08ff622
      Miguel Ojeda authored
      This is the next upgrade to the Rust toolchain, from 1.72.1 to 1.73.0
      (i.e. the latest) [1].
      
      See the upgrade policy [2] and the comments on the first upgrade in
      commit 3ed03f4d ("rust: upgrade to Rust 1.68.2").
      
      # Unstable features
      
      No unstable features (that we use) were stabilized.
      
      Therefore, the only unstable feature allowed to be used outside
      the `kernel` crate is still `new_uninit`, though other code to be
      upstreamed may increase the list.
      
      Please see [3] for details.
      
      # Required changes
      
      For the upgrade, the following changes are required:
      
        - Allow `internal_features` for `feature(compiler_builtins)` since
          now Rust warns about using internal compiler and standard library
          features (similar to how it also warns about incomplete ones) [4].
      
        - A cleanup for a documentation link thanks to a new `rustdoc` lint.
          See previous commits for details.
      
        - A need to make an intra-doc link to a macro explicit, due to a
          change in behavior in `rustdoc`. See previous commits for details.
      
      # `alloc` upgrade and reviewing
      
      The vast majority of changes are due to our `alloc` fork being upgraded
      at once.
      
      There are two kinds of changes to be aware of: the ones coming from
      upstream, which we should follow as closely as possible, and the updates
      needed in our added fallible APIs to keep them matching the newer
      infallible APIs coming from upstream.
      
      Instead of taking a look at the diff of this patch, an alternative
      approach is reviewing a diff of the changes between upstream `alloc` and
      the kernel's. This allows to easily inspect the kernel additions only,
      especially to check if the fallible methods we already have still match
      the infallible ones in the new version coming from upstream.
      
      Another approach is reviewing the changes introduced in the additions in
      the kernel fork between the two versions. This is useful to spot
      potentially unintended changes to our additions.
      
      To apply these approaches, one may follow steps similar to the following
      to generate a pair of patches that show the differences between upstream
      Rust and the kernel (for the subset of `alloc` we use) before and after
      applying this patch:
      
          # Get the difference with respect to the old version.
          git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
          git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
              cut -d/ -f3- |
              grep -Fv README.md |
              xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
          git -C linux diff --patch-with-stat --summary -R > old.patch
          git -C linux restore rust/alloc
      
          # Apply this patch.
          git -C linux am rust-upgrade.patch
      
          # Get the difference with respect to the new version.
          git -C rust checkout $(linux/scripts/min-tool-version.sh rustc)
          git -C linux ls-tree -r --name-only HEAD -- rust/alloc |
              cut -d/ -f3- |
              grep -Fv README.md |
              xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH
          git -C linux diff --patch-with-stat --summary -R > new.patch
          git -C linux restore rust/alloc
      
      Now one may check the `new.patch` to take a look at the additions (first
      approach) or at the difference between those two patches (second
      approach). For the latter, a side-by-side tool is recommended.
      
      Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1730-2023-10-05 [1]
      Link: https://rust-for-linux.com/rust-version-policy [2]
      Link: https://github.com/Rust-for-Linux/linux/issues/2 [3]
      Link: https://github.com/rust-lang/compiler-team/issues/596
      
       [4]
      Reviewed-by: default avatarMartin Rodriguez Reboredo <yakoyoku@gmail.com>
      Reviewed-by: default avatarVincenzo Palazzo <vincenzopalazzodev@gmail.com>
      Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
      Link: https://lore.kernel.org/r/20231005210556.466856-4-ojeda@kernel.org
      
      
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      e08ff622
  11. Oct 14, 2023
Loading