From: Benno Lossin <benno.lossin@proton.me>
To: Alice Ryhl <aliceryhl@google.com>,
Miguel Ojeda <ojeda@kernel.org>,
Matthew Wilcox <willy@infradead.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Kees Cook <keescook@chromium.org>
Cc: "Alex Gaynor" <alex.gaynor@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Martijn Coenen" <maco@android.com>,
"Joel Fernandes" <joel@joelfernandes.org>,
"Carlos Llamas" <cmllamas@google.com>,
"Suren Baghdasaryan" <surenb@google.com>,
"Arnd Bergmann" <arnd@arndb.de>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org,
"Christian Brauner" <brauner@kernel.org>
Subject: Re: [PATCH v5 4/4] rust: add abstraction for `struct page`
Date: Mon, 15 Apr 2024 09:54:07 +0000 [thread overview]
Message-ID: <7918eb1a-2c3a-4c5a-b309-1306573dbd1f@proton.me> (raw)
In-Reply-To: <20240415-alice-mm-v5-4-6f55e4d8ef51@google.com>
On 15.04.24 09:13, Alice Ryhl wrote:
> Adds a new struct called `Page` that wraps a pointer to `struct page`.
> This struct is assumed to hold ownership over the page, so that Rust
> code can allocate and manage pages directly.
>
> The page type has various methods for reading and writing into the page.
> These methods will temporarily map the page to allow the operation. All
> of these methods use a helper that takes an offset and length, performs
> bounds checks, and returns a pointer to the given offset in the page.
>
> This patch only adds support for pages of order zero, as that is all
> Rust Binder needs. However, it is written to make it easy to add support
> for higher-order pages in the future. To do that, you would add a const
> generic parameter to `Page` that specifies the order. Most of the
> methods do not need to be adjusted, as the logic for dealing with
> mapping multiple pages at once can be isolated to just the
> `with_pointer_into_page` method.
>
> Rust Binder needs to manage pages directly as that is how transactions
> are delivered: Each process has an mmap'd region for incoming
> transactions. When an incoming transaction arrives, the Binder driver
> will choose a region in the mmap, allocate and map the relevant pages
> manually, and copy the incoming transaction directly into the page. This
> architecture allows the driver to copy transactions directly from the
> address space of one process to another, without an intermediate copy
> to a kernel buffer.
>
> This code is based on Wedson's page abstractions from the old rust
> branch, but it has been modified by Alice by removing the incomplete
> support for higher-order pages, by introducing the `with_*` helpers
> to consolidate the bounds checking logic into a single place, and by
> introducing gfp flags.
>
> Co-developed-by: Wedson Almeida Filho <wedsonaf@gmail.com>
> Signed-off-by: Wedson Almeida Filho <wedsonaf@gmail.com>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> rust/bindings/bindings_helper.h | 2 +
> rust/helpers.c | 20 ++++
> rust/kernel/lib.rs | 1 +
> rust/kernel/page.rs | 240 ++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 263 insertions(+)
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
--
Cheers,
Benno
next prev parent reply other threads:[~2024-04-15 9:55 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 7:13 [PATCH v5 0/4] Memory management patches needed by Rust Binder Alice Ryhl
2024-04-15 7:13 ` [PATCH v5 1/4] rust: uaccess: add userspace pointers Alice Ryhl
2024-04-15 9:36 ` Benno Lossin
2024-04-15 9:44 ` Alice Ryhl
2024-04-15 9:51 ` Benno Lossin
2024-04-15 21:53 ` Boqun Feng
2024-04-16 9:53 ` Alice Ryhl
2024-04-21 18:08 ` David Laight
2024-04-21 18:37 ` Alice Ryhl
2024-04-21 19:48 ` David Laight
2024-04-22 6:31 ` Alice Ryhl
2024-04-16 5:05 ` Trevor Gross
2024-04-16 9:53 ` Alice Ryhl
2024-04-17 14:28 ` Gary Guo
2024-04-17 14:40 ` Alice Ryhl
2024-04-17 15:27 ` Benno Lossin
2024-04-17 15:35 ` Alice Ryhl
2024-04-15 7:13 ` [PATCH v5 2/4] uaccess: always export _copy_[from|to]_user with CONFIG_RUST Alice Ryhl
2024-04-15 23:05 ` Kees Cook
2024-04-16 9:57 ` Alice Ryhl
2024-04-15 7:13 ` [PATCH v5 3/4] rust: uaccess: add typed accessors for userspace pointers Alice Ryhl
2024-04-16 5:53 ` Trevor Gross
2024-04-16 9:53 ` Alice Ryhl
2024-04-15 7:13 ` [PATCH v5 4/4] rust: add abstraction for `struct page` Alice Ryhl
2024-04-15 8:10 ` Andreas Hindborg
2024-04-15 9:54 ` Benno Lossin [this message]
2024-04-16 5:40 ` Trevor Gross
2024-04-16 9:53 ` Alice Ryhl
2024-04-16 17:47 ` Trevor Gross
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=7918eb1a-2c3a-4c5a-b309-1306573dbd1f@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=arnd@arndb.de \
--cc=arve@android.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=joel@joelfernandes.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maco@android.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=surenb@google.com \
--cc=tkjos@android.com \
--cc=viro@zeniv.linux.org.uk \
--cc=wedsonaf@gmail.com \
--cc=willy@infradead.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