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