The Rust bindings for XArray include a build-time check to ensure that
you can only use the XArray with pointers that are 4-byte aligned.
Because of that, there is currently a build failure if you attempt to
create an XArray<KBox<T>> where T is a 1-byte or 2-byte aligned type.
However, this error is incorrect as KBox<_> is guaranteed to be a
pointer that comes from kmalloc, and kmalloc always produces pointers
that are at least 4-byte aligned.
To fix this, we augment the compile-time logic that computes the
alignment of KBox<_> to take the minimum alignment of its allocator into
account.
This series is based on top of rust-next.
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
Alice Ryhl (2):
rust: alloc: specify the minimum alignment of each allocator
rust: alloc: take the allocator into account for FOREIGN_ALIGN
rust/kernel/alloc.rs | 8 ++++++++
rust/kernel/alloc/allocator.rs | 8 ++++++++
rust/kernel/alloc/kbox.rs | 15 +++++++++++----
rust/kernel/sync/arc.rs | 6 +++---
4 files changed, 30 insertions(+), 7 deletions(-)
---
base-commit: a68a6bef0e75fb9e5aea1399d8538f4e3584dab1
change-id: 20250715-align-min-allocator-b31aee53cbda
Best regards,
--
Alice Ryhl <aliceryhl@google.com>