From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE83BC282D0 for ; Tue, 4 Mar 2025 11:51:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41D89280002; Tue, 4 Mar 2025 06:51:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 39A87280001; Tue, 4 Mar 2025 06:51:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C8B7280002; Tue, 4 Mar 2025 06:51:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DB4E4280001 for ; Tue, 4 Mar 2025 06:51:46 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 78D5D1CC29F for ; Tue, 4 Mar 2025 11:51:46 +0000 (UTC) X-FDA: 83183704212.28.7A3F49E Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf05.hostedemail.com (Postfix) with ESMTP id 806D4100003 for ; Tue, 4 Mar 2025 11:51:44 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=wflttoQq; spf=pass (imf05.hostedemail.com: domain of 3T-nGZwkKCIIgroikx4nrmuumrk.iusrot03-ssq1giq.uxm@flex--aliceryhl.bounces.google.com designates 209.85.221.73 as permitted sender) smtp.mailfrom=3T-nGZwkKCIIgroikx4nrmuumrk.iusrot03-ssq1giq.uxm@flex--aliceryhl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741089104; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FY6dwgEh85CdnI1YBamGI2B15sLhic/cMYMUHEd5H6Q=; b=z5T4QOOHthfnNOvWsa0SiyI0Sko/eeWddZnOWeeN3jxr7Mwx5nzPiz5BV9nIrKVAAmeRRR Pn7P6c77rYvjVjYXfrDy+ataTTAEErxK0BKWARwtuqMlwGeyyBeQ1e3IN16WiOxIgtKcKc FjGmbXzSYFiFIsPCdKXqG6QnaWa1OhY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=wflttoQq; spf=pass (imf05.hostedemail.com: domain of 3T-nGZwkKCIIgroikx4nrmuumrk.iusrot03-ssq1giq.uxm@flex--aliceryhl.bounces.google.com designates 209.85.221.73 as permitted sender) smtp.mailfrom=3T-nGZwkKCIIgroikx4nrmuumrk.iusrot03-ssq1giq.uxm@flex--aliceryhl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741089104; a=rsa-sha256; cv=none; b=36gQuLbpkixhNT2Ao/38oqaUe/rIL6qY4xx1w/kK7ze/Da8vl0oyI7XOcQ9eWyhDQ84MeU r6dfuGHrR/jbr93gxc6A6NioapmesJHqyRKdGjouRXkxFF6jyVemukEE9IWRupYm+2J8R4 G4hp057Op0TF1djyBuwkRf+hk3eiddI= Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-3911218d81cso1288448f8f.1 for ; Tue, 04 Mar 2025 03:51:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741089103; x=1741693903; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FY6dwgEh85CdnI1YBamGI2B15sLhic/cMYMUHEd5H6Q=; b=wflttoQq5iaZ8jGKlSsSjHfS5z6PUymqf6CiRDuDFRUCRsM+zyj38BWpwwSwl+CaIn P3MK8rPJ7iu6uOs/1O6SqFnZ1UhZEVfwuMpfcA2DHtaTApjeTxfqMipBBxXyoS3eHHHC KhoPb805qcY6J4fORhUNWOLn6T8wdkXTs11D2KV+GkZhxmIl5ovNj9fGTRHK9/Nz6Y65 VnFKMF6yxkrVc4H60AuBXX4TywI35G+DrXkPoj/cXqPhAk3qbFOZH/oansS5RqZahr+G BKzVBLwNnpEDyfI471Txd2jeWHjRYvtTAIpai0TkMTJgi/goz+kcL9Fv0Ctk6K7XelPc hicw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741089103; x=1741693903; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FY6dwgEh85CdnI1YBamGI2B15sLhic/cMYMUHEd5H6Q=; b=ODPfHRsJ6Xq/N6s9FiYXD2Ig1c+PPc4qysIYjWxd3OGEmYpS6PW2rcLzumW4GLiH6W aeETx0E/nImGpd3JkZ6E7DoOcxLnKC16eQlxNUak2AM9br7tWOQnRomykEpT1teQsOWk Ym1ffMaLLW/xxNOUJ9CWpC3AOHJg2cMD5uVZ/y87wIIefZL71GzqS0PrWOmlW9Ic/Ceu 2JY+8l9H/kUoAq9mlgVGRRTIMSDdytYqbnrzny99MRs3D0Hr/U94LY6qeltclJjoeNHJ etWFnJJC0ZyiRzwtkZ7k3+2SdfJvLlG8ejGmxcuKCpsQFwx4eqdu1yrs/i6vLXabz7w3 cdmA== X-Forwarded-Encrypted: i=1; AJvYcCVnhXhLLLosFGUdK5VHRiiJys8Xt1Dl/U5+3cYPcoXnc66dScke6H3nT32UXTiZNKUOwxAGdcEhlg==@kvack.org X-Gm-Message-State: AOJu0Yz0VmF9Ag8hZagDh2ayjUDG0gbu97U4erhGABY+RPfIIdnFGp4T QLI+V2CtxWUaFJo2OyUPclN9Odz9ChhMYo/dEqxkTgKeZvNcL9aOylP0DVfJ4ONYxDI2d+MDiPO cV1UP6Mj3G27Asg== X-Google-Smtp-Source: AGHT+IGm4nsZI/vYEgQt5jpoUiaQIcNh1YiFhqOzco/4v+8jRzEEZHszMeemsSLPWzO/9Vac4NsOy9qvX2yOtyc= X-Received: from wmqa21.prod.google.com ([2002:a05:600c:3495:b0:43b:c06d:f4fa]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:184e:b0:38a:8ec6:f46f with SMTP id ffacd0b85a97d-390eca81635mr15577155f8f.53.1741089103169; Tue, 04 Mar 2025 03:51:43 -0800 (PST) Date: Tue, 04 Mar 2025 11:49:53 +0000 In-Reply-To: <20250304-vma-v15-0-5c641b31980a@google.com> Mime-Version: 1.0 References: <20250304-vma-v15-0-5c641b31980a@google.com> X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=12083; i=aliceryhl@google.com; h=from:subject:message-id; bh=u2kwrwGBiExjsxacyqk+/8Snd0wRDSSXvlEJXA2mYG0=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBnxulDCLWNnUWnExjUMAWI035TCrmIg+2oXJ8f/ j8huaQA7amJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZ8bpQwAKCRAEWL7uWMY5 RitcD/0fz8xL1+bTMmo3biPjK2JiMAugHxX6jq5r8JZmw8XhrrR7XgO1piCNk/AsWoZPCcjRlwD zDIseuBT+zEE5mWFsJzl/ZwUAVoJVeaU0LzOOeYnYhRn8TWNGwHC1F/VRwbLlgV7r5nGvGgawGZ cP7745ra1sROXxgYq4oY4DTgx/ipUgYrf0HJlA9s+XTXhcMJ9q3plpnmzSRtfyEylU78lttzAeO gqFYvE9bEvAhSDK3/wB95WsPq88Ty2OQg08y/SHglxJ11k6y4Zlkhx0+QRHplvESxLDUSRvJNDM AqfUeLagr99GzYioUTa/H0brhzx/Gx2cK7U3yrauPBfB+I58bhjzTeQO3mhPKMAvHBywOqSckYo s9PBmQFM+dPn1tNsnsGXcfRyiSlPWyY9otL9yFLhG4h7ehr7VMuP5Xej9+C9z7ktMbERvBZNoUq f1CGNr2nDr5+YjdjYgFSWWy5FZ1IKW/rQ0qu7iQpf+uVMb0rfvcYzKUKEUyP3Fb9IZ+GF9TwKfX GbVqJM/Pcf1bsHw7qHkLhandM2JfwgA8K9tgN7U9koxX60phDRmpMsxxVJMQ2EmfNaJxNWIEgr5 XW336KDymEGsetScgZyqIYZ08/lGq9wrG7Zi3qg7+uBbAMh8TN6g4aq3mIQTWVnLKfuXCkunWWQ hQbuUBTEPpLvKPw== X-Mailer: b4 0.14.2 Message-ID: <20250304-vma-v15-2-5c641b31980a@google.com> Subject: [PATCH v15 2/9] mm: rust: add vm_area_struct methods that require read access From: Alice Ryhl To: Miguel Ojeda , Matthew Wilcox , Lorenzo Stoakes , Vlastimil Babka , John Hubbard , "Liam R. Howlett" , Andrew Morton , Greg Kroah-Hartman , Arnd Bergmann , Jann Horn , Suren Baghdasaryan Cc: Alex Gaynor , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Trevor Gross , Linus Torvalds , linux-kernel@vger.kernel.org, linux-mm@kvack.org, rust-for-linux@vger.kernel.org, Alice Ryhl Content-Type: text/plain; charset="utf-8" X-Stat-Signature: iqkdaaqpiqin6ek53qwop3os7hb67ni9 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 806D4100003 X-Rspam-User: X-HE-Tag: 1741089104-920840 X-HE-Meta: U2FsdGVkX19kCXIH67VVT5lAoVoZcaJEqdYsEN4B3XVIPQAMw1NmvCMZJdRmcbwS+RlrVyaBw4p4pCIYmEyRqlu+jxod92C+hZn7wOBHE/sN9tl5EfjE8gmF6E1AkX3xAzbhcwnJSgEoSKfwdvnhghMkdmUGCerngYTAe7ghGaXn06u9UM0bf6kdXOXToZ+zYOft29VtWa0hjG3qo+UYPDYxbuS2N477Npgz+fYP+rd521vamtMpVp53e1ecNj7Nn/oH286lYYOMGtfhufVwx3+A6l/XrC4n2Ddv49fN8DR+aAgDnkho/o53VA+76XfTLL+NFp0UHsS8Ezja3vksOfpWFO18wRfoo6i71ON+92osKuNQxZJdi7UMzKzk3kxIPtNJ8aonFHYLiLu8YPo4Km0c73jHWopeRVLZDP8vd3UM0Q2Hk4VgpHFEZLBXAw4QmhHLAY9MRbgYIqHe6v9gEk/J/Z8AZA/6XJDsnDejGxuCo7IVxFtPQXA2kQ28iEg1fHtCvbbZvCBAU/SxK12umyGQpV8IkiFUozrnHK00LDNYObTTzMcpVQFiAxvMengOc/rk6wUjY9tnci5AxPniexhUHA8u1BHh70Nq7vYUn+Ns+XRhYUUYqEnoLBmKRsTc6DXaofcr616fepq3OICWUy6rU+HLQ3QGXoO+a9goe4vk8e53pLcmJMGqzyUNL7yVZh1lukNFmNTGz4jpnZrmCT2vyOIWOVfGGzSg3qSD+J8LWGG/fGvw1lFAgkI6BG4T+OsE9c9F819bP+O/GrtmYMBhl+Ad4FY0Kgz0li7D1Rykq8Cp/b+zQfMc1nNMzuvRz/E6aB0ST1wmVpfHfb97+ta2oMowtuv9Ugsc1tBfm3UWGftN/52uG8dZWGwYduJKYr3tFCUVD7TflQ8XBauVj/LyBCsu5UkXbJJwgTXu/0Mt5JmOqcibHyNsoxJXDso7JIdlxkx2Yl/tCTViSM6 ufvuMnTL /OJTwrKcZozKxLe/3OR8oMsC+oL5wvOR7ipEHa1MjN5WKH8bRchU9Bce6SKJ+spYBqBVcH20mQjGs1OGfG601440gH/xl4ta4S4yPkAiCghCoojJ1tS2MSRdb8dMg/0zyoeBTqHCEueEgaf6dQDq5e5HKOGmFm0kD7kXLkfYu14O+QUznc6B9ps+0EduzzE5Bs6mhWiQcUF7TE3pI/iiJQ6fOjdpEU5MGvYgVLbFtcrl0K7/4Vbd7AjK8ftFKSwsjHr+C8Rgeiz1c8OohxuUT99tRbU5ljKEgx0RBcs0qTXSU/aiJ3X9jcMV/pw6dpM8BT5EZYNoKniI47f1/sr3Wt9NTwSP+VJbajquNfQeQSfibanX3T2g5VPkrk3yyjIK80W3e45m3hdU4ySU7gmnELScL5WrfAl/sHe8GDSstLP8SAX40Wz9ZfBr5KgrIWppHJyFPxD2m/CCzuFAz4Rz4cffwueT3dcOPedHaGiZlXAyFOuLbzqXGrNwrKH75eWDdiSz4DIGRtK5MIWVTkUVCeT4snyBtWntddFhJGQ2htxO/RaeUV4Pa3Uhuqv2KIbqqghcX5CCP/7VDcv8JERe4zKgb3sNVRL/UodfsXRueis8m50djSQP4lg5GPtm4Z86njgAR0OFDhR2Ntudb38iWNGTWpZeI1MWuOCOH3e61zADKT9AsD7adxQjzFEJxVw+gRjIFB3q6PbDI/yWyZBmKP0dSAPNfi2km+wE8M7bqXKR7gWbvaO7g8TiXtO5PlO2bnnRHLQW7tz2YPjwXktw9bIAdbO7BLENMF6ic X-Bogosity: Ham, tests=bogofilter, spamicity=0.177691, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This adds a type called VmaRef which is used when referencing a vma that you have read access to. Here, read access means that you hold either the mmap read lock or the vma read lock (or stronger). Additionally, a vma_lookup method is added to the mmap read guard, which enables you to obtain a &VmaRef in safe Rust code. This patch only provides a way to lock the mmap read lock, but a follow-up patch also provides a way to just lock the vma read lock. Acked-by: Lorenzo Stoakes Acked-by: Liam R. Howlett Reviewed-by: Jann Horn Reviewed-by: Andreas Hindborg Reviewed-by: Gary Guo Signed-off-by: Alice Ryhl --- rust/helpers/mm.c | 6 ++ rust/kernel/mm.rs | 23 ++++++ rust/kernel/mm/virt.rs | 210 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+) diff --git a/rust/helpers/mm.c b/rust/helpers/mm.c index 7201747a5d314b2b120b30c0b906715c04ca77a5..7b72eb065a3e1173c920f02a440053cf6e93814e 100644 --- a/rust/helpers/mm.c +++ b/rust/helpers/mm.c @@ -37,3 +37,9 @@ void rust_helper_mmap_read_unlock(struct mm_struct *mm) { mmap_read_unlock(mm); } + +struct vm_area_struct *rust_helper_vma_lookup(struct mm_struct *mm, + unsigned long addr) +{ + return vma_lookup(mm, addr); +} diff --git a/rust/kernel/mm.rs b/rust/kernel/mm.rs index 2fb5f440af602cc9a89a040edaee60d88d54168b..8b19dde249789b65d7b92159d131cbf38ba08149 100644 --- a/rust/kernel/mm.rs +++ b/rust/kernel/mm.rs @@ -17,6 +17,8 @@ }; use core::{ops::Deref, ptr::NonNull}; +pub mod virt; + /// A wrapper for the kernel's `struct mm_struct`. /// /// This represents the address space of a userspace process, so each process has one `Mm` @@ -200,6 +202,27 @@ pub struct MmapReadGuard<'a> { _nts: NotThreadSafe, } +impl<'a> MmapReadGuard<'a> { + /// Look up a vma at the given address. + #[inline] + pub fn vma_lookup(&self, vma_addr: usize) -> Option<&virt::VmaRef> { + // SAFETY: By the type invariants we hold the mmap read guard, so we can safely call this + // method. Any value is okay for `vma_addr`. + let vma = unsafe { bindings::vma_lookup(self.mm.as_raw(), vma_addr) }; + + if vma.is_null() { + None + } else { + // SAFETY: We just checked that a vma was found, so the pointer references a valid vma. + // + // Furthermore, the returned vma is still under the protection of the read lock guard + // and can be used while the mmap read lock is still held. That the vma is not used + // after the MmapReadGuard gets dropped is enforced by the borrow-checker. + unsafe { Some(virt::VmaRef::from_raw(vma)) } + } + } +} + impl Drop for MmapReadGuard<'_> { #[inline] fn drop(&mut self) { diff --git a/rust/kernel/mm/virt.rs b/rust/kernel/mm/virt.rs new file mode 100644 index 0000000000000000000000000000000000000000..a66be649f0b8d3dfae8ce2d18b70cb2b283fb7fe --- /dev/null +++ b/rust/kernel/mm/virt.rs @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: GPL-2.0 + +// Copyright (C) 2024 Google LLC. + +//! Virtual memory. +//! +//! This module deals with managing a single VMA in the address space of a userspace process. Each +//! VMA corresponds to a region of memory that the userspace process can access, and the VMA lets +//! you control what happens when userspace reads or writes to that region of memory. +//! +//! The module has several different Rust types that all correspond to the C type called +//! `vm_area_struct`. The different structs represent what kind of access you have to the VMA, e.g. +//! [`VmaRef`] is used when you hold the mmap or vma read lock. Using the appropriate struct +//! ensures that you can't, for example, accidentally call a function that requires holding the +//! write lock when you only hold the read lock. + +use crate::{bindings, mm::MmWithUser, types::Opaque}; + +/// A wrapper for the kernel's `struct vm_area_struct` with read access. +/// +/// It represents an area of virtual memory. +/// +/// # Invariants +/// +/// The caller must hold the mmap read lock or the vma read lock. +#[repr(transparent)] +pub struct VmaRef { + vma: Opaque, +} + +// Methods you can call when holding the mmap or vma read lock (or stronger). They must be usable +// no matter what the vma flags are. +impl VmaRef { + /// Access a virtual memory area given a raw pointer. + /// + /// # Safety + /// + /// Callers must ensure that `vma` is valid for the duration of 'a, and that the mmap or vma + /// read lock (or stronger) is held for at least the duration of 'a. + #[inline] + pub unsafe fn from_raw<'a>(vma: *const bindings::vm_area_struct) -> &'a Self { + // SAFETY: The caller ensures that the invariants are satisfied for the duration of 'a. + unsafe { &*vma.cast() } + } + + /// Returns a raw pointer to this area. + #[inline] + pub fn as_ptr(&self) -> *mut bindings::vm_area_struct { + self.vma.get() + } + + /// Access the underlying `mm_struct`. + #[inline] + pub fn mm(&self) -> &MmWithUser { + // SAFETY: By the type invariants, this `vm_area_struct` is valid and we hold the mmap/vma + // read lock or stronger. This implies that the underlying mm has a non-zero value of + // `mm_users`. + unsafe { MmWithUser::from_raw((*self.as_ptr()).vm_mm) } + } + + /// Returns the flags associated with the virtual memory area. + /// + /// The possible flags are a combination of the constants in [`flags`]. + #[inline] + pub fn flags(&self) -> vm_flags_t { + // SAFETY: By the type invariants, the caller holds at least the mmap read lock, so this + // access is not a data race. + unsafe { (*self.as_ptr()).__bindgen_anon_2.vm_flags } + } + + /// Returns the (inclusive) start address of the virtual memory area. + #[inline] + pub fn start(&self) -> usize { + // SAFETY: By the type invariants, the caller holds at least the mmap read lock, so this + // access is not a data race. + unsafe { (*self.as_ptr()).__bindgen_anon_1.__bindgen_anon_1.vm_start } + } + + /// Returns the (exclusive) end address of the virtual memory area. + #[inline] + pub fn end(&self) -> usize { + // SAFETY: By the type invariants, the caller holds at least the mmap read lock, so this + // access is not a data race. + unsafe { (*self.as_ptr()).__bindgen_anon_1.__bindgen_anon_1.vm_end } + } + + /// Zap pages in the given page range. + /// + /// This clears page table mappings for the range at the leaf level, leaving all other page + /// tables intact, and freeing any memory referenced by the VMA in this range. That is, + /// anonymous memory is completely freed, file-backed memory has its reference count on page + /// cache folio's dropped, any dirty data will still be written back to disk as usual. + /// + /// It may seem odd that we clear at the leaf level, this is however a product of the page + /// table structure used to map physical memory into a virtual address space - each virtual + /// address actually consists of a bitmap of array indices into page tables, which form a + /// hierarchical page table level structure. + /// + /// As a result, each page table level maps a multiple of page table levels below, and thus + /// span ever increasing ranges of pages. At the leaf or PTE level, we map the actual physical + /// memory. + /// + /// It is here where a zap operates, as it the only place we can be certain of clearing without + /// impacting any other virtual mappings. It is an implementation detail as to whether the + /// kernel goes further in freeing unused page tables, but for the purposes of this operation + /// we must only assume that the leaf level is cleared. + #[inline] + pub fn zap_page_range_single(&self, address: usize, size: usize) { + let (end, did_overflow) = address.overflowing_add(size); + if did_overflow || address < self.start() || self.end() < end { + // TODO: call WARN_ONCE once Rust version of it is added + return; + } + + // SAFETY: By the type invariants, the caller has read access to this VMA, which is + // sufficient for this method call. This method has no requirements on the vma flags. The + // address range is checked to be within the vma. + unsafe { + bindings::zap_page_range_single(self.as_ptr(), address, size, core::ptr::null_mut()) + }; + } +} + +/// The integer type used for vma flags. +#[doc(inline)] +pub use bindings::vm_flags_t; + +/// All possible flags for [`VmaRef`]. +pub mod flags { + use super::vm_flags_t; + use crate::bindings; + + /// No flags are set. + pub const NONE: vm_flags_t = bindings::VM_NONE as _; + + /// Mapping allows reads. + pub const READ: vm_flags_t = bindings::VM_READ as _; + + /// Mapping allows writes. + pub const WRITE: vm_flags_t = bindings::VM_WRITE as _; + + /// Mapping allows execution. + pub const EXEC: vm_flags_t = bindings::VM_EXEC as _; + + /// Mapping is shared. + pub const SHARED: vm_flags_t = bindings::VM_SHARED as _; + + /// Mapping may be updated to allow reads. + pub const MAYREAD: vm_flags_t = bindings::VM_MAYREAD as _; + + /// Mapping may be updated to allow writes. + pub const MAYWRITE: vm_flags_t = bindings::VM_MAYWRITE as _; + + /// Mapping may be updated to allow execution. + pub const MAYEXEC: vm_flags_t = bindings::VM_MAYEXEC as _; + + /// Mapping may be updated to be shared. + pub const MAYSHARE: vm_flags_t = bindings::VM_MAYSHARE as _; + + /// Page-ranges managed without `struct page`, just pure PFN. + pub const PFNMAP: vm_flags_t = bindings::VM_PFNMAP as _; + + /// Memory mapped I/O or similar. + pub const IO: vm_flags_t = bindings::VM_IO as _; + + /// Do not copy this vma on fork. + pub const DONTCOPY: vm_flags_t = bindings::VM_DONTCOPY as _; + + /// Cannot expand with mremap(). + pub const DONTEXPAND: vm_flags_t = bindings::VM_DONTEXPAND as _; + + /// Lock the pages covered when they are faulted in. + pub const LOCKONFAULT: vm_flags_t = bindings::VM_LOCKONFAULT as _; + + /// Is a VM accounted object. + pub const ACCOUNT: vm_flags_t = bindings::VM_ACCOUNT as _; + + /// Should the VM suppress accounting. + pub const NORESERVE: vm_flags_t = bindings::VM_NORESERVE as _; + + /// Huge TLB Page VM. + pub const HUGETLB: vm_flags_t = bindings::VM_HUGETLB as _; + + /// Synchronous page faults. (DAX-specific) + pub const SYNC: vm_flags_t = bindings::VM_SYNC as _; + + /// Architecture-specific flag. + pub const ARCH_1: vm_flags_t = bindings::VM_ARCH_1 as _; + + /// Wipe VMA contents in child on fork. + pub const WIPEONFORK: vm_flags_t = bindings::VM_WIPEONFORK as _; + + /// Do not include in the core dump. + pub const DONTDUMP: vm_flags_t = bindings::VM_DONTDUMP as _; + + /// Not soft dirty clean area. + pub const SOFTDIRTY: vm_flags_t = bindings::VM_SOFTDIRTY as _; + + /// Can contain `struct page` and pure PFN pages. + pub const MIXEDMAP: vm_flags_t = bindings::VM_MIXEDMAP as _; + + /// MADV_HUGEPAGE marked this vma. + pub const HUGEPAGE: vm_flags_t = bindings::VM_HUGEPAGE as _; + + /// MADV_NOHUGEPAGE marked this vma. + pub const NOHUGEPAGE: vm_flags_t = bindings::VM_NOHUGEPAGE as _; + + /// KSM may merge identical pages. + pub const MERGEABLE: vm_flags_t = bindings::VM_MERGEABLE as _; +} -- 2.48.1.711.g2feabab25a-goog