2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/rust/kernel
Alice Ryhl dcb81aeab4 mm: rust: add VmaNew for f_ops->mmap()
This type will be used when setting up a new vma in an f_ops->mmap() hook.
Using a separate type from VmaRef allows us to have a separate set of
operations that you are only able to use during the mmap() hook.  For
example, the VM_MIXEDMAP flag must not be changed after the initial setup
that happens during the f_ops->mmap() hook.

To avoid setting invalid flag values, the methods for clearing VM_MAYWRITE
and similar involve a check of VM_WRITE, and return an error if VM_WRITE
is set.  Trying to use `try_clear_maywrite` without checking the return
value results in a compilation error because the `Result` type is marked
#[must_use].

For now, there's only a method for VM_MIXEDMAP and not VM_PFNMAP.  When we
add a VM_PFNMAP method, we will need some way to prevent you from setting
both VM_MIXEDMAP and VM_PFNMAP on the same vma.

Link: https://lkml.kernel.org/r/20250408-vma-v16-6-d8b446e885d9@google.com
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Reviewed-by: Jann Horn <jannh@google.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Cc: Alex Gaynor <alex.gaynor@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Balbir Singh <balbirs@nvidia.com>
Cc: Benno Lossin <benno.lossin@proton.me>
Cc: Björn Roy Baron <bjorn3_gh@protonmail.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Gary Guo <gary@garyguo.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Trevor Gross <tmgross@umich.edu>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-05-11 17:48:25 -07:00
..
alloc rust: allow Rust 1.87.0's clippy::ptr_eq lint 2025-05-07 00:11:02 +02:00
block rust: block: refactor to use &raw mut 2025-03-23 20:39:37 +01:00
fs Rust changes for v6.15 2025-03-30 17:03:26 -07:00
list rust: use derive(CoercePointee) on rustc >= 1.84.0 2025-01-13 23:45:30 +01:00
mm mm: rust: add VmaNew for f_ops->mmap() 2025-05-11 17:48:25 -07:00
net rust: module: introduce authors key 2025-03-10 15:12:17 +01:00
sync Rust changes for v6.15 2025-03-30 17:03:26 -07:00
time Rust hrtimer API for v6.15 2025-03-25 23:41:14 +01:00
.gitignore rust: jump_label: skip formatting generated file 2024-11-20 13:32:42 -05:00
alloc.rs rust: use derive(CoercePointee) on rustc >= 1.84.0 2025-01-13 23:45:30 +01:00
block.rs rust: block: introduce kernel::block::mq module 2024-06-14 07:45:04 -06:00
build_assert.rs rust: add build_error! to the prelude 2025-01-10 00:19:09 +01:00
cred.rs cred,rust: mark Credential methods inline 2025-03-04 17:07:49 -05:00
device_id.rs rust: implement IdArray, IdTable and RawDeviceId 2024-12-20 17:19:25 +01:00
device.rs rust: device: implement device context marker 2025-03-17 08:04:25 +01:00
devres.rs rust: io: fix devres test with new io accessor functions 2025-02-25 07:29:48 +01:00
dma.rs rust: dma: add Send implementation for CoherentAllocation 2025-03-24 20:14:10 +01:00
driver.rs rust: make pin-init its own crate 2025-03-16 21:59:19 +01:00
error.rs Rust changes for v6.15 2025-03-30 17:03:26 -07:00
faux.rs rust/kernel/faux: mark Registration methods inline 2025-03-11 10:42:23 +01:00
firmware.rs rust: firmware: Use ffi::c_char type in FwFunc 2025-04-14 14:13:23 +02:00
fs.rs rust: file: add Rust abstraction for struct file 2024-09-30 13:02:28 +02:00
generated_arch_static_branch_asm.rs.S rust: jump_label: skip formatting generated file 2024-11-20 13:32:42 -05:00
init.rs Rust changes for v6.15 2025-03-30 17:03:26 -07:00
io.rs rust: io: rename io::Io accessors 2025-02-22 15:44:19 +01:00
ioctl.rs rust: start using the #[expect(...)] attribute 2024-10-07 21:39:57 +02:00
jump_label.rs rust: jump_label: skip formatting generated file 2024-11-20 13:32:42 -05:00
kunit.rs rust: kunit: allow to know if we are in a test 2025-03-20 12:27:05 +01:00
lib.rs mm: rust: add abstraction for struct mm_struct 2025-05-11 17:48:24 -07:00
list.rs rust: allow Rust 1.87.0's clippy::ptr_eq lint 2025-05-07 00:11:02 +02:00
miscdevice.rs rust: miscdevice: change how f_ops vtable is constructed 2025-03-07 18:20:36 +01:00
mm.rs mm: rust: add mmput_async support 2025-05-11 17:48:24 -07:00
net.rs rust: core abstractions for network PHY drivers 2023-12-15 09:35:50 +00:00
of.rs rust: of: add of::DeviceId abstraction 2024-12-20 17:21:04 +01:00
page.rs rust: page: remove unnecessary helper function from doctest 2025-01-13 23:44:55 +01:00
pci.rs Driver core updates for 6.15-rc1 2025-04-01 11:02:03 -07:00
pid_namespace.rs rust: add PidNamespace 2024-10-08 15:44:36 +02:00
platform.rs Driver core updates for 6.15-rc1 2025-04-01 11:02:03 -07:00
prelude.rs rust: make pin-init its own crate 2025-03-16 21:59:19 +01:00
print.rs print: use new #[export] macro for rust_fmt_argument 2025-03-09 20:52:46 +01:00
rbtree.rs rust: rbtree: fix comments referring to Box instead of KBox 2025-03-23 19:43:02 +01:00
revocable.rs rust: add Revocable type 2024-12-20 17:19:26 +01:00
security.rs lsm,rust: reword "destroy" -> "release" in SecurityCtx 2025-03-04 15:44:46 -05:00
seq_file.rs Rust changes for v6.15 2025-03-30 17:03:26 -07:00
sizes.rs rust: sizes: add commonly used constants 2024-08-30 10:27:34 +01:00
static_assert.rs rust: static_assert: add static_assert! macro 2022-12-04 01:59:16 +01:00
std_vendor.rs rust: std_vendor: update dbg macro from Rust upstream 2024-10-10 00:33:42 +02:00
str.rs rust: clean Rust 1.88.0's clippy::uninlined_format_args lint 2025-05-07 00:11:47 +02:00
sync.rs Rust changes for v6.15 2025-03-30 17:03:26 -07:00
task.rs Rust changes for v6.15 2025-03-30 17:03:26 -07:00
time.rs rust: hrtimer: add clocksource selection through ClockId 2025-03-22 12:08:54 +01:00
tracepoint.rs rust: add tracepoint support 2024-11-04 16:21:44 -05:00
transmute.rs rust: kernel: move FromBytes and AsBytes traits to a new transmute module 2024-10-10 00:33:42 +02:00
types.rs rust: make pin-init its own crate 2025-03-16 21:59:19 +01:00
uaccess.rs rust: uaccess: name the correct function 2025-03-23 19:45:03 +01:00
workqueue.rs Locking changes for v6.15: 2025-03-24 20:55:03 -07:00