Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1758808rdb; Mon, 9 Oct 2023 01:43:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGofJP9opGaKSXgLhGcb1/pdycc+n0uI/F8wh2/96zpej/gXuUCM44CmcmdLX4sOHzsQfyK X-Received: by 2002:a05:6870:f68b:b0:1b3:8cfb:78c5 with SMTP id el11-20020a056870f68b00b001b38cfb78c5mr18382617oab.34.1696841032950; Mon, 09 Oct 2023 01:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696841032; cv=none; d=google.com; s=arc-20160816; b=x2Ttzl2WGNNoEkaArQdKNEw9rvz5Jue7tCM1OoK9LyCGaWpX1oD9T2KskPJX6fBqdP HReuCuurjpySyiDIqo1CahBXAoLjHSeEMGqxW9WRpUPVMjh6DZApXCxBCpeSyA3khLDO mP41hBzSuZrNj2KaR3Ot5LXFNnz8zrjR5NELXjqSQt+7IiQrLoM//YFjOaN7UEJ8Rij6 lPunJk34No0DdXCnwgWcVeK+RVWbu75IirF99nHzoBBtcUF9BgCrizqzI6/rrAiL8m11 PGQMn4Ocx4nDxpDL5GOjWYZxGoceCUckgOMceOJyx/K67r0I5PAeFLvnt0EfGiYUudp9 IO+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Dvnd5EHOEQhxkJrLJPDUwQDT47MdXhl4dlryNO3aZ1w=; fh=F5M/07vUqNxvrCSEZSXffLFlrqXZOtORyIukROoamOM=; b=OfEIyoU2F2qwq4UwncN/sS7y5Vt1IDxvY0RreaoIUYfgjeps3ERCECfLoFJXs46B9/ 5WdJV2bOw5MyJV2EkJb+y8Lr1DnWiGHtBWbQ6SyLCtg6JdcYJyTeRwKfBAVvp8oOXxYI vmLUfLil2A8pe7OXbOt44sLHcks0C7oFFoDFOJGkwYu6slVrNpN2ca6HHh2YOGmFujex HA8B4t+QxpBE3e9iuEBekPZaHHPnbz/+CjJ4k7ITLv01SOObmPNdynXkqN7io1tGXVW8 VR8bnti/rbpdHh2mu4+UqfvlnXVn2ZT0f3KJKBL6mulLq+Ng1QOw6FB1mWf2eVUQBukS xwVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KE5jyaI1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id cv13-20020a056a0044cd00b0069100706960si6756005pfb.116.2023.10.09.01.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 01:43:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KE5jyaI1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B3E898021709; Mon, 9 Oct 2023 01:43:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345453AbjJIIno (ORCPT + 99 others); Mon, 9 Oct 2023 04:43:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234407AbjJIInm (ORCPT ); Mon, 9 Oct 2023 04:43:42 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDA2397; Mon, 9 Oct 2023 01:43:41 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 930E7C433C7; Mon, 9 Oct 2023 08:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696841021; bh=otc7OfNhraJmkEuE8nhHuV118f/GVw4nI6P2etVcZfs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KE5jyaI1vXYs5g40TIRVUzC931PNUBTA7Fd/tsfO4yKfdpIWV/3g2bhtQ9OA/dC+3 6nYhS4PcDvnSJnIxxc6OQZVTP1KtsOsBFDTrEL5E56HyzHB2puTyFUB1MNwCAYwM9u Oaf1EZO7dLr1Xl1rPzFrWaTCIFdCSPRjgvvuL1pao+N66Mf1nox1uxmQYqSTrAenOb cPFf1BW0jqctmUZL1KGkRTKUTi04awyxW2HZfAcfqy89skDkXl3N7xAiO6CK4VUmut SuccwWgOfzOLFnsQFvPOuHTIyACKTCOVWUcPi068bjYFRD37o6LdCuYDybW8CQ9GQs gH45+RfmowMQQ== Date: Mon, 9 Oct 2023 11:42:47 +0300 From: Mike Rapoport To: Axel Rasmussen Cc: Alejandro Colomar , Peter Xu , linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 05/10] ioctl_userfaultfd.2: describe two-step feature handshake Message-ID: <20231009084247.GI3303@kernel.org> References: <20230919190206.388896-1-axelrasmussen@google.com> <20230919190206.388896-6-axelrasmussen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230919190206.388896-6-axelrasmussen@google.com> X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 01:43:50 -0700 (PDT) X-Spam-Level: ** On Tue, Sep 19, 2023 at 12:02:01PM -0700, Axel Rasmussen wrote: > Fully describe how UFFDIO_API can be used to perform a two-step feature > handshake, and also note the case where this isn't necessary (programs > which don't depend on any extra features). > > This lets us clean up an old FIXME asking for this to be described. > > Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) > --- > man2/ioctl_userfaultfd.2 | 37 +++++++++++++++++++++---------------- > 1 file changed, 21 insertions(+), 16 deletions(-) > > diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 > index 339adf8fe..e91a1dfc8 100644 > --- a/man2/ioctl_userfaultfd.2 > +++ b/man2/ioctl_userfaultfd.2 > @@ -83,7 +83,6 @@ struct uffdio_api { > The > .I api > field denotes the API version requested by the application. > -.PP > The kernel verifies that it can support the requested API version, > and sets the > .I features > @@ -93,6 +92,25 @@ fields to bit masks representing all the available features and the generic > .BR ioctl (2) > operations available. > .PP > +After Linux 4.11, > +applications should use the > +.I features > +field to perform a two-step handshake. > +First, > +.BR UFFDIO_API > +is called with the > +.I features > +field set to zero. > +The kernel responsds by setting all supported feature bits. > +.PP > +Applications which do not require any specific features > +can begin using the userfaultfd immediately. > +Applications which do need specific features > +should call > +.BR UFFDIO_API > +again with a subset of the reported feature bits set > +to enable those features. > +.PP > Before Linux 4.11, the > .I features > field must be initialized to zero before the call to > @@ -102,24 +120,11 @@ and zero (i.e., no feature bits) is placed in the > field by the kernel upon return from > .BR ioctl (2). > .PP > -Starting from Linux 4.11, the > -.I features > -field can be used to ask whether particular features are supported > -and explicitly enable userfaultfd features that are disabled by default. > -The kernel always reports all the available features in the > -.I features > -field. > -.PP > -To enable userfaultfd features the application should set > -a bit corresponding to each feature it wants to enable in the > -.I features > -field. > -If the kernel supports all the requested features it will enable them. > -Otherwise it will zero out the returned > +If the application sets unsupported feature bits, > +the kernel will zero out the returned > .I uffdio_api > structure and return > .BR EINVAL . > -.\" FIXME add more details about feature negotiation and enablement > .PP > The following feature bits may be set: > .TP > -- > 2.42.0.459.ge4e396fd5e-goog > > -- Sincerely yours, Mike.