From patchwork Fri Jun 3 17:37:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12869263 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 0658EC43334 for ; Fri, 3 Jun 2022 17:37:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 88C4A6B0074; Fri, 3 Jun 2022 13:37:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 822446B0073; Fri, 3 Jun 2022 13:37:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68ABC8D0001; Fri, 3 Jun 2022 13:37:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 591B96B0071 for ; Fri, 3 Jun 2022 13:37:44 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 32D433519C for ; Fri, 3 Jun 2022 17:37:44 +0000 (UTC) X-FDA: 79537632048.21.1850838 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 7071C100012 for ; Fri, 3 Jun 2022 17:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654277863; h=from:from: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; bh=0aUCBdDLRZgXZUTdZmjGfl1wafgZ6gf3pWlYAS6s0rQ=; b=FIuKj2qsB99FY6HenwnZHX6SZQNpZgNhiM7rconN7fNcIjkPISQ01bFFQG2If7xbT2dah6 dXF33OcNh+luz+z7saY59xZjFfZ3xLWQrEfwWjNwjqiD8urAXNeko7i4qpcVYf087dGc8H 6/B1PA5hfrJ9qs2i3iJV1tq1rpUKfp0= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-Jd5jztrpOb-WwSnufp7TXQ-1; Fri, 03 Jun 2022 13:37:42 -0400 X-MC-Unique: Jd5jztrpOb-WwSnufp7TXQ-1 Received: by mail-il1-f198.google.com with SMTP id w7-20020a056e021c8700b002d3bc8e95cbso6692352ill.3 for ; Fri, 03 Jun 2022 10:37:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0aUCBdDLRZgXZUTdZmjGfl1wafgZ6gf3pWlYAS6s0rQ=; b=BBPgqvYWAPB3oZlo7G+316KStbrorJm+gTXB/4N6JIRzmmZhtomyPf440sh6XCLhUH pfGG756SCSfSHzhvq0XvTrBKGuIdvQxLY24W5tj+uxkWN45tbdeQlFpbVSeqbnzkGdrC +KqecQlOSjPzjS9Kyr3/fgRvuWMmIvGon21tnwgePUleOIrKLuje91ATxrOpU+bqj9Vm 1WQPDHhD0ZaMcq4mG5jydnUjLUdJiDjnlFu1DXsdPA/WtHOT2HeUC/5MwglLCdzkcs6T VYtirq+DUovDV1x/STgL911bEGGzsJ8U5HeqsXFe+z9jxl7gmUSoqiYWmhmvDEW3PkR6 rKmw== X-Gm-Message-State: AOAM530Ld0E5mepbJBtIP/6Dn6h/vDsjp9kQJHNlFH9VPqJBMqUOepWc 9t2PechYJOGk+iw4PYkY9hF4teIcMjBb+Ry6t0iWeaN0qh+a93krr0B2j7m2Z8D+rlwBVAPNPGC uxC9CurCrJ0A= X-Received: by 2002:a02:ce8b:0:b0:331:6050:6171 with SMTP id y11-20020a02ce8b000000b0033160506171mr6014963jaq.319.1654277861359; Fri, 03 Jun 2022 10:37:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT5yNyOJqrMirvzChd6Jq1GY7aquh0xWawRy0pwsachq+SjLrMtUXFuDfeFTAii6nzxub+Mw== X-Received: by 2002:a02:ce8b:0:b0:331:6050:6171 with SMTP id y11-20020a02ce8b000000b0033160506171mr6014940jaq.319.1654277860823; Fri, 03 Jun 2022 10:37:40 -0700 (PDT) Received: from localhost.localdomain (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id g23-20020a02bb97000000b0032e1e0ac289sm2791117jan.8.2022.06.03.10.37.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 03 Jun 2022 10:37:40 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-man@vger.kernel.org, linux-mm@kvack.org Cc: Michael Kerrisk , Andrea Arcangeli , Alejandro Colomar , Nadav Amit , Axel Rasmussen , Andrew Morton , peterx@redhat.com Subject: [PATCH v2 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY Date: Fri, 3 Jun 2022 13:37:35 -0400 Message-Id: <20220603173736.62581-2-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220603173736.62581-1-peterx@redhat.com> References: <20220603173736.62581-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FIuKj2qs; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf05.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7071C100012 X-Rspam-User: X-Stat-Signature: qwwxkscb8pzf5yj84kqc477cxnwstmpy X-HE-Tag: 1654277827-391569 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: Add a paragraph for UFFD_USER_MODE_ONLY flag that was introduced in Linux 5.11. Signed-off-by: Peter Xu --- man2/userfaultfd.2 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 93dca009f..6b9412aaf 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -12,8 +12,9 @@ Standard C library .RI ( libc ", " \-lc ) .SH SYNOPSIS .nf -.BR "#include " " /* Definition of " O_* " constants */" -.BR "#include " " /* Definition of " SYS_* " constants */" +.BR "#include " " /* Definition of " O_* " constants */" +.BR "#include " " /* Definition of " SYS_* " constants */" +.BR "#include " " /* Definition of " UFFD_* " constants */" .B #include .PP .BI "int syscall(SYS_userfaultfd, int " flags ); @@ -59,6 +60,15 @@ See the description of the .B O_NONBLOCK flag in .BR open (2). +.TP +.B 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 +.B 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 From patchwork Fri Jun 3 17:37:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12869265 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 9CAB3C43334 for ; Fri, 3 Jun 2022 17:37:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF5EB6B0072; Fri, 3 Jun 2022 13:37:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A560C6B0073; Fri, 3 Jun 2022 13:37:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 917D38D0001; Fri, 3 Jun 2022 13:37:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 807C06B0072 for ; Fri, 3 Jun 2022 13:37:45 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5B995617B4 for ; Fri, 3 Jun 2022 17:37:45 +0000 (UTC) X-FDA: 79537632090.26.6959AD7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 4584640031 for ; Fri, 3 Jun 2022 17:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654277864; h=from:from: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; bh=bvNdDteJSKV8nPr70UjTL9Ga0ysM0wiU173XEAoRmEg=; b=IriE9KlhMvKj8jPcVWOeqVCyelsJt6vhmq4QIXHYZ8QrnVnX/+dKiLE0zQMtnhFcjUVvdy d1TUi3fYBC4dxWP5hLQhBF5WmCjH5qhXnHsPpkFItq1fsu6Tm2UjAu/E7OBWBpA4qsna70 Yiw4mLYuy5/MkNcA18Crsq1jpmQ5IEU= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-tETGx9ngMb-a-x9tyCrLRA-1; Fri, 03 Jun 2022 13:37:43 -0400 X-MC-Unique: tETGx9ngMb-a-x9tyCrLRA-1 Received: by mail-il1-f199.google.com with SMTP id h18-20020a056e021d9200b002d40280eeadso2489787ila.23 for ; Fri, 03 Jun 2022 10:37:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bvNdDteJSKV8nPr70UjTL9Ga0ysM0wiU173XEAoRmEg=; b=smW7QWmxgeXIVn2AFoEKvADM7dS9Zj3olP3eBokwvMjt+chfsI8qGOMNU7qoLZHwh2 tbpJi0IIbmDrMMQAUOy6yu/FzipS0/T1oER1/qKl6pbIEKk6QE0BtngO+7eZ/uolgWpb rRmKUujAND1so3jNCZxkhhET9R435rkYLBheidsm34p/GcNJqtcxwYyJedfGzZFncT7L HcKTqehGPFdYBAkNSqLzCMODCkVqd0gTfJ0imcoK++526Jr3417DvWCSUfZQKBX2oYm1 DkX7vOtxfYZZKPiigTwD/0DyusL2VmHBLNlkJzsEEqUhZLGR1PewSrkP3Bwlu7SZDqwr MUVw== X-Gm-Message-State: AOAM531ehC+aJDmopYsFGHLoNFqdT5pgOFApCpEY2/ewAF547Prz+hK+ 3c2fs7TMYrpYDBo4ATcjWHfhT4nIVuWAAh42NrV3twPjilkweZRBY0omKLEuphUoZx9rUzBlBiY HgOamUb+hRHo= X-Received: by 2002:a05:6e02:1c42:b0:2d1:aaac:ecc2 with SMTP id d2-20020a056e021c4200b002d1aaacecc2mr6160209ilg.128.1654277862907; Fri, 03 Jun 2022 10:37:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxD6QpwDL7Wd5u30b73amnDkQf+0XrVGTTVTW2Zv3Vw4x28t8LPwaKvFl/gRzlApcqbp9Utcw== X-Received: by 2002:a05:6e02:1c42:b0:2d1:aaac:ecc2 with SMTP id d2-20020a056e021c4200b002d1aaacecc2mr6160200ilg.128.1654277862717; Fri, 03 Jun 2022 10:37:42 -0700 (PDT) Received: from localhost.localdomain (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id g23-20020a02bb97000000b0032e1e0ac289sm2791117jan.8.2022.06.03.10.37.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 03 Jun 2022 10:37:42 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-man@vger.kernel.org, linux-mm@kvack.org Cc: Michael Kerrisk , Andrea Arcangeli , Alejandro Colomar , Nadav Amit , Axel Rasmussen , Andrew Morton , peterx@redhat.com Subject: [PATCH v2 2/2] userfaultfd.2: Update on write-protection support Date: Fri, 3 Jun 2022 13:37:36 -0400 Message-Id: <20220603173736.62581-3-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220603173736.62581-1-peterx@redhat.com> References: <20220603173736.62581-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IriE9Klh; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf11.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com X-Stat-Signature: ojx44juekd7ppoxrwh1pewxy47bwocx6 X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4584640031 X-HE-Tag: 1654277856-853514 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: 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 --- man2/userfaultfd.2 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 6b9412aaf..9b5ec0358 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -270,13 +270,18 @@ 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 @@ -327,8 +332,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 Userfaultfd minor fault mode (since 5.13) Since Linux 5.13,