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 75EE4E77197 for ; Thu, 9 Jan 2025 08:23:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F32C56B007B; Thu, 9 Jan 2025 03:23:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EE2D26B0082; Thu, 9 Jan 2025 03:23:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAA466B0088; Thu, 9 Jan 2025 03:23:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BC4036B007B for ; Thu, 9 Jan 2025 03:23:51 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 70735802A3 for ; Thu, 9 Jan 2025 08:23:51 +0000 (UTC) X-FDA: 82987225062.12.0A75184 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id BB31E1C0009 for ; Thu, 9 Jan 2025 08:23:49 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KrrQFVip; spf=pass (imf18.hostedemail.com: domain of a.hindborg@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=a.hindborg@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736411029; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hKylwclzQVBoz+shQb7dXcczwWAJ0CJ0E31zB4227/Y=; b=snwdnSpZRZEGVCG71YzRjGneBK/m8/CTed2c87k+9V7uhifqX0o1dhWqo1I/Y+Jr6/X0W1 +5W2joS/p7FnG4ON0DlNUxGDSkOo7m0ciwfYMMti7wh0+szwsaz0CSv6pS9YJkMF6P7QA/ zP4Mb3Q2LCbhmaGcmPJ1eWMcWfhq2cU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KrrQFVip; spf=pass (imf18.hostedemail.com: domain of a.hindborg@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=a.hindborg@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736411029; a=rsa-sha256; cv=none; b=ecUNiGB3D56HGccPy/SP7Y/AJdsnE4QY48LuZcksycpBJGVJ2GY7HiSl6I0yrvczwYmwXZ u91M7bhAWeEb3DWsG3NiZzaT4uykuAzcckmKGWeve7fMT0mFx3aTlOrfDM80aAfH3b7oK7 DmW5gMMab3UbwVTJWkaxKbJoyBDvtOM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 830F05C5A0A; Thu, 9 Jan 2025 08:23:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60C4BC4CED2; Thu, 9 Jan 2025 08:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736411028; bh=FxDDDDkB/SYXwPnu5cUURtGqipisK/QAyYs0CosyLts=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=KrrQFVipw9WabjA9jLtkf0qaLC5OmmFGj+W1KWdKIaw1pLzidSuxMU3sjYehfWlQR LaqUXtOH+QGa1bpTgS0wjGd4A7oy4AtzjkGzynB6Zd6vK/KdhTeRDyZnM/lfO4pRCz mBfXc/TGgWFBkFGo9T0nDL+Ykp6uZNGKetK/FfEWug8e6px7kdYAH30ntOB7W6Y67m wHN3Mk5z9je23wCcoF+j/4XU9QUP/UW4S0arybPtQTsHNkF4FeSamnfCcM5FXIO+k/ dbKYCk8ZlAXr6M3WfERb33hSmPl5tRSlQnl7B3Sw1o8ntbCIkE3PqOqgZxVzaDZ4yE Z67M50BTq7ouQ== From: Andreas Hindborg To: "Alice Ryhl" Cc: "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" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , "Benno Lossin" , "Trevor Gross" , , , Subject: Re: [PATCH v11 6/8] mm: rust: add VmAreaNew for f_ops->mmap() In-Reply-To: (Alice Ryhl's message of "Wed, 08 Jan 2025 13:24:08 +0100") References: <20241211-vma-v11-0-466640428fc3@google.com> <20241211-vma-v11-6-466640428fc3@google.com> <87zfku8xm3.fsf@kernel.org> User-Agent: mu4e 1.12.7; emacs 29.4 Date: Thu, 09 Jan 2025 09:23:33 +0100 Message-ID: <874j28bdkq.fsf@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BB31E1C0009 X-Rspam-User: X-Stat-Signature: 5bz8gxdxonq4stwmzp9ea9wd6u6s954r X-HE-Tag: 1736411029-830902 X-HE-Meta: U2FsdGVkX18aM46RV9x8mBjXCDVs11Rf4Dhoku1e54oABNZj5QvaKILyz06c8/POo1ngeL4+w4fw90MISzrp3yfwMaaRgERHdifntYpXD5dXT+VLjvogRQqw+X70PVLTIqAxeWk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iicYwpvHofNnfIlKGFFVyQixF76RlDpmHYE7jUlAkN6jdM0SUCDPNayKLT6YCvuqT0lYf3RU8wI2OCS4Jg52aeSacUgLmG07eA1RPSW0mh6SUC76/lZrsh7sFiWEaKeXeOX/rRVOctQAqUAQyI+uCW7lGMTscYRKTG8TyoOVyyPMzU0vX4bBXarONHv X-Bogosity: Ham, tests=bogofilter, spamicity=0.359943, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: "Alice Ryhl" writes: > On Tue, Dec 17, 2024 at 10:31=E2=80=AFAM Andreas Hindborg wrote: >> >> "Alice Ryhl" writes: >> >> > This type will be used when setting up a new vma in an f_ops->mmap() >> > hook. Using a separate type from VmAreaRef 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 err= or >> > 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. >> > >> > Acked-by: Lorenzo Stoakes (for mm bits) >> > Reviewed-by: Jann Horn >> > Signed-off-by: Alice Ryhl >> > --- >> > rust/kernel/mm/virt.rs | 181 ++++++++++++++++++++++++++++++++++++++++= ++++++++- >> > 1 file changed, 180 insertions(+), 1 deletion(-) >> > >> > diff --git a/rust/kernel/mm/virt.rs b/rust/kernel/mm/virt.rs >> > index 3a23854e14f4..6d9ba56d4f95 100644 >> > --- a/rust/kernel/mm/virt.rs >> > +++ b/rust/kernel/mm/virt.rs >> >> [cut] >> >> > + /// Returns whether `VM_READ` is set. >> > + /// >> > + /// This flag indicates whether userspace is mapping this vma as = readable. >> > + #[inline] >> > + pub fn get_read(&self) -> bool { >> > + (self.flags() & flags::READ) !=3D 0 >> > + } >> >> As an afterthought, should we name these getters according to RFC344 [1] >> (remove get_ prefix)? > > Well, perhaps is_readable? Why not just `readable() -> bool`? That would match the guidelines. Best regards, Andreas Hindborg