Skip to content

Commit a9aabb3

Browse files
committed
Merge tag 'rust-6.20-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux
Pull rust updates from Miguel Ojeda: "Toolchain and infrastructure: - Add '__rust_helper' annotation to the C helpers This is needed to inline these helpers into Rust code - Remove imports available via the prelude, treewide This was possible thanks to a new lint in Klint that Gary has implemented -- more Klint-related changes, including initial upstream support, are coming - Deduplicate pin-init flags 'kernel' crate: - Add support for calling a function exactly once with the new 'do_once_lite!' macro (and 'OnceLite' type) Based on this, add 'pr_*_once!' macros to print only once - Add 'impl_flags!' macro for defining common bitflags operations: impl_flags!( /// Represents multiple permissions. #[derive(Debug, Clone, Default, Copy, PartialEq, Eq)] pub struct Permissions(u32); /// Represents a single permission. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Permission { /// Read permission. Read = 1 << 0, /// Write permission. Write = 1 << 1, /// Execute permission. Execute = 1 << 2, } ); let mut f: Permissions = Permission::Read | Permission::Write; assert!(f.contains(Permission::Read)); assert!(!f.contains(Permission::Execute)); f |= Permission::Execute; assert!(f.contains(Permission::Execute)); let f2: Permissions = Permission::Write | Permission::Execute; assert!((f ^ f2).contains(Permission::Read)); assert!(!(f ^ f2).contains(Permission::Write)); - 'bug' module: support 'CONFIG_DEBUG_BUGVERBOSE_DETAILED' in the 'warn_on!' macro in order to show the evaluated condition alongside the file path: ------------[ cut here ]------------ WARNING: [val == 1] linux/samples/rust/rust_minimal.rs:27 at ... Modules linked in: rust_minimal(+) - Add safety module with 'unsafe_precondition_assert!' macro, currently a wrapper for 'debug_assert!', intended to mark the validation of safety preconditions where possible: /// # Safety /// /// The caller must ensure that `index` is less than `N`. unsafe fn set_unchecked(&mut self, index: usize, value: T) { unsafe_precondition_assert!( index < N, "set_unchecked() requires index ({index}) < N ({N})" ); ... } - Add instructions to 'build_assert!' documentation requesting to always inline functions when used with function arguments - 'ptr' module: replace 'build_assert!' with a 'const' one - 'rbtree' module: reduce unsafe blocks on pointer derefs - 'transmute' module: implement 'FromBytes' and 'AsBytes' for inhabited ZSTs, and use it in Nova - More treewide replacements of 'c_str!' with C string literals 'macros' crate: - Rewrite most procedural macros ('module!', 'concat_idents!', '#[export]', '#[vtable]', '#[kunit_tests]') to use the 'syn' parsing library which we introduced last cycle, with better diagnostics This also allows to support '#[cfg]' properly in the '#[vtable]' macro, to support arbitrary types in 'module!' macro (not just an identifier) and to remove several custom parsing helpers we had - Use 'quote!' from the recently vendored 'quote' library and remove our custom one The vendored one also allows us to avoid quoting '"' and '{}' inside the template anymore and editors can now highlight it. In addition, it improves robustness as it eliminates the need for string quoting and escaping - Use 'pin_init::zeroed()' to simplify KUnit code 'pin-init' crate: - Rewrite all procedural macros ('[pin_]init!', '#[pin_data]', '#[pinned_drop]', 'derive([Maybe]Zeroable)') to use the 'syn' parsing library which we introduced last cycle, with better diagnostics - Implement 'InPlaceWrite' for '&'static mut MaybeUninit<T>'. This enables users to use external allocation mechanisms such as 'static_cell' - 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]' - 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 - Correct 'T: Sized' bounds to 'T: ?Sized' in the generated 'PinnedDrop' check by '#[pin_data]' Documentation: - Conclude the Rust experiment MAINTAINERS: - Add "RUST [RUST-ANALYZER]" entry for the rust-analyzer support. Tamir and Jesung will take care of it. They have both been active around it for a while. The new tree will flow through the Rust one - Add Gary as maintainer for "RUST [PIN-INIT]" - Update Boqun and Tamir emails to their kernel.org accounts And a few other cleanups and improvements" * tag 'rust-6.20-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (59 commits) rust: safety: introduce `unsafe_precondition_assert!` macro rust: add `impl_flags!` macro for defining common bitflag operations rust: print: Add pr_*_once macros rust: bug: Support DEBUG_BUGVERBOSE_DETAILED option rust: print: Add support for calling a function exactly once rust: kbuild: deduplicate pin-init flags gpu: nova-core: remove imports available via prelude rust: clk: replace `kernel::c_str!` with C-Strings MAINTAINERS: Update my email address to @kernel.org rust: macros: support `#[cfg]` properly in `#[vtable]` macro. rust: kunit: use `pin_init::zeroed` instead of custom null value rust: macros: rearrange `#[doc(hidden)]` in `module!` macro rust: macros: allow arbitrary types to be used in `module!` macro rust: macros: convert `#[kunit_tests]` macro to use `syn` rust: macros: convert `concat_idents!` to use `syn` rust: macros: convert `#[export]` to use `syn` rust: macros: use `quote!` for `module!` macro rust: macros: use `syn` to parse `module!` macro rust: macros: convert `#[vtable]` macro to use `syn` rust: macros: use `quote!` from vendored crate ...
2 parents f144367 + b8d687c commit a9aabb3

67 files changed

Lines changed: 2772 additions & 3442 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.mailmap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Bjorn Andersson <andersson@kernel.org> <bjorn.andersson@sonymobile.com>
152152
Björn Steinbrink <B.Steinbrink@gmx.de>
153153
Björn Töpel <bjorn@kernel.org> <bjorn.topel@gmail.com>
154154
Björn Töpel <bjorn@kernel.org> <bjorn.topel@intel.com>
155+
Boqun Feng <boqun@kernel.org> <boqun.feng@gmail.com>
155156
Boris Brezillon <bbrezillon@kernel.org> <b.brezillon.dev@gmail.com>
156157
Boris Brezillon <bbrezillon@kernel.org> <b.brezillon@overkiz.com>
157158
Boris Brezillon <bbrezillon@kernel.org> <boris.brezillon@bootlin.com>
@@ -800,6 +801,7 @@ Sven Eckelmann <sven@narfation.org> <sven@open-mesh.com>
800801
Sven Peter <sven@kernel.org> <sven@svenpeter.dev>
801802
Szymon Wilczek <swilczek.lx@gmail.com> <szymonwilczek@gmx.com>
802803
Takashi YOSHII <takashi.yoshii.zj@renesas.com>
804+
Tamir Duberstein <tamird@kernel.org> <tamird@gmail.com>
803805
Tamizh Chelvam Raja <quic_tamizhr@quicinc.com> <tamizhr@codeaurora.org>
804806
Taniya Das <quic_tdas@quicinc.com> <tdas@codeaurora.org>
805807
Tanzir Hasan <tanzhasanwork@gmail.com> <tanzirh@google.com>

Documentation/process/programming-language.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Please refer to ``include/linux/compiler_attributes.h`` for more information.
3434
Rust
3535
----
3636

37-
The kernel has experimental support for the Rust programming language
37+
The kernel has support for the Rust programming language
3838
[rust-language]_ under ``CONFIG_RUST``. It is compiled with ``rustc`` [rustc]_
3939
under ``--edition=2021`` [rust-editions]_. Editions are a way to introduce
4040
small changes to the language that are not backwards compatible.

Documentation/rust/index.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@ Documentation related to Rust within the kernel. To start using Rust
77
in the kernel, please read the quick-start.rst guide.
88

99

10-
The Rust experiment
11-
-------------------
12-
13-
The Rust support was merged in v6.1 into mainline in order to help in
14-
determining whether Rust as a language was suitable for the kernel, i.e. worth
15-
the tradeoffs.
16-
17-
Currently, the Rust support is primarily intended for kernel developers and
18-
maintainers interested in the Rust support, so that they can start working on
19-
abstractions and drivers, as well as helping the development of infrastructure
20-
and tools.
21-
22-
If you are an end user, please note that there are currently no in-tree
23-
drivers/modules suitable or intended for production use, and that the Rust
24-
support is still in development/experimental, especially for certain kernel
25-
configurations.
26-
27-
2810
Code documentation
2911
------------------
3012

MAINTAINERS

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4113,7 +4113,7 @@ F: drivers/input/touchscreen/atmel_mxt_ts.c
41134113
ATOMIC INFRASTRUCTURE
41144114
M: Will Deacon <will@kernel.org>
41154115
M: Peter Zijlstra <peterz@infradead.org>
4116-
M: Boqun Feng <boqun.feng@gmail.com>
4116+
M: Boqun Feng <boqun@kernel.org>
41174117
R: Mark Rutland <mark.rutland@arm.com>
41184118
R: Gary Guo <gary@garyguo.net>
41194119
L: linux-kernel@vger.kernel.org
@@ -4506,7 +4506,7 @@ F: lib/sbitmap.c
45064506

45074507
BLOCK LAYER DEVICE DRIVER API [RUST]
45084508
M: Andreas Hindborg <a.hindborg@kernel.org>
4509-
R: Boqun Feng <boqun.feng@gmail.com>
4509+
R: Boqun Feng <boqun@kernel.org>
45104510
L: linux-block@vger.kernel.org
45114511
L: rust-for-linux@vger.kernel.org
45124512
S: Supported
@@ -11281,7 +11281,7 @@ F: tools/testing/selftests/timers/
1128111281

1128211282
DELAY, SLEEP, TIMEKEEPING, TIMERS [RUST]
1128311283
M: Andreas Hindborg <a.hindborg@kernel.org>
11284-
R: Boqun Feng <boqun.feng@gmail.com>
11284+
R: Boqun Feng <boqun@kernel.org>
1128511285
R: FUJITA Tomonori <fujita.tomonori@gmail.com>
1128611286
R: Frederic Weisbecker <frederic@kernel.org>
1128711287
R: Lyude Paul <lyude@redhat.com>
@@ -14582,7 +14582,7 @@ M: Alan Stern <stern@rowland.harvard.edu>
1458214582
M: Andrea Parri <parri.andrea@gmail.com>
1458314583
M: Will Deacon <will@kernel.org>
1458414584
M: Peter Zijlstra <peterz@infradead.org>
14585-
M: Boqun Feng <boqun.feng@gmail.com>
14585+
M: Boqun Feng <boqun@kernel.org>
1458614586
M: Nicholas Piggin <npiggin@gmail.com>
1458714587
M: David Howells <dhowells@redhat.com>
1458814588
M: Jade Alglave <j.alglave@ucl.ac.uk>
@@ -14741,7 +14741,7 @@ LOCKING PRIMITIVES
1474114741
M: Peter Zijlstra <peterz@infradead.org>
1474214742
M: Ingo Molnar <mingo@redhat.com>
1474314743
M: Will Deacon <will@kernel.org>
14744-
M: Boqun Feng <boqun.feng@gmail.com> (LOCKDEP & RUST)
14744+
M: Boqun Feng <boqun@kernel.org> (LOCKDEP & RUST)
1474514745
R: Waiman Long <longman@redhat.com>
1474614746
L: linux-kernel@vger.kernel.org
1474714747
S: Maintained
@@ -21948,7 +21948,7 @@ M: Frederic Weisbecker <frederic@kernel.org> (kernel/rcu/tree_nocb.h)
2194821948
M: Neeraj Upadhyay <neeraj.upadhyay@kernel.org> (kernel/rcu/tasks.h)
2194921949
M: Joel Fernandes <joelagnelf@nvidia.com>
2195021950
M: Josh Triplett <josh@joshtriplett.org>
21951-
M: Boqun Feng <boqun.feng@gmail.com>
21951+
M: Boqun Feng <boqun@kernel.org>
2195221952
M: Uladzislau Rezki <urezki@gmail.com>
2195321953
R: Steven Rostedt <rostedt@goodmis.org>
2195421954
R: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
@@ -22399,7 +22399,7 @@ RESTARTABLE SEQUENCES SUPPORT
2239922399
M: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2240022400
M: Peter Zijlstra <peterz@infradead.org>
2240122401
M: "Paul E. McKenney" <paulmck@kernel.org>
22402-
M: Boqun Feng <boqun.feng@gmail.com>
22402+
M: Boqun Feng <boqun@kernel.org>
2240322403
L: linux-kernel@vger.kernel.org
2240422404
S: Supported
2240522405
F: include/trace/events/rseq.h
@@ -22922,7 +22922,7 @@ F: tools/verification/
2292222922

2292322923
RUST
2292422924
M: Miguel Ojeda <ojeda@kernel.org>
22925-
R: Boqun Feng <boqun.feng@gmail.com>
22925+
R: Boqun Feng <boqun@kernel.org>
2292622926
R: Gary Guo <gary@garyguo.net>
2292722927
R: Björn Roy Baron <bjorn3_gh@protonmail.com>
2292822928
R: Benno Lossin <lossin@kernel.org>
@@ -22968,6 +22968,7 @@ F: rust/kernel/num/
2296822968

2296922969
RUST [PIN-INIT]
2297022970
M: Benno Lossin <lossin@kernel.org>
22971+
M: Gary Guo <gary@garyguo.net>
2297122972
L: rust-for-linux@vger.kernel.org
2297222973
S: Maintained
2297322974
W: https://rust-for-linux.com/pin-init
@@ -22979,6 +22980,14 @@ F: rust/kernel/init.rs
2297922980
F: rust/pin-init/
2298022981
K: \bpin-init\b|pin_init\b|PinInit
2298122982

22983+
RUST [RUST-ANALYZER]
22984+
M: Tamir Duberstein <tamird@kernel.org>
22985+
R: Jesung Yang <y.j3ms.n@gmail.com>
22986+
L: rust-for-linux@vger.kernel.org
22987+
S: Maintained
22988+
T: git https://github.com/Rust-for-Linux/linux.git rust-analyzer-next
22989+
F: scripts/generate_rust_analyzer.py
22990+
2298222991
RXRPC SOCKETS (AF_RXRPC)
2298322992
M: David Howells <dhowells@redhat.com>
2298422993
M: Marc Dionne <marc.dionne@auristor.com>
@@ -28385,7 +28394,7 @@ F: lib/xarray.c
2838528394
F: tools/testing/radix-tree
2838628395

2838728396
XARRAY API [RUST]
28388-
M: Tamir Duberstein <tamird@gmail.com>
28397+
M: Tamir Duberstein <tamird@kernel.org>
2838928398
M: Andreas Hindborg <a.hindborg@kernel.org>
2839028399
L: rust-for-linux@vger.kernel.org
2839128400
S: Supported

drivers/gpu/nova-core/firmware/fwsec.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
use core::{
1414
marker::PhantomData,
15-
mem::size_of,
1615
ops::Deref, //
1716
};
1817

drivers/gpu/nova-core/firmware/gsp.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
use core::mem::size_of_val;
4-
53
use kernel::{
64
device,
75
dma::{
@@ -34,11 +32,11 @@ use crate::{
3432
/// that scheme before nova-core becomes stable, which means this module will eventually be
3533
/// removed.
3634
mod elf {
37-
use core::mem::size_of;
38-
39-
use kernel::bindings;
40-
use kernel::str::CStr;
41-
use kernel::transmute::FromBytes;
35+
use kernel::{
36+
bindings,
37+
prelude::*,
38+
transmute::FromBytes, //
39+
};
4240

4341
/// Newtype to provide a [`FromBytes`] implementation.
4442
#[repr(transparent)]

drivers/gpu/nova-core/firmware/riscv.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//! Support for firmware binaries designed to run on a RISC-V core. Such firmwares files have a
44
//! dedicated header.
55
6-
use core::mem::size_of;
7-
86
use kernel::{
97
device,
108
firmware::Firmware,

drivers/gpu/nova-core/gsp/commands.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl CommandToGsp for SetRegistry {
142142
}
143143

144144
/// Message type for GSP initialization done notification.
145-
struct GspInitDone {}
145+
struct GspInitDone;
146146

147147
// SAFETY: `GspInitDone` is a zero-sized type with no bytes, therefore it
148148
// trivially has no uninitialized bytes.
@@ -151,13 +151,13 @@ unsafe impl FromBytes for GspInitDone {}
151151
impl MessageFromGsp for GspInitDone {
152152
const FUNCTION: MsgFunction = MsgFunction::GspInitDone;
153153
type InitError = Infallible;
154-
type Message = GspInitDone;
154+
type Message = ();
155155

156156
fn read(
157157
_msg: &Self::Message,
158158
_sbuffer: &mut SBufferIter<array::IntoIter<&[u8], 2>>,
159159
) -> Result<Self, Self::InitError> {
160-
Ok(GspInitDone {})
160+
Ok(GspInitDone)
161161
}
162162
}
163163

drivers/gpu/nova-core/gsp/sequencer.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22

33
//! GSP Sequencer implementation for Pre-hopper GSP boot sequence.
44
5-
use core::{
6-
array,
7-
mem::{
8-
size_of,
9-
size_of_val, //
10-
},
11-
};
5+
use core::array;
126

137
use kernel::{
148
device,

drivers/gpu/nova-core/sbuffer.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
use core::ops::Deref;
44

5-
use kernel::{
6-
alloc::KVec,
7-
prelude::*, //
8-
};
5+
use kernel::prelude::*;
96

107
/// A buffer abstraction for discontiguous byte slices.
118
///

0 commit comments

Comments
 (0)