Commit graph

9610 commits

Author SHA1 Message Date
Linus Torvalds
969b5726ac Miscellaneous objtool fixes:
- Fix a build error on ia32-x86_64 cross builds
 
  - Replace locally open coded ALIGN_UP(), ALIGN_UP_POW2()
    and MAX(), which, beyond being duplicates, the
    ALIGN_UP_POW2() is also buggy.
 
  - Fix objtool klp-diff regression caused by a recent
    change to the bug table format.
 
  - Fix klp-build vs CONFIG_MODULE_SRCVERSION_ALL build
    failure.
 
 Signed-off-by: Ingo Molnar <mingo@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAml/EqgRHG1pbmdvQGtl
 cm5lbC5vcmcACgkQEnMQ0APhK1gkqBAAgna1qjT9fWFQgcEExhEFQ7Qj3CwocVNS
 1t0uiXLApienRho1aBERK4NLyMD9PX3GvGUphYBKL7qtZDUn/Ff1Biuz7EjrszCR
 nOhOL0gofWuaT4hB4UlmRLnmlmWnkXe9G2gYVUnj+7hDP1C3Z+XCxogL+Rr5QBbp
 YhQU8OMsGmA4Jy1P3vikpRXOTsTbdSyhqJxB8OsGdKf+gX8QdnAGgSdNu+d4A67x
 QNx8OH5Qyv4n9GkSNattqtgY75CyppYHUFV46DR/KHlrGHhwibJ01x6TbV0t9Y6p
 ZgOrlLPcwtLM/ZHkO0hR4xSMD4rHiBgVOam6j4Gt+PiyTA5UD3Ypi2hDQfHqi2Dk
 ZQCA6IkqdS/hCxJOj15bO8+kstbnycdBNZp1RLxDlod3AC3ZrotXoRBa4Hdmniw1
 vS5vPEHkTZG8Rz4BpA4NWpFtqDFhqAdOEZJaq0DbihE+WlVz3faXTQaDlBtYgYnE
 RCTUfwsgzgCdSElX4qXI5Hls0FdDJdfVgkVhlH0kvmMS8Jdjb/z197zK0787fiRD
 anIUj9R/2B1QMV5fdwcRDAhVmxpL4a2d96xCSRM/9eWYhm/zlZlo8Y9oSsjtTAQ4
 5p35CFA7Y8WgVJI+tEraw0AXErcpnyDk4+BktVl2liWYUsxV6jODayQnxqltu/UA
 +Anv57mVzRE=
 =ySDm
 -----END PGP SIGNATURE-----

Merge tag 'objtool-urgent-2026-02-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool fixes from Ingo Molnar:

 - Fix a build error on ia32-x86_64 cross builds

 - Replace locally open coded ALIGN_UP(), ALIGN_UP_POW2()
   and MAX(), which, beyond being duplicates, the
   ALIGN_UP_POW2() is also buggy

 - Fix objtool klp-diff regression caused by a recent
   change to the bug table format

 - Fix klp-build vs CONFIG_MODULE_SRCVERSION_ALL build
   failure

* tag 'objtool-urgent-2026-02-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  livepatch/klp-build: Fix klp-build vs CONFIG_MODULE_SRCVERSION_ALL
  objtool/klp: Fix bug table handling for __WARN_printf()
  objtool: Replace custom macros in elf.c with shared ones
  objtool: Print bfd_vma as unsigned long long on ia32-x86_64 cross build
2026-02-01 10:27:43 -08:00
Eric Dumazet
cc20650a09 scripts/bloat-o-meter: ignore __noinstr_text_start
__noinstr_text_start is adding noise to the script, ignore it.

For instance using __always_inline on __skb_incr_checksum_unnecessary and
CC=clang build.

Before this patch, __noinstr_text_start can show up and confuse us.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/2 grow/shrink: 3/0 up/down: 212/-206 (6)
Function                                     old     new   delta
tcp6_gro_complete                            208     283     +75
tcp4_gro_complete                            376     449     +73
__noinstr_text_start                        3536    3600     +64
__pfx___skb_incr_checksum_unnecessary         32       -     -32
__skb_incr_checksum_unnecessary              174       -    -174
Total: Before=25509464, After=25509470, chg +0.00%

After this patch we have a more precise result.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/2 grow/shrink: 2/0 up/down: 148/-206 (-58)
Function                                     old     new   delta
tcp6_gro_complete                            208     283     +75
tcp4_gro_complete                            376     449     +73
__pfx___skb_incr_checksum_unnecessary         32       -     -32
__skb_incr_checksum_unnecessary              174       -    -174
Total: Before=25505928, After=25505870, chg -0.00%

Link: https://lkml.kernel.org/r/20260117083448.3877418-1-edumazet@google.com
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-01-31 16:16:06 -08:00
Joe Perches
931d5c36c7 checkpatch: add an invalid patch separator test
Some versions of tools that apply patches incorrectly allow lines that
start with 3 dashes and have additional content on the same line.

Checkpatch will now emit an ERROR on these lines and optionally convert
those lines from dashes to equals with --fix.

Link: https://lkml.kernel.org/r/6ec1ed08328340db42655287afd5fa4067316b11.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Ian Rogers <irogers@google.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Kuan-Wei Chiu <visitorckw@gmail.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Namhyung kim <namhyung@kernel.org>
Cc: Stehen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-01-31 16:16:03 -08:00
Linus Torvalds
44f4119c7c Kbuild fixes for 6.19, round 3
- kbuild: rpm-pkg: Generate debuginfo package manually, allowing
    signed kernel modules in rpm package, again
 
  - kbuild: Fix permissions of modules.builtin.modinfo
 
  - kbuild: Do not run kernel-doc when building external modules
 
 Cc: Ethan Zuo <yuxuan.zuo@outlook.com>
 Cc: Holger Kiehl <Holger.Kiehl@dwd.de>
 Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
 Cc: Nathan Chancellor <nathan@kernel.org>
 Cc: Randy Dunlap <rdunlap@infradead.org>
 Cc: Rong Zhang <i@rong.moe>
 Cc: Uday Shankar <ushankar@purestorage.com>
 Cc: linux-kbuild@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEh0E3p4c3JKeBvsLGB1IKcBYmEmkFAml+Hv8ACgkQB1IKcBYm
 EmnClxAApczvQMYJWjFyoUcmMlB79dB6yZaaTp9T6+JGaWMS8zbkaU/dVDcY42Bs
 5GptCyWLKHohifG1GYIg2wKpCZbhNMAHNAL1xcJKnyqJ/ypoatwwdsVPlHw4D3Vx
 0VQVr4ofs9HeXMXznJtFCNoNMRWNoQIJncGYC1ki1X3X918b3Lr4237DWlR7NZpY
 Br+6oD6k9qEQ6hS+Q4nLwT+nYmHFwWkhOMO5tZfw1InLYBkoKC6kvimE9VvnF3hL
 Jb7xS7nHVV2yMvbAdFHvxKYc4EmpSV3rAE/kaYymSHepPbavqPPeVwp9CbWH3dg8
 qoXvUrndFs/CawNqqaAuDcXK+ppO+tnWTWjhNHKcvTh/YnnVByRKOs2QB1169/wg
 ENMlehDbLhMEkQBOmvIuc0nqkjIBtYKRjGpycHYuDCvSqrLxr9zgAIZRfgOnlPNb
 PxYWPSQd4kc1A0JGhvkwZGHyBzkfu8MFC6w2yHEA+Wt5aZQWwTfKGwyQue9PLX0a
 q8rgjBwe+tjCb8Q0LHcChFFG0jeAKEIBsiehfVC2x44Femcnjjrx/+MZy+qhKqLF
 TeWVPnlTvjOETxcP2LOx2kxHX7MHSq3lJSwu/3xR5U+PInbabTlyBjjepIsJU5Tz
 2qjrWLVlApHHK0juy3yNUebBo68qr3sgFxBJlRGhBaCVBvmBn9s=
 =2S41
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-fixes-6.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux

Pull Kbuild fixes from Nicolas Schier:

 - Generate rpm-pkg debuginfo package manually, allowing signed kernel
   modules in rpm package, again

 - Fix permissions of modules.builtin.modinfo

 - Do not run kernel-doc when building external modules

* tag 'kbuild-fixes-6.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux:
  kbuild: Do not run kernel-doc when building external modules
  kbuild: Fix permissions of modules.builtin.modinfo
  kbuild: rpm-pkg: Generate debuginfo package manually
2026-01-31 08:21:32 -08:00
Nathan Chancellor
8e24994872
kbuild: Do not run kernel-doc when building external modules
After commit 778b8ebe51 ("docs: Move the python libraries to
tools/lib/python"), building an external module with any value of W=
against the output of install-extmod-build fails with:

  $ make -C /usr/lib/modules/6.19.0-rc7-00108-g4d310797262f/build M=$PWD W=1
  make: Entering directory '/usr/lib/modules/6.19.0-rc7-00108-g4d310797262f/build'
  make[1]: Entering directory '...'
    CC [M] ...
  Traceback (most recent call last):
    File "/usr/lib/modules/6.19.0-rc7-00108-g4d310797262f/build/scripts/kernel-doc.py", line 339, in <module>
      main()
      ~~~~^^
    File "/usr/lib/modules/6.19.0-rc7-00108-g4d310797262f/build/scripts/kernel-doc.py", line 295, in main
      from kdoc.kdoc_files import KernelFiles             # pylint: disable=C0415
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ModuleNotFoundError: No module named 'kdoc'

scripts/lib was included in the build directory from find_in_scripts but
after the move to tools/lib/python, it is no longer included, breaking
kernel-doc.py.

Commit eba6ffd126 ("docs: kdoc: move kernel-doc to tools/docs") breaks
this even further by moving kernel-doc outside of scripts as well, so it
cannot be found when called by cmd_checkdoc.

  $ make -C /usr/lib/modules/6.19.0-rc7-next-20260130/build M=$PWD W=1
  make: Entering directory '/usr/lib/modules/6.19.0-rc7-next-20260130/build'
  make[1]: Entering directory '...'
    CC [M]  ...
  python3: can't open file '/usr/lib/modules/6.19.0-rc7-next-20260130/build/tools/docs/kernel-doc': [Errno 2] No such file or directory

While kernel-doc could be useful for external modules, it is more useful
for in-tree documentation that will be build and included in htmldocs.
Rather than including it in install-extmod-build, just skip running
kernel-doc for the external module build.

Cc: stable@vger.kernel.org
Fixes: 778b8ebe51 ("docs: Move the python libraries to tools/lib/python")
Reported-by: Rong Zhang <i@rong.moe>
Closes: https://lore.kernel.org/20260129175321.415295-1-i@rong.moe/
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://patch.msgid.link/20260130-kbuild-skip-kernel-doc-extmod-v1-1-58443d60131a@kernel.org
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Signed-off-by: Nicolas Schier <nsc@kernel.org>
2026-01-31 16:12:01 +01:00
Linus Torvalds
367b81ef01 Rust fixes for v6.19
Toolchain and infrastructure:
 
   - Trigger rebuilds of the newly added 'proc-macro2' crate (and its
     dependencies) when the Rust compiler version changes.
 
   - Fix error in '.rsi' targets (macro expanding single targets) under
     'O=' pointing to an external (not subdir) folder.
 
   - Fix off-by-one line number in 'rustdoc' KUnit tests.
 
   - Add '-fdiagnostics-show-context' to GCC flags skipped by 'bindgen'.
 
   - Clean objtool warning by adding one more 'noreturn' function.
 
   - Clean 'libpin_init_internal.{so,dylib}' in 'mrproper'.
 
 'kernel' crate:
 
   - Fix build error when using expressions in formatting arguments.
 
   - Mark 'num::Bounded::__new()' as unsafe and clean documentation
     accordingly.
 
   - Always inline functions using 'build_assert' with arguments.
 
   - Fix 'rusttest' build error providing the right 'isize_atomic_repr'
     type for the host.
 
 'macros' crate:
 
   - Fix 'rusttest' build error by ignoring example.
 
 rust-analyzer:
 
   - Remove assertion that was not true for distributions like NixOS.
 
   - Add missing dependency edges and fix editions for 'quote' and
     sysroot crates to provide correct IDE support.
 
 DRM Tyr:
 
   - Fix build error by adding missing dependency on 'CONFIG_COMMON_CLK'.
 
 Plus clean a few typos in docs and comments.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPjU5OPd5QIZ9jqqOGXyLc2htIW0FAml9K+8ACgkQGXyLc2ht
 IW2N0xAAyYZgbZIYsnSkHUHkCNsnHGOxAfm7D7LzCnCoPQlLGuN+wDZ8a2NABuoH
 nKYnBim685xv3Lwlr2WVMPoSezTRCdeNNN6xjkfkv8XOpPpgyB4xDR2LyubcWSsE
 LE0fx3SEkfY1Itc3tKdmWauaGXSGk6xzrzlZ5yCB37UC6Ml5vfbr/Pz3BDNpG2D1
 whHMatP31DlNGaxGENG0Ze+PGt9qEgkfvbkWj0nXKqB6uh2jXvYq+G0t7yHx3Evq
 TwsiyQM3SpmzmZ1T0smPdflbWSqBCtGyH9TCVAAf5SSQCpZzmVt3O3AxMZNbaT9w
 OeH6OpOnOhKcGat3DKfEO7VmUDfbo7jaCoruQRVH7FRgFafeYXsGbmmvbHS8HQi8
 iXavmmbQuQ4WSDPSePxfQuX6KV+ooVg8NH2pO7MpqSZnHDkMPjufw60Bd4qntPvi
 N+QwmrRp34/k2kfAArM63xtfA1o2xNh4w1hRZeaTwot7FnKSe6tr1v1cg3JbtoPT
 DwMbTCwy4EskwRNbBSV4Ie5gtRcWHhB3uuu4edfluFsI5GIxuQka+Td3ABHWv7jG
 //HVoE+4QWGH7992nSYGMA2zpLbgy5FfJZnraqFoHvcNDtWiipNXAwh4CEG0oQ5m
 OxwLf8GcX2ZTbm3XePdzNebwmowedO69IY9juFSiP380AsrCpjw=
 =C6JY
 -----END PGP SIGNATURE-----

Merge tag 'rust-fixes-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux

Pull Rust fixes from Miguel Ojeda:
 "Toolchain and infrastructure:

   - Trigger rebuilds of the newly added 'proc-macro2' crate (and its
     dependencies) when the Rust compiler version changes

   - Fix error in '.rsi' targets (macro expanding single targets) under
     'O=' pointing to an external (not subdir) folder

   - Fix off-by-one line number in 'rustdoc' KUnit tests

   - Add '-fdiagnostics-show-context' to GCC flags skipped by 'bindgen'

   - Clean objtool warning by adding one more 'noreturn' function

   - Clean 'libpin_init_internal.{so,dylib}' in 'mrproper'

  'kernel' crate:

   - Fix build error when using expressions in formatting arguments

   - Mark 'num::Bounded::__new()' as unsafe and clean documentation
     accordingly

   - Always inline functions using 'build_assert' with arguments

   - Fix 'rusttest' build error providing the right 'isize_atomic_repr'
     type for the host

  'macros' crate:

   - Fix 'rusttest' build error by ignoring example

  rust-analyzer:

   - Remove assertion that was not true for distributions like NixOS

   - Add missing dependency edges and fix editions for 'quote' and
     sysroot crates to provide correct IDE support

  DRM Tyr:

   - Fix build error by adding missing dependency on 'CONFIG_COMMON_CLK'

  Plus clean a few typos in docs and comments"

* tag 'rust-fixes-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (28 commits)
  rust: num: bounded: clean __new documentation and comments
  scripts: generate_rust_analyzer: fix resolution of #[pin_data] macros
  drm/tyr: depend on `COMMON_CLK` to fix build error
  rust: sync: atomic: Provide stub for `rusttest` 32-bit hosts
  kbuild: rust: clean libpin_init_internal in mrproper
  rust: proc-macro2: rebuild if the version text changes
  rust: num: bounded: add missing comment for always inlined function
  rust: sync: refcount: always inline functions using build_assert with arguments
  rust: bits: always inline functions using build_assert with arguments
  scripts: generate_rust_analyzer: compile sysroot with correct edition
  scripts: generate_rust_analyzer: compile quote with correct edition
  scripts: generate_rust_analyzer: quote: treat `core` and `std` as dependencies
  scripts: generate_rust_analyzer: syn: treat `std` as a dependency
  scripts: generate_rust_analyzer: remove sysroot assertion
  rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target
  scripts: generate_rust_analyzer: Add pin_init_internal deps
  scripts: generate_rust_analyzer: Add pin_init -> compiler_builtins dep
  scripts: generate_rust_analyzer: Add compiler_builtins -> core dep
  rust: macros: ignore example with module parameters
  rust: num: bounded: mark __new as unsafe
  ...
2026-01-30 16:15:59 -08:00
Thomas Weißschuh
adbbd9714f scripts: headers_install.sh: Remove config leak ignore machinery
There are no entries left to ignore and none should be added again.

Remove the now unused logic.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-30 16:46:17 +01:00
Thomas Weißschuh
e356da6014 x86/uapi: Stop leaking kconfig references to userspace
UAPI headers are not supposed to leak references to kconfig symbols.
These won't be set when building userspace. Hide the kconfig reference
behind 'if defined(__KERNEL__)', so it will be stripped by
headers_install.sh. The result for userspace will be the same, but the
exceptions in headers_install.sh can also be removed.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-30 16:46:17 +01:00
Thomas Weißschuh
9b21aa9f03 nios2: uapi: Remove custom asm/swab.h from UAPI
UAPI headers are not supposed to leak references to kconfig symbols.
They are undefined there in any case. As all actual definitions of this
header are guarded behind a kconfig symbol, for userspace the header is
always identical to its asm-generic variant.

Make the custom UAPI header a kernel-internal one, so the leaks of
kconfig symbols are fixed and userspace will instead use
asm-generic/swab.h directly.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/lkml/93c55086-931a-4282-a94c-de4954047fa9@app.fastmail.com/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-30 16:46:17 +01:00
Thomas Weißschuh
49d7819aa9 ARM: uapi: Drop PSR_ENDSTATE
The symbol PSR_ENDSTATE is pointless for userspace. Drop it from the
UAPI headers and instead inline it into the only two callers.

As as side-effect, remove a leak of an internal kconfig symbol through
the UAPI headers.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/lkml/d2ad12f2-3d65-4bef-890c-65d78a33d790@app.fastmail.com/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-30 16:46:17 +01:00
Thomas Weißschuh
b4171fd0b0 ARC: Always use SWAPE instructions for __arch_swab32()
Since commit 67a697e7576 ("ARC: retire ARC750 support") all supported
CPUs have the 'swape' instruction.

Always use the implementation of __arch_swabe() which uses 'swape'.
ARCH_USE_BUILTIN_BSWAP can not be used as that results on libcalls on
-mcpu=arc700.

As as side-effect, remove a leak of an internal kconfig symbol through
the UAPI headers.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/lkml/0ae2688a-5a22-405b-adaf-9b5ad712b245@app.fastmail.com/
Suggested-by: Vineet Gupta <vgupta@kernel.org>
Link: https://lore.kernel.org/lkml/a033a402-e3c5-4982-9fff-b6a4c55817ae@kernel.org/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-30 16:46:17 +01:00
Michal Suchanek
76c73cfde7
kbuild: dummy-tools: Add python3
DRM_MSM_VALIDATE_XML depends on a python feature. Add a dummy python
interpreter to make it possible to configure this option with dummy
tools.

Fixes: b587f413ca ("drm/msm/gen_header: allow skipping the validation")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Acked-by: Rob Clark <robin.clark@oss.qualcomm.com>
Link: https://patch.msgid.link/20260121105801.1827-1-msuchanek@suse.de
[nathan: Remove empty shell comment line]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-01-29 17:12:13 -07:00
Josh Poimboeuf
a8ff29f0ca livepatch/klp-build: Require Clang assembler >= 20
Some special sections specify their ELF section entsize, for example:

  .pushsection section, "M", @progbits, 8

The entsize (8 in this example) is needed by objtool klp-diff for
extracting individual entries.

Clang assembler versions older than 20 silently ignore the above
construct and set entsize to 0, resulting in the following error:

  .discard.annotate_data: missing special section entsize or annotations

Add a klp-build check to prevent the use of Clang assembler versions
prior to 20.

Fixes: 24ebfcd65a ("livepatch/klp-build: Introduce klp-build script for generating livepatch modules")
Reported-by: Song Liu <song@kernel.org>
Acked-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/957fd52e375d0e2cfa3ac729160da995084a7f5e.1769562556.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
2026-01-29 10:09:26 -08:00
Michael S. Tsirkin
74bc5f69bd checkpatch: special-case cacheline group macros
Currently, cacheline group macros trigger checkpatch warnings.
For example:

  $ ./scripts/checkpatch.pl -g ba7e025a6c84aed012421468d83639e5dae982b0
  WARNING: Missing a blank line after declarations
  #58: FILE: drivers/gpio/gpio-virtio.c:32:
  +	struct virtio_gpio_response res;
  +	__dma_from_device_group_end();

  $ ./scripts/checkpatch.pl -g 5d4cc87414
  WARNING: Missing a blank line after declarations
  #267: FILE: include/net/sock.h:431:
  +	int			sk_rcvlowat;
  +	__cacheline_group_end(sock_read_rx);

But these are not actually statements - the following macros
all expand to zero-length fields:
  __cacheline_group_begin()
  __cacheline_group_end()
  __cacheline_group_begin_aligned()
  __cacheline_group_end_aligned()
  __dma_from_device_group_begin()
  __dma_from_device_group_end()

Add them to $declaration_macros so checkpatch recognizes this fact.

Message-ID: <b345bb7e2d4e23672e3e5d1b283754dc11c7d8cd.1767647872.git.mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2026-01-28 15:32:16 -05:00
Ethan Zuo
6d60354ea2
kbuild: Fix permissions of modules.builtin.modinfo
Currently, modules.builtin.modinfo is created with executable permissions
(0755). This is because after commit 39cfd5b121 ("kbuild: extract
modules.builtin.modinfo from vmlinux.unstripped"), modules.builtin.modinfo
is extracted from vmlinux.unstripped using objcopy. When extracting
sections, objcopy inherits attributes from the source ELF file.

Since modules.builtin.modinfo is a data file and not an executable,
it should have regular file permissions (0644). The executable bit
can trigger warnings in Debian's Lintian tool.

Explicitly remove the executable bit after generation.

Fixes: 39cfd5b121 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped")
Signed-off-by: Ethan Zuo <yuxuan.zuo@outlook.com>
Link: https://patch.msgid.link/SY0P300MB0609F6916B24ADF65502940B9C91A@SY0P300MB0609.AUSP300.PROD.OUTLOOK.COM
Signed-off-by: Nicolas Schier <nsc@kernel.org>
2026-01-28 11:51:25 +01:00
Nathan Chancellor
62089b8048
kbuild: rpm-pkg: Generate debuginfo package manually
Commit a7c699d090 ("kbuild: rpm-pkg: build a debuginfo RPM") adjusted
the __spec_install_post macro to include __os_install_post, which runs
brp-strip. This ends up stripping module signatures, breaking loading
modules with lockdown enabled.

Undo most of the changes of the aforementioned debuginfo patch and
mirror commit 16c36f8864 ("kbuild: deb-pkg: use build ID instead of
debug link for dbg package") in kernel.spec to generate a functionally
equivalent debuginfo package while avoiding touching the modules after
they have already been signed during modules_install.

Fixes: a7c699d090 ("kbuild: rpm-pkg: build a debuginfo RPM")
Reported-by: Holger Kiehl <Holger.Kiehl@dwd.de>
Closes: https://lore.kernel.org/68c375f6-e07e-fec-434d-6a45a4f1390@praktifix.dwd.de/
Tested-by: Holger Kiehl <Holger.Kiehl@dwd.de>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://patch.msgid.link/20260121-fix-module-signing-binrpm-pkg-v1-1-8fc5832b6cbc@kernel.org
Signed-off-by: Nicolas Schier <nsc@kernel.org>
2026-01-28 11:51:24 +01:00
Miguel Ojeda
99ba0fa10d pin-init changes for v7.0
Added:
 
 - '&'static mut MaybeUninit<T>' now implements 'InPlaceWrite'. This
   enables users to use external allocation mechanisms such as
   'static_cell'.
 
 - Gary Guo as a Maintainer.
 
 Changed:
 
 - Rewrote all proc-macros ('[pin_]init!', '#[pin_data]',
   '#[pinned_drop]', 'derive([Maybe]Zeroable)'),  using 'syn' with better
   diagnostics.
 
 - 'derive([Maybe]Zeroable)' now support tuple structs.
 
 - '[pin_]init!' now supports attributes on fields (such as
   '#[cfg(...)]').
 
 - Add a '#[default_error(<type>)]' attribute to '[pin_]init!' to
   override the default error (when no '? Error' is specified).
 
 - Support packed struct in '[pin_]init!' with
   '#[disable_initialized_field_access]'.
 
 Removed:
 
 - 'try_[pin_]init!' have been removed in favor of merging their feature
   with '[pin_]init!'. The kernel's own 'try_[pin_]init!' macros have
   been updated to use the 'default_error' attribute.
 
 Fixed:
 
 - Corrected 'T: Sized' bounds to 'T: ?Sized' in the generated
   'PinnedDrop' check by '#[pin_data]'.
 -----BEGIN PGP SIGNATURE-----
 
 iIgEABYKADAWIQQjEG/HT3UeYLJybLTomd21rZaLygUCaXHz9BIcbG9zc2luQGtl
 cm5lbC5vcmcACgkQ6Jndta2Wi8q1AQD+IAf84ueKJ8vEfiSRP0IgteZakHxFHCyZ
 Uqsn0MQRUTgA/238IG65zYkrT8jaT3FY+LSoaNRY4rNS8/l9bxFWqqwA
 =dBj9
 -----END PGP SIGNATURE-----

Merge tag 'pin-init-v7.0' of https://github.com/Rust-for-Linux/linux into rust-next

Pull pin-init updates from Benno Lossin:
 "Added:

   - Implement 'InPlaceWrite' for '&'static mut MaybeUninit<T>'. This
     enables users to use external allocation mechanisms such as
     'static_cell'.

   - Add Gary Guo as a Maintainer.

  Changed:

   - Rewrote all proc-macros ('[pin_]init!', '#[pin_data]',
     '#[pinned_drop]', 'derive([Maybe]Zeroable)'), using 'syn' with
     better diagnostics.

   - Support tuple structs in 'derive([Maybe]Zeroable)'.

   - Support attributes on fields in '[pin_]init!' (such as
     '#[cfg(...)]').

   - Add a '#[default_error(<type>)]' attribute to '[pin_]init!' to
     override the default error (when no '? Error' is specified).

   - Support packed structs in '[pin_]init!' with
     '#[disable_initialized_field_access]'.

  Removed:

   - Remove 'try_[pin_]init!' in favor of merging their feature
     with '[pin_]init!'. Update the kernel's own 'try_[pin_]init!'
     macros to use the 'default_error' attribute.

  Fixed:

   - Correct 'T: Sized' bounds to 'T: ?Sized' in the generated
     'PinnedDrop' check by '#[pin_data]'."

* tag 'pin-init-v7.0' of https://github.com/Rust-for-Linux/linux:
  rust: pin-init: Implement `InPlaceWrite<T>` for `&'static mut MaybeUninit<T>`
  MAINTAINERS: add Gary Guo to pin-init
  rust: pin-init: internal: init: simplify Zeroable safety check
  rust: pin-init: internal: init: add escape hatch for referencing initialized fields
  rust: pin-init: internal: init: add support for attributes on initializer fields
  rust: init: use `#[default_error(err)]` for the initializer macros
  rust: pin-init: add `#[default_error(<type>)]` attribute to initializer macros
  rust: pin-init: rewrite the initializer macros using `syn`
  rust: pin-init: add `?Sized` bounds to traits in `#[pin_data]` macro
  rust: pin-init: rewrite `#[pin_data]` using `syn`
  rust: pin-init: rewrite the `#[pinned_drop]` attribute macro using `syn`
  rust: pin-init: rewrite `derive(Zeroable)` and `derive(MaybeZeroable)` using `syn`
  rust: pin-init: internal: add utility API for syn error handling
  rust: pin-init: add `syn` dependency and remove `proc-macro[2]` and `quote` workarounds
  rust: pin-init: allow the crate to refer to itself as `pin-init` in doc tests
  rust: pin-init: remove `try_` versions of the initializer macros
2026-01-28 00:19:32 +01:00
Josh Poimboeuf
78c268f378 livepatch/klp-build: Fix klp-build vs CONFIG_MODULE_SRCVERSION_ALL
When building a patch to a single-file kernel module with
CONFIG_MODULE_SRCVERSION_ALL enabled, the klp-build module link fails in
modpost:

  Diffing objects
  drivers/md/raid0.o: changed function: raid0_run
  Building patch module: livepatch-0001-patch-raid0_run.ko
  drivers/md/raid0.c: No such file or directory
  ...

The problem here is that klp-build copied drivers/md/.raid0.o.cmd to the
module build directory, but it didn't also copy over the input source
file listed in the .cmd file:

  source_drivers/md/raid0.o := drivers/md/raid0.c

So modpost dies due to the missing .c file which is needed for
calculating checksums for CONFIG_MODULE_SRCVERSION_ALL.

Instead of copying the original .cmd file, just create an empty one.
Modpost only requires that it exists.  The original object's build
dependencies are irrelevant for the frankenobjects used by klp-build.

Fixes: 24ebfcd65a ("livepatch/klp-build: Introduce klp-build script for generating livepatch modules")
Reported-by: Song Liu <song@kernel.org>
Tested-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/c41b6629e02775e4c1015259aa36065b3fe2f0f3.1769471792.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
2026-01-27 08:20:51 -08:00
SeungJong Ha
e440bc5c19 scripts: generate_rust_analyzer: fix resolution of #[pin_data] macros
Currently, rust-analyzer fails to properly resolve structs annotated with
`#[pin_data]`. This prevents IDE features like "Go to Definition" from
working correctly for those structs.

Add the missing configuration to `generate_rust_analyzer.py` to ensure
the `pin-init` crate macros are handled correctly.

Signed-off-by: SeungJong Ha <engineer.jjhama@gmail.com>
Fixes: d7659acca7 ("rust: add pin-init crate build infrastructure")
Cc: stable@vger.kernel.org
Tested-by: Tamir Duberstein <tamird@kernel.org>
Acked-by: Tamir Duberstein <tamird@kernel.org>
Acked-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Jesung Yang <y.j3ms.n@gmail.com>
Link: https://patch.msgid.link/20260123-fix-pin-init-crate-dependecies-v2-1-bb1c2500e54c@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-26 02:19:29 +01:00
Linus Torvalds
b83a8ff87a tracing fixes for v6.19:
- Fix a crash with passing a stacktrace between synthetic events
 
   A synthetic event is an event that combines two events into a single event
   that can display fields from both events as well as the time delta that
   took place between the events. It can also pass a stacktrace from the
   first event so that it can be displayed by the synthetic event (this is
   useful to get a stacktrace of a task scheduling out when blocked and
   recording the time it was blocked for).
 
   A synthetic event can also connect an existing synthetic event to another
   event. An issue was found that if the first synthetic event had a stacktrace
   as one of its fields, and that stacktrace field was passed to the new
   synthetic event to be displayed, it would crash the kernel. This was due to
   the stacktrace not being saved as a stacktrace but was still marked as one.
   When the stacktrace was read, it would try to read an array but instead read
   the integer metadata of the stacktrace and dereferenced a bad value.
 
   Fix this by saving the stacktrace field as a stracktrace.
 
 - Fix possible overflow in cmp_mod_entry() compare function
 
   A binary search is used to find a module address and if the addresses are
   greater than 2GB apart it could lead to truncation and cause a bad search
   result. Use normal compares instead of a subtraction between addresses to
   calculate the compare value.
 
 - Fix output of entry arguments in function graph tracer
 
   Depending on the configurations enabled, the entry can be two different
   types that hold the argument array. The macro FGRAPH_ENTRY_ARGS() is used
   to find the correct arguments from the given type. One location was missed
   and still referenced the arguments directly via entry->args and could
   produce the wrong value depending on how the kernel was configured.
 
 - Fix memory leak in scripts/tracepoint-update build tool
 
   If the array fails to allocate, the memory for the values needs to be
   freed and was not. Free the allocated values if the array failed to
   allocate.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYKADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCaXUQLxQccm9zdGVkdEBn
 b29kbWlzLm9yZwAKCRAp5XQQmuv6qgsJAQDgtWH9DWUkJKgzXTkiOA0l8JArPOVf
 tCSMla2wWJA70QD/as2ptacYAFU9v1oxO5YIgsKOLFBF68ZUIhJtvXpqtAE=
 =JeC6
 -----END PGP SIGNATURE-----

Merge tag 'trace-v6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull tracing fixes from Steven Rostedt:

 - Fix a crash with passing a stacktrace between synthetic events

   A synthetic event is an event that combines two events into a single
   event that can display fields from both events as well as the time
   delta that took place between the events. It can also pass a
   stacktrace from the first event so that it can be displayed by the
   synthetic event (this is useful to get a stacktrace of a task
   scheduling out when blocked and recording the time it was blocked
   for).

   A synthetic event can also connect an existing synthetic event to
   another event. An issue was found that if the first synthetic event
   had a stacktrace as one of its fields, and that stacktrace field was
   passed to the new synthetic event to be displayed, it would crash the
   kernel. This was due to the stacktrace not being saved as a
   stacktrace but was still marked as one. When the stacktrace was read,
   it would try to read an array but instead read the integer metadata
   of the stacktrace and dereferenced a bad value.

   Fix this by saving the stacktrace field as a stacktrace.

 - Fix possible overflow in cmp_mod_entry() compare function

   A binary search is used to find a module address and if the addresses
   are greater than 2GB apart it could lead to truncation and cause a
   bad search result. Use normal compares instead of a subtraction
   between addresses to calculate the compare value.

 - Fix output of entry arguments in function graph tracer

   Depending on the configurations enabled, the entry can be two
   different types that hold the argument array. The macro
   FGRAPH_ENTRY_ARGS() is used to find the correct arguments from the
   given type. One location was missed and still referenced the
   arguments directly via entry->args and could produce the wrong value
   depending on how the kernel was configured.

 - Fix memory leak in scripts/tracepoint-update build tool

   If the array fails to allocate, the memory for the values needs to be
   freed and was not. Free the allocated values if the array failed to
   allocate.

* tag 'trace-v6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  scripts/tracepoint-update: Fix memory leak in add_string() on failure
  function_graph: Fix args pointer mismatch in print_graph_retval()
  tracing: Avoid possible signed 64-bit truncation
  tracing: Fix crash on synthetic stacktrace field usage
2026-01-24 17:18:57 -08:00
Weigang He
361eb853c6 scripts/tracepoint-update: Fix memory leak in add_string() on failure
When realloc() fails in add_string(), the function returns -1 but leaves
*vals pointing to the previously allocated memory. This can cause memory
leaks in callers like make_trace_array() that return on error without
freeing the partially built array.

Fix this by freeing *vals and setting it to NULL when realloc() fails.
This makes the error handling self-contained in add_string() so callers
don't need to handle cleanup on failure.

This bug is found by my static analysis tool and my code review.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fixes: e30f8e61e2 ("tracing: Add a tracepoint verification check at build time")
Link: https://patch.msgid.link/20260119114542.1714405-1-geoffreyhe2@gmail.com
Signed-off-by: Weigang He <geoffreyhe2@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2026-01-23 13:34:45 -05:00
Mikko Rapeli
a5b46cd1a0
scripts: kconfig: merge_config.sh: warn on duplicate input files
External scripts like yocto kernel scc may provide
same input config fragment multiple times. This may
be a bug since processing same fragments multiple times
can be time consuming.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Link: https://patch.msgid.link/20260122105751.2186609-3-mikko.rapeli@linaro.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-01-22 15:58:45 -07:00
Mikko Rapeli
dfc97e1c5d
scripts: kconfig: merge_config.sh: use awk in checks too
Converting from shell/sed/grep loop to awk improves runtime
checks of Yocto genericarm64 kernel config from 20 seconds
to under 1 second. The checks catch this kind of issues:

WARNING: CONFIG_BLK_DEV_DM differs:
Requested value: CONFIG_BLK_DEV_DM=y
Actual value:    CONFIG_BLK_DEV_DM=m
WARNING: CONFIG_SECURITY_NETWORK differs:
Requested value: CONFIG_SECURITY_NETWORK=n
Actual value:    CONFIG_SECURITY_NETWORK=y
WARNING: Value requested for CONFIG_ARM64_BTI_KERNEL not in final .config
Requested value: CONFIG_ARM64_BTI_KERNEL=y
Actual value:

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Link: https://patch.msgid.link/20260122105751.2186609-2-mikko.rapeli@linaro.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-01-22 15:58:27 -07:00
Anders Roxell
5fa9b82cbc
scripts: kconfig: merge_config.sh: refactor from shell/sed/grep to awk
merge_config.sh shell/sed/grep loop scales poorly and is slow.
With Yocto genericarm64 kernel and around 190 config fragments
the script takes more than 20 minutes to run on a fast build machine.
Re-implementation with awk does the same job in 10 seconds.
Using awk since it is likely available in the build environments
and using perl, python etc would introduce more complex runtime
dependencies. awk is good enough and lot better than shell/sed/grep.

Output stays the same but changed execution time means that
parallel job output may be ordered differently.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Link: https://patch.msgid.link/20260122105751.2186609-1-mikko.rapeli@linaro.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-01-22 15:58:25 -07:00
Ard Biesheuvel
a081b57892
kallsyms: Get rid of kallsyms relative base
When the kallsyms relative base was introduced, per-CPU variable
references on x86_64 SMP were implemented as offsets into the respective
per-CPU region, rather than offsets relative to the location of the
variable's template in the kernel image, which is how other
architectures implement it.

This required kallsyms to reason about the difference between the two,
and the sign of the value in the kallsyms_offsets[] array was used to
distinguish them. This meant that negative offsets were not permitted
for ordinary variables, and so it was crucial that the relative base was
chosen such that all offsets were positive numbers.

This is no longer needed: instead, the offsets can simply be encoded as
values in the range -/+ 2 GiB, which is precisely what PC32 relocations
provide on most architectures. So it is possible to simplify the logic,
and just use _text as the anchor directly, and let the linker calculate
the final value based on the location of the entry itself.

Some architectures (nios2, extensa) do not support place-relative
relocations at all, but these are all 32-bit and non-relocatable, and so
there is no need for place-relative relocations in the first place, and
the actual symbol values can just be stored directly.

This makes all entries in the kallsyms_offsets[] array visible as
place-relative references in the ELF metadata, which will be important
when implementing ELF-based fg-kaslr.

Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://patch.msgid.link/20260116093359.2442297-6-ardb+git@google.com
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-01-22 15:58:22 -07:00
Guillaume Tucker
8f989b3b6f
scripts: add tool to run containerized builds
Add a 'scripts/container' tool written in Python to run any command in
the source tree from within a container.  This can typically be used
to call 'make' with a compiler toolchain image to run reproducible
builds but any arbitrary command can be run too.  Only Docker and
Podman are supported in this initial version.

Add a new entry to MAINTAINERS accordingly.

Link: https://lore.kernel.org/all/affb7aff-dc9b-4263-bbd4-a7965c19ac4e@gtucker.io/
Signed-off-by: Guillaume Tucker <gtucker@gtucker.io>
Tested-by: Nicolas Schier <nsc@kernel.org>
Acked-by: Nicolas Schier <nsc@kernel.org>
Link: https://patch.msgid.link/9b8da20157e409e8fa3134d2101678779e157256.1769090419.git.gtucker@gtucker.io
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-01-22 15:30:48 -07:00
Thomas Gleixner
99d2592023 rseq: Implement sys_rseq_slice_yield()
Provide a new syscall which has the only purpose to yield the CPU after the
kernel granted a time slice extension.

sched_yield() is not suitable for that because it unconditionally
schedules, but the end of the time slice extension is not required to
schedule when the task was already preempted. This also allows to have a
strict check for termination to catch user space invoking random syscalls
including sched_yield() from a time slice extension region.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20251215155708.929634896@linutronix.de
2026-01-22 11:11:17 +01:00
Ihor Solodrai
26ad5d6e76 scripts/gen-btf.sh: Use CONFIG_SHELL for execution
According to the docs [1], kernel build scripts should be executed via
CONFIG_SHELL, which is sh by default.

Fixup gen-btf.sh to be runnable with sh, and use CONFIG_SHELL at every
invocation site.

See relevant discussion for context [2].

[1] https://docs.kernel.org/kbuild/makefiles.html#script-invocation
[2] https://lore.kernel.org/bpf/CAADnVQ+dxmSNoJAGb6xV89ffUCKXe5CJXovXZt22nv5iYFV5mw@mail.gmail.com/

Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Tested-by: Gary Guo <gary@garyguo.net>
Reported-by: Gary Guo <gary@garyguo.net>
Suggested-by: Thomas Weißschuh <linux@weissschuh.net>
Fixes: 522397d05e ("resolve_btfids: Change in-place update with raw binary output")
Link: https://lore.kernel.org/r/20260121181617.820300-1-ihor.solodrai@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-01-21 12:36:32 -08:00
Jonathan Corbet
a9e732c12d docs: add a scripts/kernel-doc symbolic link
Some folks evidently have muscle memory expecting kernel-doc to be under
scripts/.  Now that we have moved it to tools/docs, leave behind a symbolic
link to reduce the global profanity count.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2026-01-20 15:57:06 -07:00
Jonathan Corbet
eba6ffd126 docs: kdoc: move kernel-doc to tools/docs
kernel-doc is the last documentation-related tool still living outside of
the tools/docs directory; the time has come to move it over.

[mchehab: fixed kdoc lib location]

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <311d17e403524349940a8b12de6b5e91e554b1f4.1768823489.git.mchehab+huawei@kernel.org>
2026-01-20 15:31:06 -07:00
Mauro Carvalho Chehab
6cc45ee5df docs: kdoc: some fixes to kernel-doc comments
There are some typos and English errors in the comments of kernel‑doc.py.

Locate them with the help of an LLM (gpt‑oss 14B), executed locally
with this prompt:

        review English grammar and syntax at the comments on the code below:
        <cat scripts/kernel-doc.py>

While LLM worked fine for the task of doing an English grammar review
for strings, being able to distinguish them from the actual code, it
was not is perfect: some things required manual work to fix.

-

While here, replace:

    "/**" with: ``/**``

As, if we ever rename this script to kernel_doc.py and add it to
Sphinx ext autodoc, we want to avoid this warning:

    scripts/kernel_doc.py:docstring of kernel_doc:10: WARNING: Inline strong start-string without end-string. [docutils]

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <ec08727f22ad35e6c58519c1f425f216f14b701c.1768823489.git.mchehab+huawei@kernel.org>
2026-01-20 15:31:06 -07:00
Mauro Carvalho Chehab
bd28e99720 docs: kdoc: ensure that comments are using our coding style
Along kernel-doc libs, we opted to have all comments starting/ending
with a blank comment line. Use the same style here.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <50e430acd333a500719205e80ab3b2d297edcd7d.1768823489.git.mchehab+huawei@kernel.org>
2026-01-20 15:31:06 -07:00
Mauro Carvalho Chehab
802774d853 docs: kdoc: avoid error_count overflows
The glibc library limits the return code to 8 bits. We need to
stick to this limit when using sys.exit(error_count).

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <233d1674db99ed8feb405a2f781de350f0fba0ac.1768823489.git.mchehab+huawei@kernel.org>
2026-01-20 15:31:05 -07:00
Tamir Duberstein
6c37b6841a rust: kunit: replace kernel::c_str! with C-Strings
C-String literals were added in Rust 1.77. Replace instances of
`kernel::c_str!` with C-String literals where possible.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Reviewed-by: David Gow <davidgow@google.com>
Link: https://patch.msgid.link/20251222-cstr-kunit-v1-1-39d999672f35@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-19 01:13:23 +01:00
Tamir Duberstein
ac3c50b9a2 scripts: generate_rust_analyzer: compile sysroot with correct edition
Use `core_edition` for all sysroot crates rather than just core as all
were updated to edition 2024 in Rust 1.87.

Fixes: f4daa80d6b ("rust: compile libcore with edition 2024 for 1.87+")
Signed-off-by: Tamir Duberstein <tamird@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260116-rust-analyzer-sysroot-v2-1-094aedc33208@kernel.org
[ Added `>`s to make the quote a single block. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-18 20:26:29 +01:00
Tamir Duberstein
bc83834c15 scripts: generate_rust_analyzer: compile quote with correct edition
Our copy of the quote crate uses edition 2018, thus generate the correct
rust-analyzer configuration for it.

Fixes: 88de91cc1c ("rust: quote: enable support in kbuild")
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Reviewed-by: Jesung Yang <y.j3ms.n@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260115-rust-analyzer-quote-edition-v1-1-d492f880dde4@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-18 20:26:29 +01:00
Jesung Yang
3a50257e56 scripts: generate_rust_analyzer: quote: treat core and std as dependencies
Fix the `generate_rust_analyzer.py` script to ensure that the
`rust-project.json` it produces includes `core` and `std` in the `deps`
field for the `quote` crate.

`quote` directly references items from both `core` and `std`, so
rust-analyzer should treat them as dependencies to provide correct IDE
support.

For example, the `::quote::ToTokens` trait is implemented for
`std::ffi::CString`. With `std` listed in the `deps` field,
rust-analyzer can show the expected autocomplete for the
`::quote::ToTokens` methods on `std::ffi::CString`.

Verified the explicit uses of `core` and `std` using:

    grep -rnE 'core::|std::' rust/quote/

Fixes: 88de91cc1c ("rust: quote: enable support in kbuild")
Signed-off-by: Jesung Yang <y.j3ms.n@gmail.com>
Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Link: https://patch.msgid.link/cef76fc1105481d219953c8552eb5eb07dac707a.1764062688.git.y.j3ms.n@gmail.com
[ Reworded title. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-18 20:26:26 +01:00
Jesung Yang
87417cc95b scripts: generate_rust_analyzer: syn: treat std as a dependency
Fix the `generate_rust_analyzer.py` script to ensure that the
`rust-project.json` it produces includes `std` in the `deps` field for
the `syn` crate.

`syn` directly references items from `std`, so rust-analyzer should
treat it as a dependency to provide correct IDE support.

For example, `syn::Punctuated` contains fields of type `Vec<..>` and
`Option<..>`, both of which come from the standard library prelude.
With `std` listed in the `deps` field, rust-analyzer can infer the types
of these fields instead of showing `{unknown}`.

Verified the explicit uses of `std` using:

    grep -rn 'std::' rust/syn/

Fixes: 737401751a ("rust: syn: enable support in kbuild")
Signed-off-by: Jesung Yang <y.j3ms.n@gmail.com>
Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Tested-by: Tamir Duberstein <tamird@gmail.com>
Link: https://patch.msgid.link/6dbdf6e1c1639ae381ca9ab7041f84728ffa2267.1764062688.git.y.j3ms.n@gmail.com
[ Reworded title. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-18 20:25:26 +01:00
Onur Özkan
1b83ef9f7a scripts: generate_rust_analyzer: remove sysroot assertion
With nixpkgs's rustc, rust-src component is not bundled
with the compiler by default and is instead provided from
a separate store path, so this assumption does not hold.

The assertion assumes these paths are in the same location
which causes `make LLVM=1 rust-analyzer` to fail on NixOS.

Link: https://rust-for-linux.zulipchat.com/#narrow/stream/x/topic/x/near/565284250
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Reviewed-by: Gary Guo <gary@garyguo.net>
Fixes: fe99216357 ("rust: Support latest version of `rust-analyzer`")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20251224135343.32476-1-work@onurozkan.dev
[ Reworded title. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-18 20:24:15 +01:00
Miguel Ojeda
af20ae33e7 rust: kbuild: give --config-path to rustfmt in .rsi target
`rustfmt` is configured via the `.rustfmt.toml` file in the source tree,
and we apply `rustfmt` to the macro expanded sources generated by the
`.rsi` target.

However, under an `O=` pointing to an external folder (i.e. not just
a subdir), `rustfmt` will not find the file when checking the parent
folders. Since the edition is configured in this file, this can lead to
errors when it encounters newer syntax, e.g.

    error: expected one of `!`, `.`, `::`, `;`, `?`, `where`, `{`, or an operator, found `"rust_minimal"`
      --> samples/rust/rust_minimal.rsi:29:49
       |
    28 | impl ::kernel::ModuleMetadata for RustMinimal {
       |                                               - while parsing this item list starting here
    29 |     const NAME: &'static ::kernel::str::CStr = c"rust_minimal";
       |                                                 ^^^^^^^^^^^^^^ expected one of 8 possible tokens
    30 | }
       | - the item list ends here
       |
       = note: you may be trying to write a c-string literal
       = note: c-string literals require Rust 2021 or later
       = help: pass `--edition 2024` to `rustc`
       = note: for more on editions, read https://doc.rust-lang.org/edition-guide

A workaround is to use `RUSTFMT=n`, which is documented in the `Makefile`
help for cases where macro expanded source may happen to break `rustfmt`
for other reasons, but this is not one of those cases.

One solution would be to pass `--edition`, but we want `rustfmt` to
use the entire configuration, even if currently we essentially use the
default configuration.

Thus explicitly give the path to the config file to `rustfmt` instead.

Reported-by: Alice Ryhl <aliceryhl@google.com>
Fixes: 2f7ab1267d ("Kbuild: add Rust support")
Cc: stable@vger.kernel.org
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260115183832.46595-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-18 20:24:15 +01:00
Peter Zijlstra
fd69b2f7d5 compiler: Use __typeof_unqual__() for __unqual_scalar_typeof()
The recent changes to get_unaligned() resulted in a new sparse warning:

   net/rds/ib_cm.c:96:35: sparse: sparse: incorrect type in argument 1 (different modifiers) @@     expected void * @@     got restricted __be64 const * @@
   net/rds/ib_cm.c:96:35: sparse:     expected void *
   net/rds/ib_cm.c:96:35: sparse:     got restricted __be64 const *

The updated get_unaligned_t() uses __unqual_scalar_typeof() to get an
unqualified type. This works correctly for the compilers, but fails for
sparse when the data type is __be64 (or any other __beNN variant).

On sparse runs (C=[12]) __beNN types are annotated with
__attribute__((bitwise)).

That annotation allows sparse to detect incompatible operations on __beNN
variables, but it also prevents sparse from evaluating the _Generic() in
__unqual_scalar_typeof() and map __beNN to a unqualified scalar type, so it
ends up with the default, i.e. the original qualified type of a 'const
__beNN' pointer. That then ends up as the first pointer argument to
builtin_memcpy(), which obviously causes the above sparse warnings.

The sparse git tree supports typeof_unqual() now, which allows to use it
instead of the _Generic() based __unqual_scalar_typeof(). With that sparse
correctly evaluates the unqualified type and keeps the __beNN logic intact.

The downside is that this requires a top of tree sparse build and an old
sparse version will emit a metric ton of incomprehensible error messages
before it dies with a segfault.

Therefore implement a sanity check which validates that the checker is
available and capable of handling typeof_unqual(). Emit a warning if not so
the user can take informed action.

[ tglx: Move the evaluation of USE_TYPEOF_UNQUAL to compiler_types.h so it is
  	set before use and implement the sanity checker ]

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Link: https://patch.msgid.link/87ecnp2zh3.ffs@tglx
Closes: https://lore.kernel.org/oe-kbuild-all/202601150001.sKSN644a-lkp@intel.com/
2026-01-18 10:32:03 +01:00
Benno Lossin
514e4ed2c9 rust: pin-init: add syn dependency and remove proc-macro[2] and quote workarounds
`syn` makes parsing Rust from proc-macros a lot simpler. `pin-init` has
not used `syn` up until now, because the we did not support it. That
changed in commit 54e3eae855 ("Merge patch series "`syn` support""),
so we can finally utilize the added ergonomics of parsing proc-macro
input with `syn`.

Previously we only had the `proc-macro` library available, whereas the
user-space version also used `proc-macro2` and `quote`. Now both are
available, so remove the workarounds.

Due to these changes, clippy emits warnings about unnecessary
`.to_string()` as `proc-macro2` provides an additional `PartialEq` impl
on `Ident`, so the warnings are fixed.

[ Adjusted wording from upstream version and added build system changes
  for the kernel - Benno ]

Co-developed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Signed-off-by: Benno Lossin <lossin@kernel.org>
2026-01-17 10:49:31 +01:00
Alexei Starovoitov
e3d0dbb3b5 Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf after rc5
Cross-merge BPF and other fixes after downstream PR.

No conflicts.

Adjacent:
Auto-merging MAINTAINERS
Auto-merging Makefile
Auto-merging kernel/bpf/verifier.c
Auto-merging kernel/sched/ext.c
Auto-merging mm/memcontrol.c

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-01-14 15:22:01 -08:00
Kees Cook
070580b0b1 checkpatch: Suggest kmalloc_obj family for sizeof allocations
To support shifting away from sized allocation towards typed
allocations, suggest the kmalloc_obj family of macros when a sizeof() is
present in the argument lists.

Link: https://patch.msgid.link/20251203233036.3212363-2-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
2026-01-14 14:43:01 -08:00
Thomas Weißschuh
379b749add
kbuild: Drop superfluous compiler option checks
Many of the compiler option checks are not necessary anymore with the
current supported versions of compilers (clang 15+, GCC 8.1+).

Remove them.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://patch.msgid.link/20260113-kbuild-cc-option-v1-1-011314a0f7f1@weissschuh.net
[nathan: Add minor note about currently supported compilers]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-01-14 14:22:33 -07:00
Tamir Duberstein
74e15ac34b scripts: generate_rust_analyzer: Add pin_init_internal deps
Commit d7659acca7 ("rust: add pin-init crate build infrastructure")
did not add dependencies to `pin_init_internal`, resulting in broken
navigation. Thus add them now.

[ Tamir elaborates:

  "before this series, go-to-symbol from pin_init_internal to e.g.
   proc_macro::TokenStream doesn't work."

     - Miguel ]

Signed-off-by: Tamir Duberstein <tamird@kernel.org>
Reviewed-by: Jesung Yang <y.j3ms.n@gmail.com>
Acked-by: Benno Lossin <lossin@kernel.org>
Fixes: d7659acca7 ("rust: add pin-init crate build infrastructure")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250723-rust-analyzer-pin-init-v1-3-3c6956173c78@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-14 19:53:02 +01:00
Tamir Duberstein
98dcca8553 scripts: generate_rust_analyzer: Add pin_init -> compiler_builtins dep
Add a dependency edge from `pin_init` to `compiler_builtins` to
`scripts/generate_rust_analyzer.py` to match `rust/Makefile`. This has
been incorrect since commit d7659acca7 ("rust: add pin-init crate
build infrastructure").

Signed-off-by: Tamir Duberstein <tamird@kernel.org>
Reviewed-by: Jesung Yang <y.j3ms.n@gmail.com>
Acked-by: Benno Lossin <lossin@kernel.org>
Fixes: d7659acca7 ("rust: add pin-init crate build infrastructure")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250723-rust-analyzer-pin-init-v1-2-3c6956173c78@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-14 19:53:02 +01:00
Tamir Duberstein
5157c328ed scripts: generate_rust_analyzer: Add compiler_builtins -> core dep
Add a dependency edge from `compiler_builtins` to `core` to
`scripts/generate_rust_analyzer.py` to match `rust/Makefile`. This has
been incorrect since commit 8c4555ccc5 ("scripts: add
`generate_rust_analyzer.py`")

Signed-off-by: Tamir Duberstein <tamird@kernel.org>
Reviewed-by: Jesung Yang <y.j3ms.n@gmail.com>
Acked-by: Benno Lossin <lossin@kernel.org>
Fixes: 8c4555ccc5 ("scripts: add `generate_rust_analyzer.py`")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250723-rust-analyzer-pin-init-v1-1-3c6956173c78@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-01-14 19:53:02 +01:00
Arkadiusz Kozdra
baaecfcac5
kconfig: fix static linking of nconf
When running make nconfig with a static linking host toolchain,
the libraries are linked in an incorrect order,
resulting in errors similar to the following:

$ MAKEFLAGS='HOSTCC=cc\ -static' make nconfig
/usr/bin/ld: /usr/lib64/gcc/x86_64-unknown-linux-gnu/14.2.1/../../../../lib64/libpanel.a(p_new.o): in function `new_panel':
(.text+0x13): undefined reference to `_nc_panelhook_sp'
/usr/bin/ld: (.text+0x6c): undefined reference to `_nc_panelhook_sp'

Fixes: 1c5af5cf93 ("kconfig: refactor ncurses package checks for building mconf and nconf")
Signed-off-by: Arusekk <floss@arusekk.pl>
Link: https://patch.msgid.link/20260110114808.22595-1-floss@arusekk.pl
[nsc: Added comment about library order]
Signed-off-by: Nicolas Schier <nsc@kernel.org>
2026-01-14 14:23:20 +01:00
Carlos Llamas
946d462346
kbuild: prefer ${NM} in check-function-names.sh
The check-function-names.sh scripts invokes 'nm' directly and this can
be problematic during cross-compilation when the toolchain is different
from the system's default (e.g. LLVM=1).

  scripts/check-function-names.sh: nm: not found

Let's prefer the ${NM} variable which is already set by kbuild. However,
still fallback to plain 'nm' to ensure the script is still usable when
called directly.

Fixes: 93863f3f85 ("kbuild: Check for functions with ambiguous -ffunction-sections section names")
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://patch.msgid.link/20251218175824.3122690-1-cmllamas@google.com
Signed-off-by: Nicolas Schier <nsc@kernel.org>
2026-01-14 14:13:41 +01:00