Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2180398rdb; Tue, 3 Oct 2023 12:46:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9i8GjfAfl6lVdCQK0MIU5y2GSd7f0HiSRI1oQm9qrJgkqaCvjYsowK0X7TAe02CFqsHiJ X-Received: by 2002:a17:90a:8d01:b0:271:9c57:1c9a with SMTP id c1-20020a17090a8d0100b002719c571c9amr358586pjo.21.1696362397645; Tue, 03 Oct 2023 12:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696362397; cv=none; d=google.com; s=arc-20160816; b=XB7iVNLPENuBQuryfg8EfZFweVJRJp3ec0vSqoxH7MYWsdbWVpJRTDQV79+1sFJ/nz zzKSBVqYDTlvH+0pPoG7wRLnzZ7zed7J8UbA6QXtrDH/2xdrJl/3F2eK0BwtA56SrgF0 8jNh+1619m62cGA4MRogQE7pbKYwc3dtaLLDMKpRk1TvLNvMoOEAEdHtGnlJh5BU3AIC tD71cl0U2+l2WDv780NHkxhOBudejA7bJRt/txzrba/38SkfVOvEYeUPx7HouS9dQsOh iLif+R4/QTe2TLNplCmTUVsLlnhULJZoJs9LV5HRaTT1PUK9gmh/EvySG8PuWqd+J1Sp Mnag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=LZEL2BMjxz1i5idDbV1660WVS0O86XmSCyt1X5bcmDM=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=sy04jfQ16OnyXdwYxt5mpM3aF+WNhe/+t7hD3axX/P3zkkwyUgLUV5nS6bB4FkOadI /Px8vCGLgg6oQEZqRHUoCXFIw/fqyG1Ybd1GSWuieZc5ZD4+CWMY3XFN5y6ZExpv2Mhh o9LP4NN3gGWsq66alHjIV/zu60mOB5aQZjG0WU/0Sy5T5hld02D8IwQZZDfvDe4IX4Qj a9HhhHbac541MGnLQlIPrsH/SC59khlSyk9NBeZEIKyYXVKifL+v/i1QHbNy2oSLtMem 1jL3z5lBJFPOXZU1upYxVUNa6OyG1fYxyLdhvH0uBJMTU3Ut+ybXhRf8Iz+oZYnhcIxA HGdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Mq+RXsAd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b10-20020a17090ae38a00b00274df6d4c38si2066370pjz.89.2023.10.03.12.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 12:46:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Mq+RXsAd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C5D2B802C7F3; Tue, 3 Oct 2023 12:46:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232069AbjJCTqB (ORCPT + 99 others); Tue, 3 Oct 2023 15:46:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230502AbjJCTqA (ORCPT ); Tue, 3 Oct 2023 15:46:00 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE990A1 for ; Tue, 3 Oct 2023 12:45:56 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d81ff714678so1611925276.2 for ; Tue, 03 Oct 2023 12:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696362356; x=1696967156; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LZEL2BMjxz1i5idDbV1660WVS0O86XmSCyt1X5bcmDM=; b=Mq+RXsAdEu8Agt8QFclfS9ZJWQeyPjWgzORyR7dQ5ZrZPp2vHmiXbJ8Hq0EpBo7Bjm DYaSmQPC1pDTdIxAGyi+usEAYI7R/RqxhbshCoE/FO/i6WfTuEF/WukwvjRfHVN85UrN v4fae/nl9HnRZZnb5Mi3EijH5EH3/ntBGOSXkDECrLT7KvigehvgWLyP5bvP78N889rC OGsVX1N6VIlUQF5Y7NU1C5vUlAhG4YW77ueRx0S2I1zYYj5Qcv5vKOsDRiglJTFK7Z8p sfnQH9Tj3M8uHD3OHsapFSGsUwwvZeyCSw1l+DN30ac1rAIHut9N5EwZb3pL9nZWitjx A2gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696362356; x=1696967156; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LZEL2BMjxz1i5idDbV1660WVS0O86XmSCyt1X5bcmDM=; b=YtdPZ5mg32s/covbxD7CDZewpebcO6SfcJZDiNswGVTR6I1So7/yCMbDWGhpeROF4A +s+kBGjjt95SGJxOoavZpp5HrX09SsUcWtHeU4b8rlIYLy99lTrU70VE/KRcEnxtDOjB qom/1779XDaEjRNOiCCt+HOMIY09lcfKOOoECx3fLRneSd4k6zxtCqhxwiz9DjvERfzE UVFLEI7+dK74E/0ZfEf7aKW/WenFw117vIRKzfO2ct/O6g6iyCZFTs4XYdS6uqs8ezNK 4Hpp0Qx11AHy8fhsClC2niDF5GowVOx9bY2ZN8Oqnor13aYYnVgAUJ6dqu8KPrIRfib5 mP4Q== X-Gm-Message-State: AOJu0YwLQsBwSx820dSwZ5HANJpLkx9J+JYhOOyy+fv1NTUftODLfUhJ XLbmXBy3UREngV9Ur+cSJjGKJsElrIioLsP/rSAL X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:6577:b8c1:dd2d:1c93]) (user=axelrasmussen job=sendgmr) by 2002:a25:d816:0:b0:d7b:9fad:6b9e with SMTP id p22-20020a25d816000000b00d7b9fad6b9emr3353ybg.1.1696362356219; Tue, 03 Oct 2023 12:45:56 -0700 (PDT) Date: Tue, 3 Oct 2023 12:45:43 -0700 In-Reply-To: <20231003194547.2237424-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20231003194547.2237424-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231003194547.2237424-2-axelrasmussen@google.com> Subject: [PATCH v2 1/5] ioctl_userfaultfd.2: describe two-step feature handshake From: Axel Rasmussen To: Alejandro Colomar , Peter Xu Cc: linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 12:46:03 -0700 (PDT) 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 --- 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 b5281ec4c..ef352a69d 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -82,7 +82,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 @@ -92,6 +91,25 @@ fields to bit masks representing all the available features and the generic .BR ioctl (2) operations available. .PP +Since 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 @@ -101,24 +119,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.609.gbb76f46606-goog