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

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

- Fix missing KASAN LLVM flags on first build (and fix spurious
rebuilds) by skipping '--target'

- Fix Make < 4.3 build error by using '$(pound)'

- Fix UML build error by removing 'volatile' qualifier from io
helpers

- Fix UML build error by adding 'dma_{alloc,free}_attrs()' helpers

- Clean gendwarfksyms warnings by avoiding to export '__pfx' symbols

- Clean objtool warning by adding a new 'noreturn' function for
1.86.0

- Disable 'needless_continue' Clippy lint due to new 1.86.0 warnings

- Add missing 'ffi' crate to 'generate_rust_analyzer.py'

'pin-init' crate:

- Import a couple fixes from upstream"

* tag 'rust-fixes-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux:
rust: helpers: Add dma_alloc_attrs() and dma_free_attrs()
rust: helpers: Remove volatile qualifier from io helpers
rust: kbuild: use `pound` to support GNU Make < 4.3
objtool/rust: add one more `noreturn` Rust function for Rust 1.86.0
rust: kasan/kbuild: fix missing flags on first build
rust: disable `clippy::needless_continue`
rust: kbuild: Don't export __pfx symbols
rust: pin-init: use Markdown autolinks in Rust comments
rust: pin-init: alloc: restrict `impl ZeroableOption` for `Box` to `T: Sized`
scripts: generate_rust_analyzer: Add ffi crate

+53 -31
+1
MAINTAINERS
··· 7021 S: Supported 7022 W: https://rust-for-linux.com 7023 T: git https://github.com/Rust-for-Linux/linux.git alloc-next 7024 F: rust/kernel/dma.rs 7025 F: samples/rust/rust_dma.rs 7026
··· 7021 S: Supported 7022 W: https://rust-for-linux.com 7023 T: git https://github.com/Rust-for-Linux/linux.git alloc-next 7024 + F: rust/helpers/dma.c 7025 F: rust/kernel/dma.rs 7026 F: samples/rust/rust_dma.rs 7027
-1
Makefile
··· 477 -Wclippy::ignored_unit_patterns \ 478 -Wclippy::mut_mut \ 479 -Wclippy::needless_bitwise_bool \ 480 - -Wclippy::needless_continue \ 481 -Aclippy::needless_lifetimes \ 482 -Wclippy::no_mangle_with_rust_abi \ 483 -Wclippy::undocumented_unsafe_blocks \
··· 477 -Wclippy::ignored_unit_patterns \ 478 -Wclippy::mut_mut \ 479 -Wclippy::needless_bitwise_bool \ 480 -Aclippy::needless_lifetimes \ 481 -Wclippy::no_mangle_with_rust_abi \ 482 -Wclippy::undocumented_unsafe_blocks \
+1 -1
rust/Makefile
··· 368 $(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE 369 $(call if_changed_dep,bindgen) 370 371 - rust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__cfi/ && $$3!~/__odr_asan/ { printf $(2),$$3 }' 372 373 quiet_cmd_exports = EXPORTS $@ 374 cmd_exports = \
··· 368 $(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE 369 $(call if_changed_dep,bindgen) 370 371 + rust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__(pfx|cfi|odr_asan)/ { printf $(2),$$3 }' 372 373 quiet_cmd_exports = EXPORTS $@ 374 cmd_exports = \
+16
rust/helpers/dma.c
···
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/dma-mapping.h> 4 + 5 + void *rust_helper_dma_alloc_attrs(struct device *dev, size_t size, 6 + dma_addr_t *dma_handle, gfp_t flag, 7 + unsigned long attrs) 8 + { 9 + return dma_alloc_attrs(dev, size, dma_handle, flag, attrs); 10 + } 11 + 12 + void rust_helper_dma_free_attrs(struct device *dev, size_t size, void *cpu_addr, 13 + dma_addr_t dma_handle, unsigned long attrs) 14 + { 15 + dma_free_attrs(dev, size, cpu_addr, dma_handle, attrs); 16 + }
+1
rust/helpers/helpers.c
··· 14 #include "cpumask.c" 15 #include "cred.c" 16 #include "device.c" 17 #include "err.c" 18 #include "fs.c" 19 #include "io.c"
··· 14 #include "cpumask.c" 15 #include "cred.c" 16 #include "device.c" 17 + #include "dma.c" 18 #include "err.c" 19 #include "fs.c" 20 #include "io.c"
+17 -17
rust/helpers/io.c
··· 7 return ioremap(offset, size); 8 } 9 10 - void rust_helper_iounmap(volatile void __iomem *addr) 11 { 12 iounmap(addr); 13 } 14 15 - u8 rust_helper_readb(const volatile void __iomem *addr) 16 { 17 return readb(addr); 18 } 19 20 - u16 rust_helper_readw(const volatile void __iomem *addr) 21 { 22 return readw(addr); 23 } 24 25 - u32 rust_helper_readl(const volatile void __iomem *addr) 26 { 27 return readl(addr); 28 } 29 30 #ifdef CONFIG_64BIT 31 - u64 rust_helper_readq(const volatile void __iomem *addr) 32 { 33 return readq(addr); 34 } 35 #endif 36 37 - void rust_helper_writeb(u8 value, volatile void __iomem *addr) 38 { 39 writeb(value, addr); 40 } 41 42 - void rust_helper_writew(u16 value, volatile void __iomem *addr) 43 { 44 writew(value, addr); 45 } 46 47 - void rust_helper_writel(u32 value, volatile void __iomem *addr) 48 { 49 writel(value, addr); 50 } 51 52 #ifdef CONFIG_64BIT 53 - void rust_helper_writeq(u64 value, volatile void __iomem *addr) 54 { 55 writeq(value, addr); 56 } 57 #endif 58 59 - u8 rust_helper_readb_relaxed(const volatile void __iomem *addr) 60 { 61 return readb_relaxed(addr); 62 } 63 64 - u16 rust_helper_readw_relaxed(const volatile void __iomem *addr) 65 { 66 return readw_relaxed(addr); 67 } 68 69 - u32 rust_helper_readl_relaxed(const volatile void __iomem *addr) 70 { 71 return readl_relaxed(addr); 72 } 73 74 #ifdef CONFIG_64BIT 75 - u64 rust_helper_readq_relaxed(const volatile void __iomem *addr) 76 { 77 return readq_relaxed(addr); 78 } 79 #endif 80 81 - void rust_helper_writeb_relaxed(u8 value, volatile void __iomem *addr) 82 { 83 writeb_relaxed(value, addr); 84 } 85 86 - void rust_helper_writew_relaxed(u16 value, volatile void __iomem *addr) 87 { 88 writew_relaxed(value, addr); 89 } 90 91 - void rust_helper_writel_relaxed(u32 value, volatile void __iomem *addr) 92 { 93 writel_relaxed(value, addr); 94 } 95 96 #ifdef CONFIG_64BIT 97 - void rust_helper_writeq_relaxed(u64 value, volatile void __iomem *addr) 98 { 99 writeq_relaxed(value, addr); 100 }
··· 7 return ioremap(offset, size); 8 } 9 10 + void rust_helper_iounmap(void __iomem *addr) 11 { 12 iounmap(addr); 13 } 14 15 + u8 rust_helper_readb(const void __iomem *addr) 16 { 17 return readb(addr); 18 } 19 20 + u16 rust_helper_readw(const void __iomem *addr) 21 { 22 return readw(addr); 23 } 24 25 + u32 rust_helper_readl(const void __iomem *addr) 26 { 27 return readl(addr); 28 } 29 30 #ifdef CONFIG_64BIT 31 + u64 rust_helper_readq(const void __iomem *addr) 32 { 33 return readq(addr); 34 } 35 #endif 36 37 + void rust_helper_writeb(u8 value, void __iomem *addr) 38 { 39 writeb(value, addr); 40 } 41 42 + void rust_helper_writew(u16 value, void __iomem *addr) 43 { 44 writew(value, addr); 45 } 46 47 + void rust_helper_writel(u32 value, void __iomem *addr) 48 { 49 writel(value, addr); 50 } 51 52 #ifdef CONFIG_64BIT 53 + void rust_helper_writeq(u64 value, void __iomem *addr) 54 { 55 writeq(value, addr); 56 } 57 #endif 58 59 + u8 rust_helper_readb_relaxed(const void __iomem *addr) 60 { 61 return readb_relaxed(addr); 62 } 63 64 + u16 rust_helper_readw_relaxed(const void __iomem *addr) 65 { 66 return readw_relaxed(addr); 67 } 68 69 + u32 rust_helper_readl_relaxed(const void __iomem *addr) 70 { 71 return readl_relaxed(addr); 72 } 73 74 #ifdef CONFIG_64BIT 75 + u64 rust_helper_readq_relaxed(const void __iomem *addr) 76 { 77 return readq_relaxed(addr); 78 } 79 #endif 80 81 + void rust_helper_writeb_relaxed(u8 value, void __iomem *addr) 82 { 83 writeb_relaxed(value, addr); 84 } 85 86 + void rust_helper_writew_relaxed(u16 value, void __iomem *addr) 87 { 88 writew_relaxed(value, addr); 89 } 90 91 + void rust_helper_writel_relaxed(u32 value, void __iomem *addr) 92 { 93 writel_relaxed(value, addr); 94 } 95 96 #ifdef CONFIG_64BIT 97 + void rust_helper_writeq_relaxed(u64 value, void __iomem *addr) 98 { 99 writeq_relaxed(value, addr); 100 }
+1 -1
rust/pin-init/examples/pthread_mutex.rs
··· 1 // SPDX-License-Identifier: Apache-2.0 OR MIT 2 3 - // inspired by https://github.com/nbdd0121/pin-init/blob/trunk/examples/pthread_mutex.rs 4 #![allow(clippy::undocumented_unsafe_blocks)] 5 #![cfg_attr(feature = "alloc", feature(allocator_api))] 6 #[cfg(not(windows))]
··· 1 // SPDX-License-Identifier: Apache-2.0 OR MIT 2 3 + // inspired by <https://github.com/nbdd0121/pin-init/blob/trunk/examples/pthread_mutex.rs> 4 #![allow(clippy::undocumented_unsafe_blocks)] 5 #![cfg_attr(feature = "alloc", feature(allocator_api))] 6 #[cfg(not(windows))]
+3 -5
rust/pin-init/src/alloc.rs
··· 17 18 pub extern crate alloc; 19 20 - // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee). 21 - // 22 - // In this case we are allowed to use `T: ?Sized`, since all zeros is the `None` variant and there 23 - // is no problem with a VTABLE pointer being null. 24 - unsafe impl<T: ?Sized> ZeroableOption for Box<T> {} 25 26 /// Smart pointer that can initialize memory in-place. 27 pub trait InPlaceInit<T>: Sized {
··· 17 18 pub extern crate alloc; 19 20 + // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee: 21 + // <https://doc.rust-lang.org/stable/std/option/index.html#representation>). 22 + unsafe impl<T> ZeroableOption for Box<T> {} 23 24 /// Smart pointer that can initialize memory in-place. 25 pub trait InPlaceInit<T>: Sized {
+1 -1
rust/pin-init/src/lib.rs
··· 1447 {<T: ?Sized + Zeroable>} UnsafeCell<T>, 1448 1449 // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee: 1450 - // https://doc.rust-lang.org/stable/std/option/index.html#representation). 1451 Option<NonZeroU8>, Option<NonZeroU16>, Option<NonZeroU32>, Option<NonZeroU64>, 1452 Option<NonZeroU128>, Option<NonZeroUsize>, 1453 Option<NonZeroI8>, Option<NonZeroI16>, Option<NonZeroI32>, Option<NonZeroI64>,
··· 1447 {<T: ?Sized + Zeroable>} UnsafeCell<T>, 1448 1449 // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee: 1450 + // <https://doc.rust-lang.org/stable/std/option/index.html#representation>). 1451 Option<NonZeroU8>, Option<NonZeroU16>, Option<NonZeroU32>, Option<NonZeroU64>, 1452 Option<NonZeroU128>, Option<NonZeroUsize>, 1453 Option<NonZeroI8>, Option<NonZeroI16>, Option<NonZeroI32>, Option<NonZeroI64>,
+2 -2
scripts/Makefile.compiler
··· 79 # Usage: MY_RUSTFLAGS += $(call __rustc-option,$(RUSTC),$(MY_RUSTFLAGS),-Cinstrument-coverage,-Zinstrument-coverage) 80 # TODO: remove RUSTC_BOOTSTRAP=1 when we raise the minimum GNU Make version to 4.4 81 __rustc-option = $(call try-run,\ 82 - echo '#![allow(missing_docs)]#![feature(no_core)]#![no_core]' | RUSTC_BOOTSTRAP=1\ 83 - $(1) --sysroot=/dev/null $(filter-out --sysroot=/dev/null,$(2)) $(3)\ 84 --crate-type=rlib --out-dir=$(TMPOUT) --emit=obj=- - >/dev/null,$(3),$(4)) 85 86 # rustc-option
··· 79 # Usage: MY_RUSTFLAGS += $(call __rustc-option,$(RUSTC),$(MY_RUSTFLAGS),-Cinstrument-coverage,-Zinstrument-coverage) 80 # TODO: remove RUSTC_BOOTSTRAP=1 when we raise the minimum GNU Make version to 4.4 81 __rustc-option = $(call try-run,\ 82 + echo '$(pound)![allow(missing_docs)]$(pound)![feature(no_core)]$(pound)![no_core]' | RUSTC_BOOTSTRAP=1\ 83 + $(1) --sysroot=/dev/null $(filter-out --sysroot=/dev/null --target=%,$(2)) $(3)\ 84 --crate-type=rlib --out-dir=$(TMPOUT) --emit=obj=- - >/dev/null,$(3),$(4)) 85 86 # rustc-option
+9 -3
scripts/generate_rust_analyzer.py
··· 112 cfg=["kernel"], 113 ) 114 115 def append_crate_with_generated( 116 display_name, 117 deps, ··· 137 "exclude_dirs": [], 138 } 139 140 - append_crate_with_generated("bindings", ["core"]) 141 - append_crate_with_generated("uapi", ["core"]) 142 - append_crate_with_generated("kernel", ["core", "macros", "build_error", "pin_init", "bindings", "uapi"]) 143 144 def is_root_crate(build_file, target): 145 try:
··· 112 cfg=["kernel"], 113 ) 114 115 + append_crate( 116 + "ffi", 117 + srctree / "rust" / "ffi.rs", 118 + ["core", "compiler_builtins"], 119 + ) 120 + 121 def append_crate_with_generated( 122 display_name, 123 deps, ··· 131 "exclude_dirs": [], 132 } 133 134 + append_crate_with_generated("bindings", ["core", "ffi"]) 135 + append_crate_with_generated("uapi", ["core", "ffi"]) 136 + append_crate_with_generated("kernel", ["core", "macros", "build_error", "pin_init", "ffi", "bindings", "uapi"]) 137 138 def is_root_crate(build_file, target): 139 try:
+1
tools/objtool/check.c
··· 225 str_ends_with(func->name, "_4core9panicking14panic_nounwind") || 226 str_ends_with(func->name, "_4core9panicking18panic_bounds_check") || 227 str_ends_with(func->name, "_4core9panicking19assert_failed_inner") || 228 str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference") || 229 strstr(func->name, "_4core9panicking13assert_failed") || 230 strstr(func->name, "_4core9panicking11panic_const24panic_const_") ||
··· 225 str_ends_with(func->name, "_4core9panicking14panic_nounwind") || 226 str_ends_with(func->name, "_4core9panicking18panic_bounds_check") || 227 str_ends_with(func->name, "_4core9panicking19assert_failed_inner") || 228 + str_ends_with(func->name, "_4core9panicking30panic_null_pointer_dereference") || 229 str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference") || 230 strstr(func->name, "_4core9panicking13assert_failed") || 231 strstr(func->name, "_4core9panicking11panic_const24panic_const_") ||