2022-06-01 19:46:48

by Peter Xu

[permalink] [raw]
Subject: [PATCH 0/2] userfaultfd.2: Update to latest

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



2022-06-01 20:26:33

by Peter Xu

[permalink] [raw]
Subject: [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY

Add a paragraph for UFFD_USER_MODE_ONLY flag that was introduced in
Linux 5.11.

Signed-off-by: Peter Xu <[email protected]>
---
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


2022-06-05 00:33:21

by Alejandro Colomar

[permalink] [raw]
Subject: Re: [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY

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 <[email protected]>

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/>


Attachments:
OpenPGP_signature (849.00 B)
OpenPGP digital signature

2022-06-06 05:41:53

by Peter Xu

[permalink] [raw]
Subject: Re: [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY

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 <[email protected]>
>
> 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