Skip to contentSkip to conversation

Rust for 6.18

GIT PULL Merged Miguel Ojeda 2 participants 2 messages Sep 28, 2025 – Oct 1, 2025 Rust

lore
Share & tools
lore

Miguel Ojeda

author maintainer
#0 lore raw

Hi Linus,

This is the next round of the Rust support.

A small one this time. One of the trees I merge (pin-init) is going this cycle through DRM for convenience.

No conflicts expected at this time. Nevertheless, I did a test merge and tested it a bit and it seems fine.

When you merge other trees, you will have some. The resolutions in -next should be fine, except for a rustfmt issue in one, so please remember to double-check that on your merges (it may be solved by the time you get to it).

All commits have been in linux-next for at least four rounds, most for two weeks or more.

Please pull for v6.18 -- thanks!

Cheers,
Miguel

The following changes since commit 76eeb9b8de9880ca38696b2fb56ac45ac0a25c6c:

Linux 6.17-rc5 (2025-09-07 14:22:57 -0700)

are available in the Git repository at:

https://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux.git tags/rust-6.18

for you to fetch changes up to f3f6b3664302e16ef1c6b91034a72df5564d6b8a:

gpu: nova-core: use Alignment for alignment-related operations (2025-09-22 23:56:06 +0200)

----------------------------------------------------------------
Rust changes for v6.18

Toolchain and infrastructure:

- Derive 'Zeroable' for all structs and unions generated by 'bindgen' where possible and corresponding cleanups. To do so, add the 'pin-init' crate as a dependency to 'bindings' and 'uapi'.

It also includes its first use in the 'cpufreq' module, with more to come in the next cycle.

- Add warning to the 'rustdoc' target to detect broken 'srctree/' links and fix existing cases.

- Remove support for unused (since v6.16) host '#[test]'s, simplifying the 'rusttest' target. Tests should generally run within KUnit.

'kernel' crate:

- Add 'ptr' module with a new 'Alignment' type, which is always a power of two and is used to validate that a given value is a valid alignment and to perform masking and alignment operations:

       // Checked at build time.
       assert_eq!(Alignment::new::<16>().as_usize(), 16);

       // Checked at runtime.
       assert_eq!(Alignment::new_checked(15), None);

       assert_eq!(Alignment::of::<u8>().log2(), 0);

       assert_eq!(0x25u8.align_down(Alignment::new::<0x10>()), 0x20);
       assert_eq!(0x5u8.align_up(Alignment::new::<0x10>()), Some(0x10));
       assert_eq!(u8::MAX.align_up(Alignment::new::<0x10>()), None);

It also includes its first use in Nova.

- Add 'core::mem::{align,size}_of{,_val}' to the prelude, matching Rust 1.80.0.

- Keep going with the steps on our migration to the standard library 'core::ffi::CStr' type (use 'kernel::{fmt, prelude::fmt!}' and use upstream method names).

- 'error' module: improve 'Error::from_errno' and 'to_result' documentation, including examples/tests.

- 'sync' module: extend 'aref' submodule documentation now that it exists, and more updates to complete the ongoing move of 'ARef' and 'AlwaysRefCounted' to 'sync::aref'.

- 'list' module: add an example/test for 'ListLinksSelfPtr' usage.

- 'alloc' module:

- Implement 'Box::pin_slice()', which constructs a pinned slice of elements.

- Provide information about the minimum alignment guarantees of 'Kmalloc', 'Vmalloc' and 'KVmalloc'.

- Take minimum alignment guarantees of allocators for 'ForeignOwnable' into account.

- Remove the 'allocator_test' (including 'Cmalloc').

- Add doctest for 'Vec::as_slice()'.

- Constify various methods.

- 'time' module:

- Add methods on 'HrTimer' that can only be called with exclusive access to an unarmed timer, or from timer callback context.

- Add arithmetic operations to 'Instant' and 'Delta'.

- Add a few convenience and access methods to 'HrTimer' and

     'Instant'.

'macros' crate:

- Reduce collections in 'quote!' macro.

And a few other cleanups and improvements.

----------------------------------------------------------------
Alexandre Courbot (2):
rust: add Alignment type
gpu: nova-core: use Alignment for alignment-related operations

Alice Ryhl (3):
rust: alloc: specify the minimum alignment of each allocator
rust: alloc: take the allocator into account for FOREIGN_ALIGN
rust: alloc: implement Box::pin_slice()

Benno Lossin (4):
rust: add pin-init as a dependency to bindings and uapi
rust: derive Zeroable for all structs & unions generated by bindgen where possible
rust: cpufreq: replace MaybeUninit::zeroed().assume_init() with pin_init::zeroed()
rust: sync: extend module documentation of aref

Boqun Feng (1):
rust: list: Add an example for ListLinksSelfPtr usage

Danilo Krummrich (1):
rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist

Hui Zhu (2):
rust: alloc: kvec: add doc example for as_slice method
rust: alloc: kvec: simplify KUnit test module name to "rust_kvec"

Lyude Paul (9):
rust: hrtimer: Document the return value for HrTimerHandle::cancel()
rust: hrtimer: Add HrTimerInstant
rust: hrtimer: Add HrTimer::raw_forward() and forward()
rust: hrtimer: Add HrTimerCallbackContext and ::forward()
rust: hrtimer: Add forward_now() to HrTimer and HrTimerCallbackContext
rust: time: Add Instant::from_ktime()
rust: hrtimer: Add HrTimer::expires()
rust: time: Implement Add<Delta>/Sub<Delta> for Instant
rust: time: Implement basic arithmetic operations for Delta

Miguel Ojeda (10):
rust: kernel: remove support for unused host #[test]s
rust: alloc: remove allocator_test
Merge tag 'alloc-next-v6.18-2025-09-04' of https://github.com/Rust-for-Linux/linux into rust-next
rust: block: fix srctree/ links
rust: drm: fix srctree/ links
rust: warn if srctree/ links do not exist
rust: prelude: re-export core::mem::{align,size}_of{,_val}
rust: error: improve Error::from_errno documentation
rust: error: improve to_result documentation
Merge tag 'rust-timekeeping-v6.18' of https://github.com/Rust-for-Linux/linux into rust-next

Onur Özkan (3):
rust: make ArrayLayout::new_unchecked a const fn
rust: make kvec::Vec functions const fn
rust: error: add C header links

Ritvik Gupta (1):
rust: kernel: cpu: mark CpuId::current() inline

Shankari Anand (3):
rust: dma: Update ARef and AlwaysRefCounted imports from sync::aref
rust: sync: Update ARef and AlwaysRefCounted imports from sync::aref
rust: task: update ARef and AlwaysRefCounted imports from sync::aref

Tamir Duberstein (21):
gpu: nova-core: use kernel::{fmt,prelude::fmt!}
rust: alloc: use kernel::{fmt,prelude::fmt!}
rust: block: use kernel::{fmt,prelude::fmt!}
rust: device: use kernel::{fmt,prelude::fmt!}
rust: file: use kernel::{fmt,prelude::fmt!}
rust: kunit: use kernel::{fmt,prelude::fmt!}
rust: seq_file: use kernel::{fmt,prelude::fmt!}
rust: sync: use kernel::{fmt,prelude::fmt!}
rust: device: use kernel::{fmt,prelude::fmt!} drm/panic: use core::ffi::CStr method names
rust: auxiliary: use core::ffi::CStr method names
rust: configfs: use core::ffi::CStr method names
rust: cpufreq: use core::ffi::CStr method names
rust: drm: use core::ffi::CStr method names
rust: firmware: use core::ffi::CStr method names
rust: kunit: use core::ffi::CStr method names
rust: miscdevice: use core::ffi::CStr method names
rust: net: use core::ffi::CStr method names
rust: of: use core::ffi::CStr method names
rust: acpi: use core::ffi::CStr method names
rust: macros: reduce collections in quote! macro

 Documentation/gpu/nova/core/todo.rst |   1 -
 drivers/block/rnull.rs               |   2 +-
 drivers/gpu/drm/drm_panic_qr.rs      |   2 +-
 drivers/gpu/nova-core/fb.rs          |   6 +-
 drivers/gpu/nova-core/gpu.rs         |   3 +-
 drivers/gpu/nova-core/regs/macros.rs |   6 +-
 drivers/gpu/nova-core/vbios.rs       |   4 +-
 rust/Makefile                        |  29 ++---
 rust/bindgen_parameters              |   5 +
 rust/bindings/bindings_helper.h      |   1 +
 rust/bindings/lib.rs                 |   8 ++
 rust/kernel/acpi.rs                  |   7 +-
 rust/kernel/alloc.rs                 |  15 +--
 rust/kernel/alloc/allocator.rs       |   8 ++
 rust/kernel/alloc/allocator_test.rs  | 124 -------------------
 rust/kernel/alloc/kbox.rs            |  92 +++++++++++++-
 rust/kernel/alloc/kvec.rs            |  24 ++--
 rust/kernel/alloc/kvec/errors.rs     |   2 +-
 rust/kernel/alloc/layout.rs          |   2 +-
 rust/kernel/auxiliary.rs             |   4 +-
 rust/kernel/block/mq.rs              |   2 +-
 rust/kernel/block/mq/gen_disk.rs     |   4 +-
 rust/kernel/block/mq/raw_writer.rs   |   3 +-
 rust/kernel/configfs.rs              |   4 +-
 rust/kernel/cpu.rs                   |   1 +
 rust/kernel/cpufreq.rs               |   6 +-
 rust/kernel/device.rs                |   6 +-
 rust/kernel/device/property.rs       |  23 ++--
 rust/kernel/dma.rs                   |   2 +-
 rust/kernel/drm/device.rs            |   6 +-
 rust/kernel/drm/driver.rs            |   2 +-
 rust/kernel/drm/file.rs              |   2 +-
 rust/kernel/drm/gem/mod.rs           |   2 +-
 rust/kernel/drm/ioctl.rs             |   2 +-
 rust/kernel/error.rs                 |  66 ++++++++--
 rust/kernel/firmware.rs              |   2 +-
 rust/kernel/fs/file.rs               |   5 +-
 rust/kernel/kunit.rs                 |  14 +--
 rust/kernel/lib.rs                   |   5 +-
 rust/kernel/list.rs                  | 120 ++++++++++++++++++
 rust/kernel/miscdevice.rs            |   2 +-
 rust/kernel/net/phy.rs               |   2 +-
 rust/kernel/of.rs                    |   2 +-
 rust/kernel/prelude.rs               |   5 +-
 rust/kernel/ptr.rs                   | 228 +++++++++++++++++++++++++++++++++++
 rust/kernel/seq_file.rs              |   6 +-
 rust/kernel/sync/arc.rs              |   8 +-
 rust/kernel/sync/aref.rs             |  17 ++-
 rust/kernel/task.rs                  |   7 +-
 rust/kernel/time.rs                  | 163 ++++++++++++++++++++++++-
 rust/kernel/time/hrtimer.rs          | 152 ++++++++++++++++++++++-
 rust/kernel/time/hrtimer/arc.rs      |   9 +-
 rust/kernel/time/hrtimer/pin.rs      |   9 +-
 rust/kernel/time/hrtimer/pin_mut.rs  |  12 +-
 rust/kernel/time/hrtimer/tbox.rs     |   9 +-
 rust/macros/quote.rs                 | 104 ++++++++--------
 rust/uapi/lib.rs                     |   2 +
 samples/rust/rust_configfs.rs        |   2 +-
 samples/rust/rust_dma.rs             |   2 +-
 scripts/generate_rust_analyzer.py    |   4 +-
 scripts/rustdoc_test_gen.rs          |   2 +-
 61 files changed, 1054 insertions(+), 315 deletions(-)
 delete mode 100644 rust/kernel/alloc/allocator_test.rs
 create mode 100644 rust/kernel/ptr.rs