public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Miguel Ojeda <ojeda@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	stable@vger.kernel.org
Cc: Danilo Krummrich <dakr@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>, Alyssa Ross <hi@alyssa.is>,
	NoisyCoil <noisycoil@disroot.org>,
	patches@lists.linux.dev, Miguel Ojeda <ojeda@kernel.org>
Subject: [PATCH 6.12.y 00/60] `alloc`, `#[expect]` and "Custom FFI"
Date: Fri,  7 Mar 2025 23:49:07 +0100	[thread overview]
Message-ID: <20250307225008.779961-1-ojeda@kernel.org> (raw)

Hi Greg, Sasha,

Please consider this series for 6.12.y. It should apply cleanly on top
of v6.12.18.

These are the patches to backport the `alloc` series for Rust, which
will be useful for Rust Android Binder and others. It also means that,
with this applied, we will not rely on the standard library `alloc` (and
the unstable `cfg` option we used) anymore in any stable kernel that
supports several Rust versions, so e.g. upstream Rust could consider
removing that `cfg` if they needed.

The entire series of cherry-picks apply almost cleanly (only 2 trivial
conflicts) -- to achieve that, I included the `#[expect]` support, which
will make future backports that use that feature easier anyway. That
series also enabled some Clippy warnings. We could reduce the series,
but the end result is warning-free and Clippy is opt-in anyway.
Out-of-tree code could, of course, see some warnings if they use it.

I also included a bunch of Clippy warnings cleanups for the DRM QR Code
to have this series clean up to Rust 1.85.0 (the latest stable), but
I could send them separately if needed.

Finally, I included the "Custom FFI" series backport, which in turn
solves the arm64 + Rust 1.85.0 + `CONFIG_RUST_FW_LOADER_ABSTRACTIONS=y`
issue. It will also make future patches easier to backport, since we
will have the same `ffi::` types.

I tested that the entire series builds between every commit for x86_64
`LLVM=1` with the latest stable and minimum supported Rust compiler
versions. I also ran my usual stable kernel tests on the end result;
that is, boot-tested in QEMU for several architectures etc. In v6.12.18
for loongarch there is an unrelated error that was not there in v6.12.17
when I did a previous test run -- reported separately.

Things could still break, so extra tests on the next -rc from users in
Cc here would be welcome -- thanks!

Cheers,
Miguel

Asahi Lina (1):
  rust: alloc: Fix `ArrayLayout` allocations

Benno Lossin (1):
  rust: alloc: introduce `ArrayLayout`

Danilo Krummrich (28):
  rust: alloc: add `Allocator` trait
  rust: alloc: separate `aligned_size` from `krealloc_aligned`
  rust: alloc: rename `KernelAllocator` to `Kmalloc`
  rust: alloc: implement `ReallocFunc`
  rust: alloc: make `allocator` module public
  rust: alloc: implement `Allocator` for `Kmalloc`
  rust: alloc: add module `allocator_test`
  rust: alloc: implement `Vmalloc` allocator
  rust: alloc: implement `KVmalloc` allocator
  rust: alloc: add __GFP_NOWARN to `Flags`
  rust: alloc: implement kernel `Box`
  rust: treewide: switch to our kernel `Box` type
  rust: alloc: remove extension of std's `Box`
  rust: alloc: add `Box` to prelude
  rust: alloc: implement kernel `Vec` type
  rust: alloc: implement `IntoIterator` for `Vec`
  rust: alloc: implement `collect` for `IntoIter`
  rust: treewide: switch to the kernel `Vec` type
  rust: alloc: remove `VecExt` extension
  rust: alloc: add `Vec` to prelude
  rust: error: use `core::alloc::LayoutError`
  rust: error: check for config `test` in `Error::name`
  rust: alloc: implement `contains` for `Flags`
  rust: alloc: implement `Cmalloc` in module allocator_test
  rust: str: test: replace `alloc::format`
  rust: alloc: update module comment of alloc.rs
  kbuild: rust: remove the `alloc` crate and `GlobalAlloc`
  MAINTAINERS: add entry for the Rust `alloc` module

Ethan D. Twardy (1):
  rust: kbuild: expand rusttest target for macros

Filipe Xavier (2):
  rust: error: make conversion functions public
  rust: error: optimize error type to use nonzero

Gary Guo (3):
  rust: fix size_t in bindgen prototypes of C builtins
  rust: map `__kernel_size_t` and friends also to usize/isize
  rust: use custom FFI integer types

Miguel Ojeda (17):
  rust: workqueue: remove unneeded ``#[allow(clippy::new_ret_no_self)]`
  rust: sort global Rust flags
  rust: types: avoid repetition in `{As,From}Bytes` impls
  rust: enable `clippy::undocumented_unsafe_blocks` lint
  rust: enable `clippy::unnecessary_safety_comment` lint
  rust: enable `clippy::unnecessary_safety_doc` lint
  rust: enable `clippy::ignored_unit_patterns` lint
  rust: enable `rustdoc::unescaped_backticks` lint
  rust: init: remove unneeded `#[allow(clippy::disallowed_names)]`
  rust: sync: remove unneeded
    `#[allow(clippy::non_send_fields_in_send_ty)]`
  rust: introduce `.clippy.toml`
  rust: replace `clippy::dbg_macro` with `disallowed_macros`
  rust: provide proper code documentation titles
  rust: enable Clippy's `check-private-items`
  Documentation: rust: add coding guidelines on lints
  rust: start using the `#[expect(...)]` attribute
  Documentation: rust: discuss `#[expect(...)]` in the guidelines

Thomas Böhler (7):
  drm/panic: avoid reimplementing Iterator::find
  drm/panic: remove unnecessary borrow in alignment_pattern
  drm/panic: prefer eliding lifetimes
  drm/panic: remove redundant field when assigning value
  drm/panic: correctly indent continuation of line in list item
  drm/panic: allow verbose boolean for clarity
  drm/panic: allow verbose version check

 .clippy.toml                             |   9 +
 .gitignore                               |   1 +
 Documentation/rust/coding-guidelines.rst | 148 ++++
 MAINTAINERS                              |   8 +
 Makefile                                 |  15 +-
 drivers/block/rnull.rs                   |   4 +-
 drivers/gpu/drm/drm_panic_qr.rs          |  23 +-
 mm/kasan/kasan_test_rust.rs              |   3 +-
 rust/Makefile                            |  92 +--
 rust/bindgen_parameters                  |   5 +
 rust/bindings/bindings_helper.h          |   1 +
 rust/bindings/lib.rs                     |   6 +
 rust/exports.c                           |   1 -
 rust/ffi.rs                              |  13 +
 rust/helpers/helpers.c                   |   1 +
 rust/helpers/slab.c                      |   6 +
 rust/helpers/vmalloc.c                   |   9 +
 rust/kernel/alloc.rs                     | 150 +++-
 rust/kernel/alloc/allocator.rs           | 208 ++++--
 rust/kernel/alloc/allocator_test.rs      |  95 +++
 rust/kernel/alloc/box_ext.rs             |  89 ---
 rust/kernel/alloc/kbox.rs                | 456 +++++++++++
 rust/kernel/alloc/kvec.rs                | 913 +++++++++++++++++++++++
 rust/kernel/alloc/layout.rs              |  91 +++
 rust/kernel/alloc/vec_ext.rs             | 185 -----
 rust/kernel/block/mq/operations.rs       |  18 +-
 rust/kernel/block/mq/raw_writer.rs       |   2 +-
 rust/kernel/block/mq/tag_set.rs          |   2 +-
 rust/kernel/error.rs                     |  79 +-
 rust/kernel/init.rs                      | 127 ++--
 rust/kernel/init/__internal.rs           |  13 +-
 rust/kernel/init/macros.rs               |  18 +-
 rust/kernel/ioctl.rs                     |   2 +-
 rust/kernel/lib.rs                       |   5 +-
 rust/kernel/list.rs                      |   1 +
 rust/kernel/list/arc_field.rs            |   2 +-
 rust/kernel/net/phy.rs                   |  16 +-
 rust/kernel/prelude.rs                   |   5 +-
 rust/kernel/print.rs                     |   5 +-
 rust/kernel/rbtree.rs                    |  49 +-
 rust/kernel/std_vendor.rs                |  12 +-
 rust/kernel/str.rs                       |  46 +-
 rust/kernel/sync/arc.rs                  |  25 +-
 rust/kernel/sync/arc/std_vendor.rs       |   2 +
 rust/kernel/sync/condvar.rs              |   7 +-
 rust/kernel/sync/lock.rs                 |   8 +-
 rust/kernel/sync/lock/mutex.rs           |   4 +-
 rust/kernel/sync/lock/spinlock.rs        |   4 +-
 rust/kernel/sync/locked_by.rs            |   2 +-
 rust/kernel/task.rs                      |   8 +-
 rust/kernel/time.rs                      |   4 +-
 rust/kernel/types.rs                     | 140 ++--
 rust/kernel/uaccess.rs                   |  23 +-
 rust/kernel/workqueue.rs                 |  29 +-
 rust/macros/lib.rs                       |  14 +-
 rust/macros/module.rs                    |   8 +-
 rust/uapi/lib.rs                         |   6 +
 samples/rust/rust_minimal.rs             |   4 +-
 samples/rust/rust_print.rs               |   1 +
 scripts/Makefile.build                   |   4 +-
 scripts/generate_rust_analyzer.py        |  11 +-
 61 files changed, 2482 insertions(+), 756 deletions(-)
 create mode 100644 .clippy.toml
 create mode 100644 rust/ffi.rs
 create mode 100644 rust/helpers/vmalloc.c
 create mode 100644 rust/kernel/alloc/allocator_test.rs
 delete mode 100644 rust/kernel/alloc/box_ext.rs
 create mode 100644 rust/kernel/alloc/kbox.rs
 create mode 100644 rust/kernel/alloc/kvec.rs
 create mode 100644 rust/kernel/alloc/layout.rs
 delete mode 100644 rust/kernel/alloc/vec_ext.rs

--
2.48.1

             reply	other threads:[~2025-03-07 22:50 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07 22:49 Miguel Ojeda [this message]
2025-03-07 22:49 ` [PATCH 6.12.y 01/60] rust: workqueue: remove unneeded ``#[allow(clippy::new_ret_no_self)]` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 02/60] rust: sort global Rust flags Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 03/60] rust: types: avoid repetition in `{As,From}Bytes` impls Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 04/60] rust: enable `clippy::undocumented_unsafe_blocks` lint Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 05/60] rust: enable `clippy::unnecessary_safety_comment` lint Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 06/60] rust: enable `clippy::unnecessary_safety_doc` lint Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 07/60] rust: enable `clippy::ignored_unit_patterns` lint Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 08/60] rust: enable `rustdoc::unescaped_backticks` lint Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 09/60] rust: init: remove unneeded `#[allow(clippy::disallowed_names)]` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 10/60] rust: sync: remove unneeded `#[allow(clippy::non_send_fields_in_send_ty)]` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 11/60] rust: introduce `.clippy.toml` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 12/60] rust: replace `clippy::dbg_macro` with `disallowed_macros` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 13/60] rust: provide proper code documentation titles Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 14/60] rust: enable Clippy's `check-private-items` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 15/60] Documentation: rust: add coding guidelines on lints Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 16/60] rust: start using the `#[expect(...)]` attribute Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 17/60] Documentation: rust: discuss `#[expect(...)]` in the guidelines Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 18/60] rust: error: make conversion functions public Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 19/60] rust: error: optimize error type to use nonzero Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 20/60] rust: alloc: add `Allocator` trait Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 21/60] rust: alloc: separate `aligned_size` from `krealloc_aligned` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 22/60] rust: alloc: rename `KernelAllocator` to `Kmalloc` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 23/60] rust: alloc: implement `ReallocFunc` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 24/60] rust: alloc: make `allocator` module public Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 25/60] rust: alloc: implement `Allocator` for `Kmalloc` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 26/60] rust: alloc: add module `allocator_test` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 27/60] rust: alloc: implement `Vmalloc` allocator Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 28/60] rust: alloc: implement `KVmalloc` allocator Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 29/60] rust: alloc: add __GFP_NOWARN to `Flags` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 30/60] rust: alloc: implement kernel `Box` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 31/60] rust: treewide: switch to our kernel `Box` type Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 32/60] rust: alloc: remove extension of std's `Box` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 33/60] rust: alloc: add `Box` to prelude Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 34/60] rust: alloc: introduce `ArrayLayout` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 35/60] rust: alloc: implement kernel `Vec` type Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 36/60] rust: alloc: implement `IntoIterator` for `Vec` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 37/60] rust: alloc: implement `collect` for `IntoIter` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 38/60] rust: treewide: switch to the kernel `Vec` type Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 39/60] rust: alloc: remove `VecExt` extension Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 40/60] rust: alloc: add `Vec` to prelude Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 41/60] rust: error: use `core::alloc::LayoutError` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 42/60] rust: error: check for config `test` in `Error::name` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 43/60] rust: alloc: implement `contains` for `Flags` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 44/60] rust: alloc: implement `Cmalloc` in module allocator_test Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 45/60] rust: str: test: replace `alloc::format` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 46/60] rust: alloc: update module comment of alloc.rs Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 47/60] kbuild: rust: remove the `alloc` crate and `GlobalAlloc` Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 48/60] MAINTAINERS: add entry for the Rust `alloc` module Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 49/60] drm/panic: avoid reimplementing Iterator::find Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 50/60] drm/panic: remove unnecessary borrow in alignment_pattern Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 51/60] drm/panic: prefer eliding lifetimes Miguel Ojeda
2025-03-07 22:49 ` [PATCH 6.12.y 52/60] drm/panic: remove redundant field when assigning value Miguel Ojeda
2025-03-07 22:50 ` [PATCH 6.12.y 53/60] drm/panic: correctly indent continuation of line in list item Miguel Ojeda
2025-03-07 22:50 ` [PATCH 6.12.y 54/60] drm/panic: allow verbose boolean for clarity Miguel Ojeda
2025-03-07 22:50 ` [PATCH 6.12.y 55/60] drm/panic: allow verbose version check Miguel Ojeda
2025-03-07 22:50 ` [PATCH 6.12.y 56/60] rust: kbuild: expand rusttest target for macros Miguel Ojeda
2025-03-07 22:50 ` [PATCH 6.12.y 57/60] rust: fix size_t in bindgen prototypes of C builtins Miguel Ojeda
2025-03-07 22:50 ` [PATCH 6.12.y 58/60] rust: map `__kernel_size_t` and friends also to usize/isize Miguel Ojeda
2025-03-07 22:50 ` [PATCH 6.12.y 59/60] rust: use custom FFI integer types Miguel Ojeda
2025-03-07 22:50 ` [PATCH 6.12.y 60/60] rust: alloc: Fix `ArrayLayout` allocations Miguel Ojeda
2025-03-09  9:47 ` [PATCH 6.12.y 00/60] `alloc`, `#[expect]` and "Custom FFI" Greg Kroah-Hartman
2025-03-09 12:41 ` Ilya K
2025-03-09 14:20   ` Miguel Ojeda
2025-03-09 16:27     ` Greg Kroah-Hartman
2025-03-09 20:42       ` [PATCH 6.12.y 0/2] The two missing ones Miguel Ojeda
2025-03-09 20:42         ` [PATCH 6.12.y 1/2] rust: finish using custom FFI integer types Miguel Ojeda
2025-03-13  9:01           ` Sasha Levin
2025-03-09 20:42         ` [PATCH 6.12.y 2/2] rust: map `long` to `isize` and `char` to `u8` Miguel Ojeda
2025-03-13  9:01           ` Sasha Levin
2025-03-13 10:59             ` Miguel Ojeda
2025-03-09 21:02         ` [PATCH 6.12.y 0/2] The two missing ones Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250307225008.779961-1-ojeda@kernel.org \
    --to=ojeda@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hi@alyssa.is \
    --cc=noisycoil@disroot.org \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox