From nobody Fri May 1 11:11:11 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 371DDC433FE for ; Tue, 31 May 2022 01:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243166AbiEaBMK (ORCPT ); Mon, 30 May 2022 21:12:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242242AbiEaBMH (ORCPT ); Mon, 30 May 2022 21:12:07 -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 3A36B93987 for ; Mon, 30 May 2022 18:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653959524; 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=B1zh0G6TK+W9pGc27qGuRakMVqnavlPCuAI+rVxzeGY=; b=ixy7FTS/dQzXK2w81U1xN85hRnPZJo+Q4lNF/QjhQnmwXm5e7itwyabZVqtndLjYWL55x+ UdUOcmWbuLCinh8eiCWj34INA2JKkyS/YPQE/yVL1XRAhhy0MCrUahKjdnWMfs8qyTJJsf MzqrZ7g6d3IWfBa2LnFRUKJfjd9QPJI= 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-6-93xGvDeyNRWPipSvz94SFQ-1; Mon, 30 May 2022 21:12:03 -0400 X-MC-Unique: 93xGvDeyNRWPipSvz94SFQ-1 Received: by mail-il1-f199.google.com with SMTP id x3-20020a056e021bc300b002d1b0ccfca6so9269809ilv.11 for ; Mon, 30 May 2022 18:12:03 -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=B1zh0G6TK+W9pGc27qGuRakMVqnavlPCuAI+rVxzeGY=; b=UQnHeW2IGxUsL9GwX+4/mkWImouovHKcYuZFwf6Ec95GhIhf+9RrBwieswZ7C+/59Z 29mKBUaFsDzCBnSNFcJuK5tPFkN3Y88gFRtCn+TkHMq8lHnZhojpYvXScd0YAMmfgAH6 ZBF6Rg5MBRhM0ojSmFxbbm2o8qt8B7i16JX7mk+lqrLCHkCHtv7Kjx+B16KsaOfkyfgI vbf8YMFKC8dSek8rv7t2FsO+rwzvOhKaPl6OIrRD+j7r9eFn7N++qatYqhYWA6hhX8vp W8KFnNm7/o9K0MfGDinnVYtvP64l8x5nGVxx+pXhykm07OAFv4H73rNcnSjv10bciGZl 6apA== X-Gm-Message-State: AOAM530OQFhgat8UapzVxAToRzh4uprDiF2EFZDLar6vkAvqSO2ISQcn tGcWO6dwTxSCJLnWTXveeViyZw68sPhE30S6HcxIhPOzVxsHevp3TJGbMtjpoi7wA19h4f6Dr7a YNeODaBrqAIgl0msvA2VcWyWMwQ+od3nrDjXn49mu5p6+buUwsMCMfJI/sA7zLlFGlfr04/WkXg == X-Received: by 2002:a05:6638:22c1:b0:331:f39:dc21 with SMTP id j1-20020a05663822c100b003310f39dc21mr6075908jat.75.1653959522125; Mon, 30 May 2022 18:12:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8O9HB/EdT6K2oS1Z/LDBvAFHH91nKVvI12INxaRwhBYX3fQMWWp9l9Gk9CQfAnLC9UW9O4A== X-Received: by 2002:a05:6638:22c1:b0:331:f39:dc21 with SMTP id j1-20020a05663822c100b003310f39dc21mr6075887jat.75.1653959521805; Mon, 30 May 2022 18:12:01 -0700 (PDT) Received: from localhost.localdomain (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id s6-20020a02c7c6000000b0032be3784b9bsm3158234jao.117.2022.05.30.18.12.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 May 2022 18:12:01 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-man@vger.kernel.org, linux-mm@kvack.org Cc: Alejandro Colomar , Michael Kerrisk , Axel Rasmussen , Andrea Arcangeli , peterx@redhat.com, Nadav Amit , Andrew Morton Subject: [PATCH 1/2] userfaultfd.2: Add section for UFFD_USER_MODE_ONLY Date: Mon, 30 May 2022 21:11:56 -0400 Message-Id: <20220531011157.46868-2-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220531011157.46868-1-peterx@redhat.com> References: <20220531011157.46868-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 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 s= pace .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 ); @@ -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 --=20 2.32.0 From nobody Fri May 1 11:11:11 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 8ED3DC433EF for ; Tue, 31 May 2022 01:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243305AbiEaBMS (ORCPT ); Mon, 30 May 2022 21:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243070AbiEaBMH (ORCPT ); Mon, 30 May 2022 21:12:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA1AD9399C for ; Mon, 30 May 2022 18:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653959525; 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=+ftsvv1kgyZ07pkGYMo31JDRVN0rVbQcS4X4QP8a2k4=; b=OH1/Gb9JfpyiMei5A4RVXXqXDb84/O+7BoSnRSK+ybtemePxSyOHZRkGgsYK3xekxHvKWw 8DE7W55no9QDWd0oF/on+VwsRqyl+rzM8B//RpEgvJgdXraWjt/1APigQYe9FbPxG6DgPF ZysjG4WOBGgvRXDgHGA0NcksEf3v7uU= 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-203-i1SQqUxNPgCw5HwIReE20Q-1; Mon, 30 May 2022 21:12:04 -0400 X-MC-Unique: i1SQqUxNPgCw5HwIReE20Q-1 Received: by mail-il1-f199.google.com with SMTP id b13-20020a92670d000000b002d1a5d6b795so9259129ilc.16 for ; Mon, 30 May 2022 18:12:04 -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=+ftsvv1kgyZ07pkGYMo31JDRVN0rVbQcS4X4QP8a2k4=; b=mmbav1YJmni9FDhDeWrX5L+SYBm8Ef/AZsFLq/Cfqh3zCIVKNUi+j0CxC7FBmcHkpx EC77/tosYzDsIWStYT3mGLlRp1n+Wdlel1hyptaZYA/76vleyrJSlPoxcdsTjoH0ZXdv oW0nNwULA45SUefinzc13khAtwz7Fc6nAJHhgXZsKkNuzVo9TDssn2z8WYNw7O+2JH2a plwdubkm14omHY03sotmk2BSMp2CKoMgjHgX6FLGe9baOLNorljwcPkgEPrLK9Fi+8g8 uA8C0CPdcQBiHda8aoV8V98D/qO9hQuUcS4G1EAiBOjdFg8dOwS9WeerRgkugdD19sjT nHPw== X-Gm-Message-State: AOAM533WL7o2r/LwdsxJTq9Ej/BslZZiPc9oSj3I4USOlZDFJRt9Xa3k H5Uva9Yn1tfBzCFih2hzynsHV/tIUgr3UyOCSJ8CwoJGY6uI1rQgrTV+VePebL9uT47LO7NWFq0 6bv2t8JG5vIP//C4+TApfrBMlNszfmj9NCJ+fJ6ESI0sX3cJNQ4/kBq9YY5eFqZKBbzCu6sqXUA == X-Received: by 2002:a5e:d614:0:b0:65e:42c8:c51b with SMTP id w20-20020a5ed614000000b0065e42c8c51bmr25644015iom.78.1653959523786; Mon, 30 May 2022 18:12:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMlE0Rt5YEOvPReAT+xVKJwEsp+VIfQPBHnAmvRHpzn4UHcneOh9VgrZzAwMT91V2dYrCgyA== X-Received: by 2002:a5e:d614:0:b0:65e:42c8:c51b with SMTP id w20-20020a5ed614000000b0065e42c8c51bmr25643999iom.78.1653959523503; Mon, 30 May 2022 18:12:03 -0700 (PDT) Received: from localhost.localdomain (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id s6-20020a02c7c6000000b0032be3784b9bsm3158234jao.117.2022.05.30.18.12.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 May 2022 18:12:02 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-man@vger.kernel.org, linux-mm@kvack.org Cc: Alejandro Colomar , Michael Kerrisk , Axel Rasmussen , Andrea Arcangeli , peterx@redhat.com, Nadav Amit , Andrew Morton Subject: [PATCH 2/2] userfaultfd.2: Update on write-protection support Date: Mon, 30 May 2022 21:11:57 -0400 Message-Id: <20220531011157.46868-3-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220531011157.46868-1-peterx@redhat.com> References: <20220531011157.46868-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 | 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 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 @@ -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) --=20 2.32.0