From nobody Mon May 4 13:05:26 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BB2EC433EF for ; Fri, 3 Jun 2022 17:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239546AbiFCRhs (ORCPT ); Fri, 3 Jun 2022 13:37:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232282AbiFCRhp (ORCPT ); Fri, 3 Jun 2022 13:37:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9FF2450B11 for ; Fri, 3 Jun 2022 10:37:44 -0700 (PDT) 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-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-58-I2qUrBrkMMGjlJJFsoNiiw-1; Fri, 03 Jun 2022 13:37:42 -0400 X-MC-Unique: I2qUrBrkMMGjlJJFsoNiiw-1 Received: by mail-il1-f199.google.com with SMTP id r9-20020a92cd89000000b002d16798b3cfso6659909ilb.22 for ; Fri, 03 Jun 2022 10:37:42 -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=mPuirnpch4WhD7HvFBmk9h0Sw4GiepdJeFFwnfIriR10VMFgTEArGbcz/Oplx7M9up A5q36r8O2LJxL/uetg7ZX0B3LdTr10zIHbspGfryS8YGVF0UpEB+2CI6DjpThu1SlfUk U5k4Nfh0/8GYA1UEepInhaE4/PggYNYOzvyDG65NZ68hJbKvV2qwAt9je8wls2VUh9og dmF+H9k+W2Pu9kW8vfEOFRRo3MlgauxF0coABzstV+F3djQ3G3iEQrmH2VpDt2odw9BM ILFXz4r4M+Em4V013vhqoc27VBwdDk1MsKTt1YhTzq9aKo/wNh9AxhS6dfWtbvkMTIQW pDGg== X-Gm-Message-State: AOAM531KccRcH8tWkLUXppoTZ11n/X0cEnQCNleQ09TKSbZ8rL5/Iggp sdsnDbcT8+YeQJWfMPPpaFWxZxjmdA2ueb8je1vCrxUCmNXkLR9AcVcUYDosBUtbZ5lhmyHvLAt Pv4V1HHhI7eKa/2G4JFvGcSTD5MWllrTTCE1yGb8PYP5ecWajcWIvwCVQJA4TzqoJJ6OkP1EPXg == X-Received: by 2002:a02:ce8b:0:b0:331:6050:6171 with SMTP id y11-20020a02ce8b000000b0033160506171mr6014972jaq.319.1654277861443; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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_* " constant= s */" +.BR "#include " " /* Definition of " UFFD_* " constan= ts */" .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 --=20 2.32.0 From nobody Mon May 4 13:05:26 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B747EC433EF for ; Fri, 3 Jun 2022 17:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344550AbiFCRhz (ORCPT ); Fri, 3 Jun 2022 13:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344523AbiFCRhr (ORCPT ); Fri, 3 Jun 2022 13:37:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0420B50B11 for ; Fri, 3 Jun 2022 10:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654277865; 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=KVN5llUSTKGfOYwgLQOT/k3UPuUs0mFWw5O0GBLZ2DY4thENsp57vN2Y4wjPwFufZFqp0v /EV/aIygvIyLSn2HYNbp2ygbjeccnFbBihznmwxj5DWmPyZYDpr6wBTteSfM2OH5yEVBkl tImYFuAqUusD9FXE0s3PbI3W95XmN88= 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-384-odD---04Op-DaA8-FLzXhg-1; Fri, 03 Jun 2022 13:37:44 -0400 X-MC-Unique: odD---04Op-DaA8-FLzXhg-1 Received: by mail-il1-f199.google.com with SMTP id a3-20020a924443000000b002d1bc79da14so6672744ilm.15 for ; Fri, 03 Jun 2022 10:37:44 -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=0iGWt7ohEcK/DUylY1UJtp+K2lu4QQSYvACIa8gpq6pD06xy1jvTyJNQ6y9wiDjwM8 cPesifqZhduousxBivqAnW0oFKD7VwZyqxRI1BLmiomoEDqGli9joY9IgEQyQdM8iocQ MYLhml8JsZrwZqKtZ7syjAsI91JOMelsKuwp9OO312UF3CRCyhgBTtQl+bxgIpOptgqa DMOy5iA6cAgTJmjXTYjgEIJdTwUUOUunqhGcR5p/WOeJ6S79GJJXjZW8uQXy+KMWyqsq 8ZigxamjHufCWx2D08faZs3IIi4L8KJFj7D2lqk9spLQraTuzyMXF1nVVcGD1ExJQ+Qc h6Ig== X-Gm-Message-State: AOAM532cb7IRXYRDlKyQt8+LDATpTTjQMva4td1h/ME2JaBI59lUXcfv n/qm3YhrKX535ALvDIu8wZJ6oXoDEEihP384eQhsqQWZWxeZZvr4/NlpqNz5DJ/sYcozHGuh4CF lzBet9Ec1vNQMbHRb9Twbx1JYN/dSVCVjZmlob9T41uwsC4zkUfwPe1smZCqaoPn4zfHTpViLlQ == X-Received: by 2002:a05:6e02:1c42:b0:2d1:aaac:ecc2 with SMTP id d2-20020a056e021c4200b002d1aaacecc2mr6160215ilg.128.1654277862994; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 mem= ory. 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 an= d 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 initiat= e 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, --=20 2.32.0