Skip to content

Commit 0bd2f26

Browse files
committed
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
2 parents 51c7960 + c1b4071 commit 0bd2f26

File tree

12 files changed

+53
-31
lines changed

12 files changed

+53
-31
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7021,6 +7021,7 @@ L: rust-for-linux@vger.kernel.org
70217021
S: Supported
70227022
W: https://rust-for-linux.com
70237023
T: git https://github.com/Rust-for-Linux/linux.git alloc-next
7024+
F: rust/helpers/dma.c
70247025
F: rust/kernel/dma.rs
70257026
F: samples/rust/rust_dma.rs
70267027

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ export rust_common_flags := --edition=2021 \
477477
-Wclippy::ignored_unit_patterns \
478478
-Wclippy::mut_mut \
479479
-Wclippy::needless_bitwise_bool \
480-
-Wclippy::needless_continue \
481480
-Aclippy::needless_lifetimes \
482481
-Wclippy::no_mangle_with_rust_abi \
483482
-Wclippy::undocumented_unsafe_blocks \

rust/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_extra = ;
368368
$(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE
369369
$(call if_changed_dep,bindgen)
370370

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 }'
372372

373373
quiet_cmd_exports = EXPORTS $@
374374
cmd_exports = \

rust/helpers/dma.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

rust/helpers/helpers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "cpumask.c"
1515
#include "cred.c"
1616
#include "device.c"
17+
#include "dma.c"
1718
#include "err.c"
1819
#include "fs.c"
1920
#include "io.c"

rust/helpers/io.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,94 +7,94 @@ void __iomem *rust_helper_ioremap(phys_addr_t offset, size_t size)
77
return ioremap(offset, size);
88
}
99

10-
void rust_helper_iounmap(volatile void __iomem *addr)
10+
void rust_helper_iounmap(void __iomem *addr)
1111
{
1212
iounmap(addr);
1313
}
1414

15-
u8 rust_helper_readb(const volatile void __iomem *addr)
15+
u8 rust_helper_readb(const void __iomem *addr)
1616
{
1717
return readb(addr);
1818
}
1919

20-
u16 rust_helper_readw(const volatile void __iomem *addr)
20+
u16 rust_helper_readw(const void __iomem *addr)
2121
{
2222
return readw(addr);
2323
}
2424

25-
u32 rust_helper_readl(const volatile void __iomem *addr)
25+
u32 rust_helper_readl(const void __iomem *addr)
2626
{
2727
return readl(addr);
2828
}
2929

3030
#ifdef CONFIG_64BIT
31-
u64 rust_helper_readq(const volatile void __iomem *addr)
31+
u64 rust_helper_readq(const void __iomem *addr)
3232
{
3333
return readq(addr);
3434
}
3535
#endif
3636

37-
void rust_helper_writeb(u8 value, volatile void __iomem *addr)
37+
void rust_helper_writeb(u8 value, void __iomem *addr)
3838
{
3939
writeb(value, addr);
4040
}
4141

42-
void rust_helper_writew(u16 value, volatile void __iomem *addr)
42+
void rust_helper_writew(u16 value, void __iomem *addr)
4343
{
4444
writew(value, addr);
4545
}
4646

47-
void rust_helper_writel(u32 value, volatile void __iomem *addr)
47+
void rust_helper_writel(u32 value, void __iomem *addr)
4848
{
4949
writel(value, addr);
5050
}
5151

5252
#ifdef CONFIG_64BIT
53-
void rust_helper_writeq(u64 value, volatile void __iomem *addr)
53+
void rust_helper_writeq(u64 value, void __iomem *addr)
5454
{
5555
writeq(value, addr);
5656
}
5757
#endif
5858

59-
u8 rust_helper_readb_relaxed(const volatile void __iomem *addr)
59+
u8 rust_helper_readb_relaxed(const void __iomem *addr)
6060
{
6161
return readb_relaxed(addr);
6262
}
6363

64-
u16 rust_helper_readw_relaxed(const volatile void __iomem *addr)
64+
u16 rust_helper_readw_relaxed(const void __iomem *addr)
6565
{
6666
return readw_relaxed(addr);
6767
}
6868

69-
u32 rust_helper_readl_relaxed(const volatile void __iomem *addr)
69+
u32 rust_helper_readl_relaxed(const void __iomem *addr)
7070
{
7171
return readl_relaxed(addr);
7272
}
7373

7474
#ifdef CONFIG_64BIT
75-
u64 rust_helper_readq_relaxed(const volatile void __iomem *addr)
75+
u64 rust_helper_readq_relaxed(const void __iomem *addr)
7676
{
7777
return readq_relaxed(addr);
7878
}
7979
#endif
8080

81-
void rust_helper_writeb_relaxed(u8 value, volatile void __iomem *addr)
81+
void rust_helper_writeb_relaxed(u8 value, void __iomem *addr)
8282
{
8383
writeb_relaxed(value, addr);
8484
}
8585

86-
void rust_helper_writew_relaxed(u16 value, volatile void __iomem *addr)
86+
void rust_helper_writew_relaxed(u16 value, void __iomem *addr)
8787
{
8888
writew_relaxed(value, addr);
8989
}
9090

91-
void rust_helper_writel_relaxed(u32 value, volatile void __iomem *addr)
91+
void rust_helper_writel_relaxed(u32 value, void __iomem *addr)
9292
{
9393
writel_relaxed(value, addr);
9494
}
9595

9696
#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)
9898
{
9999
writeq_relaxed(value, addr);
100100
}

rust/pin-init/examples/pthread_mutex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0 OR MIT
22

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>
44
#![allow(clippy::undocumented_unsafe_blocks)]
55
#![cfg_attr(feature = "alloc", feature(allocator_api))]
66
#[cfg(not(windows))]

rust/pin-init/src/alloc.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ use crate::{
1717

1818
pub extern crate alloc;
1919

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> {}
2523

2624
/// Smart pointer that can initialize memory in-place.
2725
pub trait InPlaceInit<T>: Sized {

rust/pin-init/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ impl_zeroable! {
14471447
{<T: ?Sized + Zeroable>} UnsafeCell<T>,
14481448

14491449
// 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>).
14511451
Option<NonZeroU8>, Option<NonZeroU16>, Option<NonZeroU32>, Option<NonZeroU64>,
14521452
Option<NonZeroU128>, Option<NonZeroUsize>,
14531453
Option<NonZeroI8>, Option<NonZeroI16>, Option<NonZeroI32>, Option<NonZeroI64>,

scripts/Makefile.compiler

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3))
7979
# Usage: MY_RUSTFLAGS += $(call __rustc-option,$(RUSTC),$(MY_RUSTFLAGS),-Cinstrument-coverage,-Zinstrument-coverage)
8080
# TODO: remove RUSTC_BOOTSTRAP=1 when we raise the minimum GNU Make version to 4.4
8181
__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)\
8484
--crate-type=rlib --out-dir=$(TMPOUT) --emit=obj=- - >/dev/null,$(3),$(4))
8585

8686
# rustc-option

0 commit comments

Comments
 (0)