* [PATCH 0/2] userfaultfd.2: Update to latest @ 2022-05-31 1:11 Peter Xu 2022-05-31 1:11 ` [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY Peter Xu 2022-05-31 1:11 ` [PATCH 2/2] userfaultfd.2: Update on write-protection support Peter Xu 0 siblings, 2 replies; 6+ messages in thread From: Peter Xu @ 2022-05-31 1:11 UTC (permalink / raw) To: linux-kernel, linux-man, linux-mm Cc: Alejandro Colomar, Michael Kerrisk, Axel Rasmussen, Andrea Arcangeli, peterx, Nadav Amit, Andrew Morton Add the two missing pieces till latest 5.19-rc1: the UFFD_USER_MODE_ONLY flag, and also the recent wr-protect support on shmem and hugetlbfs. Please review, thanks. Peter Xu (2): userfaultfd.2: Add section for UFFD_USER_MODE_ONLY userfaultfd.2: Update on write-protection support man2/userfaultfd.2 | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) -- 2.32.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY 2022-05-31 1:11 [PATCH 0/2] userfaultfd.2: Update to latest Peter Xu @ 2022-05-31 1:11 ` Peter Xu 2022-06-03 17:11 ` Alejandro Colomar 2022-05-31 1:11 ` [PATCH 2/2] userfaultfd.2: Update on write-protection support Peter Xu 1 sibling, 1 reply; 6+ messages in thread From: Peter Xu @ 2022-05-31 1:11 UTC (permalink / raw) To: linux-kernel, linux-man, linux-mm Cc: Alejandro Colomar, Michael Kerrisk, Axel Rasmussen, Andrea Arcangeli, peterx, Nadav Amit, Andrew Morton Add a paragraph for UFFD_USER_MODE_ONLY flag that was introduced in Linux 5.11. Signed-off-by: Peter Xu <peterx@redhat.com> --- man2/userfaultfd.2 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index cee7c01d2..0928a76d2 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -29,8 +29,9 @@ userfaultfd \- create a file descriptor for handling page faults in user space .SH SYNOPSIS .nf -.BR "#include <fcntl.h>" " /* Definition of " O_* " constants */" -.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.BR "#include <fcntl.h>" " /* Definition of " O_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.BR "#include <linux/userfaultfd.h>" " /* Definition of " UFFD_* " constants */" .B #include <unistd.h> .PP .BI "int syscall(SYS_userfaultfd, int " flags ); @@ -76,6 +77,15 @@ See the description of the .BR O_NONBLOCK flag in .BR open (2). +.TP +.BR UFFD_USER_MODE_ONLY +This is an userfaultfd specific flag that was introduced since Linux 5.11. +When set, the userfaultfd object will only be able to handle page faults +originated from the userspace on the registered regions. +When a kernel originated fault was triggered on the registered range with +this userfaultfd, a +.BR SIGBUS +signal will be delivered. .PP When the last file descriptor referring to a userfaultfd object is closed, all memory ranges that were registered with the object are unregistered -- 2.32.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY 2022-05-31 1:11 ` [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY Peter Xu @ 2022-06-03 17:11 ` Alejandro Colomar 2022-06-03 17:34 ` Peter Xu 0 siblings, 1 reply; 6+ messages in thread From: Alejandro Colomar @ 2022-06-03 17:11 UTC (permalink / raw) To: Peter Xu, linux-kernel, linux-man, linux-mm Cc: Axel Rasmussen, Andrea Arcangeli, Nadav Amit, Andrew Morton [-- Attachment #1.1: Type: text/plain, Size: 2229 bytes --] Hi Peter, On 5/31/22 03:11, Peter Xu wrote: > Add a paragraph for UFFD_USER_MODE_ONLY flag that was introduced in > Linux 5.11. > > Signed-off-by: Peter Xu <peterx@redhat.com> See some minor comments below. Cheers, Alex > --- > man2/userfaultfd.2 | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 > index cee7c01d2..0928a76d2 100644 > --- a/man2/userfaultfd.2 > +++ b/man2/userfaultfd.2 > @@ -29,8 +29,9 @@ > userfaultfd \- create a file descriptor for handling page faults in user space > .SH SYNOPSIS > .nf > -.BR "#include <fcntl.h>" " /* Definition of " O_* " constants */" > -.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" > +.BR "#include <fcntl.h>" " /* Definition of " O_* " constants */" > +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" > +.BR "#include <linux/userfaultfd.h>" " /* Definition of " UFFD_* " constants */" > .B #include <unistd.h> > .PP > .BI "int syscall(SYS_userfaultfd, int " flags ); > @@ -76,6 +77,15 @@ See the description of the > .BR O_NONBLOCK > flag in > .BR open (2). > +.TP > +.BR UFFD_USER_MODE_ONLY s/BR/B/ see groff_man(7): [ [...] .B [text] Set text in bold. If the macro is given no argu‐ ments, the text of the next input line is set in bold. [...] .BR bold‐text roman‐text ... Set each argument in bold and roman, alternately. ] > +This is an userfaultfd specific flag that was introduced since Linux 5.11. > +When set, the userfaultfd object will only be able to handle page faults > +originated from the userspace on the registered regions. > +When a kernel originated fault was triggered on the registered range with > +this userfaultfd, a > +.BR SIGBUS s/BR/B/ > +signal will be delivered. > .PP > When the last file descriptor referring to a userfaultfd object is closed, > all memory ranges that were registered with the object are unregistered -- Alejandro Colomar <http://www.alejandro-colomar.es/> [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY 2022-06-03 17:11 ` Alejandro Colomar @ 2022-06-03 17:34 ` Peter Xu 0 siblings, 0 replies; 6+ messages in thread From: Peter Xu @ 2022-06-03 17:34 UTC (permalink / raw) To: Alejandro Colomar Cc: linux-kernel, linux-man, linux-mm, Axel Rasmussen, Andrea Arcangeli, Nadav Amit, Andrew Morton On Fri, Jun 03, 2022 at 07:11:05PM +0200, Alejandro Colomar wrote: > Hi Peter, > > On 5/31/22 03:11, Peter Xu wrote: > > Add a paragraph for UFFD_USER_MODE_ONLY flag that was introduced in > > Linux 5.11. > > > > Signed-off-by: Peter Xu <peterx@redhat.com> > > See some minor comments below. > > Cheers, > > Alex > > > --- > > man2/userfaultfd.2 | 14 ++++++++++++-- > > 1 file changed, 12 insertions(+), 2 deletions(-) > > > > diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 > > index cee7c01d2..0928a76d2 100644 > > --- a/man2/userfaultfd.2 > > +++ b/man2/userfaultfd.2 > > @@ -29,8 +29,9 @@ > > userfaultfd \- create a file descriptor for handling page faults in user space > > .SH SYNOPSIS > > .nf > > -.BR "#include <fcntl.h>" " /* Definition of " O_* " constants */" > > -.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" > > +.BR "#include <fcntl.h>" " /* Definition of " O_* " constants */" > > +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" > > +.BR "#include <linux/userfaultfd.h>" " /* Definition of " UFFD_* " constants */" > > .B #include <unistd.h> > > .PP > > .BI "int syscall(SYS_userfaultfd, int " flags ); > > @@ -76,6 +77,15 @@ See the description of the > > .BR O_NONBLOCK > > flag in > > .BR open (2). > > +.TP > > +.BR UFFD_USER_MODE_ONLY > > > s/BR/B/ > > see groff_man(7): > > [ > [...] > > .B [text] > Set text in bold. If the macro is given no argu‐ > ments, the text of the next input line is set in > bold. > > [...] > > .BR bold‐text roman‐text ... > Set each argument in bold and roman, alternately. > ] > > > +This is an userfaultfd specific flag that was introduced since Linux 5.11. > > +When set, the userfaultfd object will only be able to handle page faults > > +originated from the userspace on the registered regions. > > +When a kernel originated fault was triggered on the registered range with > > +this userfaultfd, a > > +.BR SIGBUS > > s/BR/B/ Thanks Alex, I'll fix and repost the patchset soon. -- Peter Xu ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] userfaultfd.2: Update on write-protection support 2022-05-31 1:11 [PATCH 0/2] userfaultfd.2: Update to latest Peter Xu 2022-05-31 1:11 ` [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY Peter Xu @ 2022-05-31 1:11 ` Peter Xu 2022-06-03 17:12 ` Alejandro Colomar 1 sibling, 1 reply; 6+ messages in thread From: Peter Xu @ 2022-05-31 1:11 UTC (permalink / raw) To: linux-kernel, linux-man, linux-mm Cc: Alejandro Colomar, Michael Kerrisk, Axel Rasmussen, Andrea Arcangeli, peterx, Nadav Amit, Andrew Morton The shmem/hugetlbfs memory types are supported for write-protection messages very lately. Update the man page to reflect that. Signed-off-by: Peter Xu <peterx@redhat.com> --- man2/userfaultfd.2 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 0928a76d2..99aae8b50 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -273,13 +273,17 @@ Since Linux 4.11, userfaultfd can be also used with hugetlbfs and shared memory mappings. .\" .SS Userfaultfd write-protect mode (since 5.7) -Since Linux 5.7, userfaultfd supports write-protect mode. +Since Linux 5.7, userfaultfd supports write-protect mode for anonymous memory. The user needs to first check availability of this feature using .B UFFDIO_API ioctl against the feature bit .B UFFD_FEATURE_PAGEFAULT_FLAG_WP before using this feature. .PP +Since Linux 5.19, the write-protection mode was also supported on shmem and hugetlbfs +memory types. It can be detected with the feature bit +.BR UFFD_FEATURE_WP_HUGETLBFS_SHMEM . +.PP To register with userfaultfd write-protect mode, the user needs to initiate the .B UFFDIO_REGISTER ioctl with mode @@ -330,8 +334,6 @@ ioctl, whose should have the flag .B UFFDIO_WRITEPROTECT_MODE_WP cleared upon the faulted page or range. -.PP -Write-protect mode supports only private anonymous memory. .SS Reading from the userfaultfd structure Each .BR read (2) -- 2.32.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] userfaultfd.2: Update on write-protection support 2022-05-31 1:11 ` [PATCH 2/2] userfaultfd.2: Update on write-protection support Peter Xu @ 2022-06-03 17:12 ` Alejandro Colomar 0 siblings, 0 replies; 6+ messages in thread From: Alejandro Colomar @ 2022-06-03 17:12 UTC (permalink / raw) To: Peter Xu, linux-kernel, linux-man, linux-mm Cc: Axel Rasmussen, Andrea Arcangeli, Nadav Amit, Andrew Morton [-- Attachment #1.1: Type: text/plain, Size: 2269 bytes --] Hi Peter, On 5/31/22 03:11, Peter Xu wrote: > The shmem/hugetlbfs memory types are supported for write-protection > messages very lately. Update the man page to reflect that. > > Signed-off-by: Peter Xu <peterx@redhat.com> Please see some source formatting comments below. Cheers, Alex > --- > man2/userfaultfd.2 | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 > index 0928a76d2..99aae8b50 100644 > --- a/man2/userfaultfd.2 > +++ b/man2/userfaultfd.2 > @@ -273,13 +273,17 @@ Since Linux 4.11, > userfaultfd can be also used with hugetlbfs and shared memory mappings. > .\" > .SS Userfaultfd write-protect mode (since 5.7) > -Since Linux 5.7, userfaultfd supports write-protect mode. > +Since Linux 5.7, userfaultfd supports write-protect mode for anonymous memory. > The user needs to first check availability of this feature using > .B UFFDIO_API > ioctl against the feature bit > .B UFFD_FEATURE_PAGEFAULT_FLAG_WP > before using this feature. > .PP > +Since Linux 5.19, the write-protection mode was also supported on shmem and hugetlbfs > +memory types. It can be detected with the feature bit See man-pages(7): [ Use semantic newlines In the source of a manual page, new sentences should be started on new lines, and long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on). This convention, sometimes known as "seman‐ tic newlines", makes it easier to see the effect of patches, which often operate at the level of individual sentences or sentence clauses. ] > +.BR UFFD_FEATURE_WP_HUGETLBFS_SHMEM . > +.PP > To register with userfaultfd write-protect mode, the user needs to initiate the > .B UFFDIO_REGISTER > ioctl with mode > @@ -330,8 +334,6 @@ ioctl, whose > should have the flag > .B UFFDIO_WRITEPROTECT_MODE_WP > cleared upon the faulted page or range. > -.PP > -Write-protect mode supports only private anonymous memory. > .SS Reading from the userfaultfd structure > Each > .BR read (2) -- Alejandro Colomar <http://www.alejandro-colomar.es/> [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-06-03 17:34 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-05-31 1:11 [PATCH 0/2] userfaultfd.2: Update to latest Peter Xu 2022-05-31 1:11 ` [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY Peter Xu 2022-06-03 17:11 ` Alejandro Colomar 2022-06-03 17:34 ` Peter Xu 2022-05-31 1:11 ` [PATCH 2/2] userfaultfd.2: Update on write-protection support Peter Xu 2022-06-03 17:12 ` Alejandro Colomar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).