From patchwork Fri Nov 29 16:32:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alice Ryhl X-Patchwork-Id: 13888843 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 EF68FD729EC for ; Fri, 29 Nov 2024 16:33:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 852F76B0092; Fri, 29 Nov 2024 11:33:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 801AD6B0093; Fri, 29 Nov 2024 11:33:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 630576B0095; Fri, 29 Nov 2024 11:33:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4053A6B0092 for ; Fri, 29 Nov 2024 11:33:00 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E14BBA1311 for ; Fri, 29 Nov 2024 16:32:59 +0000 (UTC) X-FDA: 82839676626.21.B614FC1 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf28.hostedemail.com (Postfix) with ESMTP id 72D04C0002 for ; Fri, 29 Nov 2024 16:32:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LqsI9Oe2; spf=pass (imf28.hostedemail.com: domain of 3uOxJZwkKCPkbmjdfszimhpphmf.dpnmjovy-nnlwbdl.psh@flex--aliceryhl.bounces.google.com designates 209.85.128.74 as permitted sender) smtp.mailfrom=3uOxJZwkKCPkbmjdfszimhpphmf.dpnmjovy-nnlwbdl.psh@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=1732897971; 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=a5YzoZTIOzo/0986DnSppxfBI0p8rQsJVoOP2q6LCvk=; b=ZCOKkI5YjgW6i0+TgPUxgxfTGT0YTSlHlYSugpRWGAowdiNPMFwbsyIcuLdUY7jYgw1XpQ 9rEPlF/hpkwGEMB+mlBMhNp9AqZAuh8KPT+URN6RWKSqUpSKSavVuI3NGRX3ec+eoE3f0s vETAypXXjjnIjbADFGebWQlec1L1lSs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LqsI9Oe2; spf=pass (imf28.hostedemail.com: domain of 3uOxJZwkKCPkbmjdfszimhpphmf.dpnmjovy-nnlwbdl.psh@flex--aliceryhl.bounces.google.com designates 209.85.128.74 as permitted sender) smtp.mailfrom=3uOxJZwkKCPkbmjdfszimhpphmf.dpnmjovy-nnlwbdl.psh@flex--aliceryhl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732897971; a=rsa-sha256; cv=none; b=Uu1JfRoJXk4uggUqkmX46yd9NASATBJ1otnHqM8BLMTpxhD27Fbrh8elD3hSK4I0o0tjnc vnN9i+/wB8CqPj8onZWHyfXqodM/jw8R6GQRhC/Qr9OCwWZ9nizb6IppG7BBxwdccPfaXa TwgJLDsRFEyyvM1teX8iONmj2IG2QuY= Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-434a9dce888so14163625e9.0 for ; Fri, 29 Nov 2024 08:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1732897976; x=1733502776; 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=a5YzoZTIOzo/0986DnSppxfBI0p8rQsJVoOP2q6LCvk=; b=LqsI9Oe2xV3TMSkqAVmdfVM6Ev1oRo1xPmwP2MjkNelLVRPhUQ8q6cZllPnW3Lz9yE fGlaH3z8DWry/KvEgoKanVKwblD2VonEP1ePSuFK8HF74u18UmsbAc3LSGaciqDB/qNC VfMce8FsV9DKYGX/ojlkrtMu2J6QlKdTvu9mu7w8Guz3cJMWlVThhZB9MObR8uqgAV/y U7J2EJ0lFOZQHhE2fZwNwQRiHwM38gK9TgCbyN5HLwEowh4b4JRKXwPSBI+3Nj4X1eBP Vgd83tLjc0H8LiW7r6XTdNwdidskpSKlth5Al+wvcVjnCWJZz1rHsvHqz8DF2RbOCXoY u8dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732897976; x=1733502776; 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=a5YzoZTIOzo/0986DnSppxfBI0p8rQsJVoOP2q6LCvk=; b=HE7s8l3RgJrdUpWZTA1sdCKiU860gEnsx8dJUTOBFSGDZ3VuxG4dr9ayIJ9qf9mlFj Aoy3qI+jjKpPrXSDPLG4vz80LAcW4kf5Hth4C+g6YIUxRAZqhLlS2u2DxiiASBPPjexR KG5CPhrEWrQJnv1zujnb8dk7tdZlfiu9lK+KwTjacRW+7K5SKizazw/WRLnX3h1MyJKc 8hyRU4yDS056PAUx76P8nzZJDbWZ8zNwyxVMDFOTRfmo8oTGSVimIepfCs6KibBPQCVj EzxDdSorlAhQHT65zqav0qXidldIPOYywOxBcxIk3Ol/G3P/Ks9Fc1DXpMPmuxbJl4sD IZCA== X-Forwarded-Encrypted: i=1; AJvYcCUPpsEy1TqWtxFNYOOGO2ntZis5h3jD3o/CWIXYm3YQ0i2Ss1h+sKtR6kbg7p1PckzCaguu1aYKxA==@kvack.org X-Gm-Message-State: AOJu0YwINLP6aMeJv0kLgSbCVQ+sQLfCawqTBYCJETkuhaOhcrg8K38C I2eCrD1549loXzd7l+gmy9lbZdxRWbW7FS/xKVBrvxpOMkicZ+c6pzZwmrZ+hfmDdPsYKGVu3GH fD3q7tplgR0n+OA== X-Google-Smtp-Source: AGHT+IHze4h565Aoh2DoHrp99j4LSl0kVAIFqSGJmgywq3dMrDmKMH3RGZw03PbIllpNmKnyBzK6/JzPDiaVmPE= X-Received: from wmoq13.prod.google.com ([2002:a05:600c:46cd:b0:431:1260:2444]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3146:b0:434:a169:6ff8 with SMTP id 5b1f17b1804b1-434a9db8423mr128388385e9.3.1732897976603; Fri, 29 Nov 2024 08:32:56 -0800 (PST) Date: Fri, 29 Nov 2024 16:32:35 +0000 In-Reply-To: <20241129-vma-v10-0-4dfff05ba927@google.com> Mime-Version: 1.0 References: <20241129-vma-v10-0-4dfff05ba927@google.com> X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=9643; i=aliceryhl@google.com; h=from:subject:message-id; bh=qfqYB5CY+zrrWoF1p5PA1wE61kagKg3f8qMfUMwrH2s=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBnSeyunSmy45C3+dwg4sTBb0910JzVks9XKF/WA HFj/FmBAwyJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZ0nsrgAKCRAEWL7uWMY5 Ro6+D/0eS03pE3ZODh9XPuyPKCvsQdzzedfXMU5VED+gXAd+veD/s0mctxSF5+dCrZH/WzcSeG0 E0wvbKQGYvTYjDOrABcB4VUKPw13cEX5BB5FFhslBKJaVfKdQjRib4r2lFNk8nm2hDydoigQEf5 Necf6GOJbCrOgVx9Rkn6E2leJwlSrSiobggvnXvvPuJjEcyVX02iG/xj9eaQBwg8R9x2cozehqe 5AZsxJl9JZqNPPCvnMquL3HhnS51Tx9OzpfikrhsWXxOYqQMbaSYCsq3JREbXVut+Wyf8plCNvF 8sUwhycV5tQES/p36rGUFikzr7Z4qUmQbkCF8XX/gOJshCUGnlnMOfXLf3cZQAUn7/FZWVwIVe2 07m+UyPyzz2M5AMMEaGHizR1WiL1I09EhEDgdNrnAqTA+LPowkPYhRE+urCovOVmwG2KEVjlu+B 6sNpFxFnHDbpUAMnIR+WBFeG6+ZeDfSrrC46g59620JfvBYSBcS17v0TvqAIsHsPC8w41FLcPPD O/6dcaOE9l5QO27XYeCm2uOSGn8Mn4SemMv9PK7a7V4ECtf9kuFUJ7CBD0KjnZwz94CrvGAxwPq dkZ21D6ljWsx+KrHr5XkZ4KglFbqxP/ZE6f8FCSkOH/53QWrOW//QlkjLpp08wULZs6JDDB43rw bJ2rL11wZz/I6WQ== X-Mailer: b4 0.13.0 Message-ID: <20241129-vma-v10-2-4dfff05ba927@google.com> Subject: [PATCH v10 2/8] 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 , Christian Brauner , 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 , linux-kernel@vger.kernel.org, linux-mm@kvack.org, rust-for-linux@vger.kernel.org, Alice Ryhl X-Rspamd-Queue-Id: 72D04C0002 X-Rspamd-Server: rspam12 X-Stat-Signature: qqe5hdq4ueyjdsmey59w4dw1x4mwbzhx X-Rspam-User: X-HE-Tag: 1732897966-671861 X-HE-Meta: U2FsdGVkX1/ZoqYWI4nxsOIL3gW6MK/0QsURPEpjHiHVx6TBgn263MtZr8X6Zvhvm2mf1D7Vz3Q3WrzTzGh/QHp6ocBSUaGT2QGMVq5LywYEtTghkSaaoRQfR9U5dALZoimiV7O7f7i0fPXJYheyjIvN5tN2Yd4WLRoxbCYZx9pg6Hq6b8itPlR+qZJq/CVcUdwWexIad0107BM6Ky+6H376HGeKRxFRC+lyRZvTK2aB8dD3fQvz6YW2ytjW0AYjHarboRf6cokYrBCaYydp84XkyM4me4vYqo3OWZ4sdg3xbYch26RqKb7NsVNsuU/NWuZ/Kqoa/Gst+jtlqAmdPBf2bUMKk+xG6K2u2zrlvHvYEm+5itBqpwob4PFcjU/9A5i99lG//Ey4xOZB7GD1jCPUU1guV9zaf7M7nWS6wBicrI8cYHxYC+pz29QxiY1aI8tGoquSGniJ7ghoz3Z14xNaNn1imUbqhkutkTwT6tEY8cNMDMuFImb0KMYsn0/V1at7TwGUtw9wdDZ9qkmJnKt9uMAX7GCk7PiZ//xdMG8PltCIyNpGD0Nzb0/xzAnA4908xyw4eQ5p8hlbXJRz81lEHFdYUxULxtYTRfWdWCoQVq2+sEZ5fJomgseZjHFp5KJgskOvtL3lyvSEq7uTMEyzOBSfuJFu6weYfluVRBCS4gY4w3YFjAYJgeae1kX4MRjFcSAzKR0BNPWeLK5mHlBGEpPMWYNQfIKmWHItWv/m+noDyfhM1Bvp36liLJ32OafXd5ig3GolnmAKD77+NjMOemEcvUH+CNGxnt4460JtyYL34nriJ1XdlFG/tLRPRStvsuJuQnNqFg/na/PKtjyFeqIxfunSP8SzPuiUjIgWP+VXHxAkBe/1Hh/j91uIs0jEScdXgQqKLDFaylVnPuIyDShizp26jzrwwQViuneM3IhWzvUWtnUIleIF96K5TEB6Hh8sQ8nIyWocKpb 56z4SBI8 V3nDIQzI0zk1Q3o4OreV+llgJpN/jCebtviK6q+mb1xwrEwX3rX7PAv5U5/HeZ2TbUdFYYqfYXQDse/2oCShYN33028C6hSw5IcdvBukPxk+W63JwD/EL8i2XKbgAcQ6rPfpZSxqDh/oLT/JyTZImFrpO5HdHBP5P8at2p/0mnf5x22+J7RFhzJ2VyUDq+WR1L6xw72l8/OXizZtNaAAlw+2g7oK45THPLZvOANjgp4LXyx8g4EWQS9CjADtN1GU6IOSiFly6rG+cBkN/uOhohP90FNnrjbKPtz/YsO+mKdqecWqSlRBE9BAkc3Txruc2k/M8m/s96gL8mquiIjpJtPxHmIWeDJF4AV4jbC8bpoZkPODXufA9s7lxmM8/aAzvxox0KzT6JVb2OjOLPnQKJLfXEF97sz7mW1xtZItyhdSwpkI3EFMVWPHFGtAh7ogt0a/IwpTmq9jTyTpYKiOsowrtcAp/ILB8SKFRvd1sTXP5arDR+bEK4cwgcOn4BrI6a9bM4TfKaW7GzqV87KzwIZN2z6QH4GseRne3FqgMoV3uutzZNKVuqFEJL5jNOvPVAbIa9IS8+b+wd/6R/7BNhufqKKdU/45Est896TiOUOfl4W5cdWBcJPfeaytWs8mG2H2D3PjJsqCRmfVPB+ufdOGc/5jVtAt0eaTmiKZaUjvQ6mEN5C285rfLlHDkYwp5TaxkIKWm0GPud3a+GEtt1gzP6A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 VmAreaRef 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 &VmAreaRef 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 (for mm bits) Reviewed-by: Jann Horn Signed-off-by: Alice Ryhl --- rust/helpers/mm.c | 6 ++ rust/kernel/mm.rs | 21 ++++++ rust/kernel/mm/virt.rs | 182 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+) diff --git a/rust/helpers/mm.c b/rust/helpers/mm.c index 7201747a5d31..7b72eb065a3e 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 84cba581edaa..ace8e7d57afe 100644 --- a/rust/kernel/mm.rs +++ b/rust/kernel/mm.rs @@ -12,6 +12,8 @@ }; use core::{ops::Deref, ptr::NonNull}; +pub mod virt; + /// A wrapper for the kernel's `struct mm_struct`. /// /// Since `mm_users` may be zero, the associated address space may not exist anymore. You can use @@ -210,6 +212,25 @@ 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::VmAreaRef> { + // SAFETY: We hold a reference to the mm, so the pointer must be valid. Any value is okay + // for `vma_addr`. + let vma = unsafe { bindings::vma_lookup(self.mm.as_raw(), vma_addr as _) }; + + if vma.is_null() { + None + } else { + // SAFETY: We just checked that a vma was found, so the pointer is valid. Furthermore, + // the returned area will borrow from this read lock guard, so it can only be used + // while the mmap read lock is still held. + unsafe { Some(virt::VmAreaRef::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 000000000000..032eea4d4690 --- /dev/null +++ b/rust/kernel/mm/virt.rs @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: GPL-2.0 + +// Copyright (C) 2024 Google LLC. + +//! Virtual memory. + +use crate::{bindings, 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 VmAreaRef { + vma: Opaque, +} + +// Methods you can call when holding the mmap or vma read lock (or strong). They must be usable no +// matter what the vma flags are. +impl VmAreaRef { + /// 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() + } + + /// 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 as _ } + } + + /// 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 as _ } + } + + /// 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 as _ } + } + + /// 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. + #[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 as _, + size as _, + core::ptr::null_mut(), + ) + }; + } +} + +/// The integer type used for vma flags. +#[doc(inline)] +pub use bindings::vm_flags_t; + +/// All possible flags for [`VmAreaRef`]. +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 _; +}