On Thu, Jun 04, 2026 at 10:11:17PM +0200, Andreas Hindborg wrote: > From: Asahi Lina <[email protected]> > > This allows Page references to be returned as borrowed references, > without necessarily owning the struct page. > > Signed-off-by: Asahi Lina <[email protected]> > [ Andreas: Fix formatting and add a safety comment. ] > Signed-off-by: Andreas Hindborg <[email protected]> > --- > rust/kernel/page.rs | 38 +++++++++++++++++++++++++------------- > 1 file changed, 25 insertions(+), 13 deletions(-) > > diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs > index 3bdcee0e16a8..844c75e54134 100644 > --- a/rust/kernel/page.rs > +++ b/rust/kernel/page.rs > @@ -10,6 +10,11 @@ > bindings, > error::code::*, > error::Result, > + types::{ > + Opaque, > + Ownable, > + Owned, // > + }, > uaccess::UserSliceReader, // > }; > use core::{ > @@ -105,7 +110,7 @@ pub const fn page_align(addr: usize) -> Option<usize> { > /// > /// [`VBox`]: kernel::alloc::VBox > /// [`Vmalloc`]: kernel::alloc::allocator::Vmalloc > -pub struct BorrowedPage<'a>(ManuallyDrop<Page>, PhantomData<&'a Page>); > +pub struct BorrowedPage<'a>(ManuallyDrop<NonNull<Page>>, PhantomData<&'a > Page>);
BorrowedPage<'a> is no longer needed because it's just &Page. Alice
