From: Alejandro Colomar <alx@kernel.org>
To: Kiryl Shutsemau <kirill@shutemov.name>
Cc: linux-man@vger.kernel.org, linux-mm@kvack.org,
akpm@linux-foundation.org, rppt@kernel.org, peterx@redhat.com,
david@kernel.org, kernel-team@meta.com,
Kiryl Shutsemau <kas@kernel.org>
Subject: Re: [PATCH v2 2/6] UFFDIO_RWPROTECT.2const: New page
Date: Thu, 28 May 2026 13:35:06 +0200 [thread overview]
Message-ID: <ahgoSq87Hbk5e0J8@devuan> (raw)
In-Reply-To: <20260526134149.2831720-3-kirill@shutemov.name>
[-- Attachment #1: Type: text/plain, Size: 4851 bytes --]
Hi Kiryl,
On 2026-05-26T14:41:45+0100, Kiryl Shutsemau wrote:
> Document the UFFDIO_RWPROTECT ioctl (since Linux 7.2). It installs or
> removes read-write protection on a range that was registered with
> UFFDIO_REGISTER_MODE_RWP, and is also how a handler resolves an
> UFFD_PAGEFAULT_FLAG_RWP notification.
>
> Cover the two mode bits (UFFDIO_RWPROTECT_MODE_RWP and
> UFFDIO_RWPROTECT_MODE_DONTWAKE, mutually exclusive), the populated-
> pages-only semantics, the anon vs file-backed reclaim behaviour, the
> explicit-drop list (MADV_DONTNEED, hole-punch, truncation), and the
> EINVAL/EAGAIN/ENOENT/EFAULT errors returned by the kernel.
>
> Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Thanks! I've applied the patch (with a few minor tweaks).
Have a lovely day!
Alex
> ---
> man/man2const/UFFDIO_RWPROTECT.2const | 122 ++++++++++++++++++++++++++
> 1 file changed, 122 insertions(+)
> create mode 100644 man/man2const/UFFDIO_RWPROTECT.2const
>
> diff --git a/man/man2const/UFFDIO_RWPROTECT.2const b/man/man2const/UFFDIO_RWPROTECT.2const
> new file mode 100644
> index 000000000000..42654a834cd5
> --- /dev/null
> +++ b/man/man2const/UFFDIO_RWPROTECT.2const
> @@ -0,0 +1,122 @@
> +.\" Copyright, the authors of the Linux man-pages project
> +.\"
> +.\" SPDX-License-Identifier: Linux-man-pages-copyleft
> +.\"
> +.TH UFFDIO_RWPROTECT 2const (date) "Linux man-pages (unreleased)"
> +.SH NAME
> +UFFDIO_RWPROTECT
> +\-
> +read-write-protect or un-protect a userfaultfd-registered memory range
> +.SH LIBRARY
> +Standard C library
> +.RI ( libc ,\~ \-lc )
> +.SH SYNOPSIS
> +.nf
> +.BR "#include <linux/userfaultfd.h>" " /* Definition of " UFFD* " constants */"
> +.B #include <sys/ioctl.h>
> +.P
> +.BI "int ioctl(int " fd ", UFFDIO_RWPROTECT, struct uffdio_rwprotect *" argp );
> +.P
> +.B #include <linux/userfaultfd.h>
> +.P
> +.fi
> +.EX
> +.B struct uffdio_rwprotect {
> +.BR " struct uffdio_range range;" " /* Range to change RWP on */"
> +.BR " __u64 mode;" " /* Mode flags */"
> +.B };
> +.EE
> +.SH DESCRIPTION
> +Read-write-protect or un-protect a userfaultfd-registered memory range
> +registered with mode
> +.BR UFFDIO_REGISTER_MODE_RWP .
> +.P
> +The following mode bits are supported:
> +.TP
> +.B UFFDIO_RWPROTECT_MODE_RWP
> +When this mode bit is set,
> +the ioctl installs read-write protection
> +on every page present in the range specified by
> +.IR range .
> +Otherwise the ioctl removes read-write protection from the range,
> +which is also how a fault handler resolves an
> +.B UFFD_PAGEFAULT_FLAG_RWP
> +notification.
> +.TP
> +.B UFFDIO_RWPROTECT_MODE_DONTWAKE
> +When this mode bit is set,
> +do not wake up any thread
> +that waits for page-fault resolution after the operation.
> +This can be specified only if
> +.B UFFDIO_RWPROTECT_MODE_RWP
> +is not specified.
> +.P
> +Read-write protection only affects pages
> +that are currently populated in the range;
> +unmapped addresses are left untouched.
> +For anonymous mappings,
> +protection is preserved across page reclaim
> +(the marker rides on the swap entry)
> +and migration.
> +For shmem and file-backed mappings,
> +protection is dropped when the backing page is reclaimed.
> +Callers must also re-arm a range with
> +.B UFFDIO_RWPROTECT
> +after any operation that explicitly drops the underlying page:
> +.B MADV_DONTNEED
> +on anonymous memory,
> +hole-punch on shmem,
> +truncation of a file mapping.
> +.SH RETURN VALUE
> +On success,
> +0 is returned.
> +On error, \-1 is returned and
> +.I errno
> +is set to indicate the error.
> +.SH ERRORS
> +.TP
> +.B EINVAL
> +The
> +.I start
> +or the
> +.I len
> +field of the
> +.I uffdio_range
> +structure was not a multiple of the system page size;
> +or
> +.I len
> +was zero;
> +or the specified range was otherwise invalid;
> +or an invalid mode bit was specified;
> +or
> +.B UFFDIO_RWPROTECT_MODE_DONTWAKE
> +was specified together with
> +.BR UFFDIO_RWPROTECT_MODE_RWP .
> +.TP
> +.B EAGAIN
> +The process was interrupted;
> +retry this call.
> +.TP
> +.B ENOENT
> +The range specified in
> +.I range
> +is not valid.
> +For example, the virtual address does not exist,
> +or part of the range is not registered with
> +.BR UFFDIO_REGISTER_MODE_RWP .
> +.TP
> +.B EFAULT
> +Encountered a generic fault during processing.
> +.SH STANDARDS
> +Linux.
> +.SH HISTORY
> +Linux 7.2.
> +.SH EXAMPLES
> +See
> +.BR userfaultfd (2).
> +.SH SEE ALSO
> +.BR ioctl (2),
> +.BR ioctl_userfaultfd (2),
> +.BR userfaultfd (2)
> +.P
> +.I linux.git/\:Documentation/\:admin\-guide/\:mm/\:userfaultfd.rst
> --
> 2.54.0
>
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-05-28 11:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 13:41 [PATCH man-pages v2 0/6] userfaultfd: document read-write-protect mode Kiryl Shutsemau
2026-05-26 13:41 ` [PATCH v2 1/6] userfaultfd.2: Add " Kiryl Shutsemau
2026-05-27 23:36 ` Alejandro Colomar
2026-05-26 13:41 ` [PATCH v2 2/6] UFFDIO_RWPROTECT.2const: New page Kiryl Shutsemau
2026-05-28 11:35 ` Alejandro Colomar [this message]
2026-05-26 13:41 ` [PATCH v2 3/6] UFFDIO_SET_MODE.2const: " Kiryl Shutsemau
2026-05-28 11:48 ` Alejandro Colomar
2026-05-26 13:41 ` [PATCH v2 4/6] UFFDIO_API.2const: Document UFFD_FEATURE_RWP{,_ASYNC} and 1 << _UFFDIO_SET_MODE Kiryl Shutsemau
2026-05-26 13:41 ` [PATCH v2 5/6] UFFDIO_REGISTER.2const: Document UFFDIO_REGISTER_MODE_RWP and 1 << _UFFDIO_RWPROTECT Kiryl Shutsemau
2026-05-26 13:41 ` [PATCH v2 6/6] ioctl_userfaultfd.2: Reference UFFDIO_RWPROTECT and UFFDIO_SET_MODE Kiryl Shutsemau
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=ahgoSq87Hbk5e0J8@devuan \
--to=alx@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=kirill@shutemov.name \
--cc=linux-man@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=rppt@kernel.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