From patchwork Tue Sep 19 19:01:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142169 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3823086vqi; Tue, 19 Sep 2023 19:22:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHerHb+0fT8iy23w/NvAga7jEs4XDw61eBsuLvoGrvwXm67vhfk/7rM3YZqXxSrSe9b52oO X-Received: by 2002:a17:902:e5cc:b0:1b9:e241:ad26 with SMTP id u12-20020a170902e5cc00b001b9e241ad26mr1604313plf.9.1695176579374; Tue, 19 Sep 2023 19:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695176579; cv=none; d=google.com; s=arc-20160816; b=q73WV79h6l/uw3lj3X+JHy7D5/GsMFGXhA2C4lS8EvSKvO7q2cS905T3Lybu1xyghm v5CPu8pN6zHFAdBaGJU/WFlABp+UgosdGbbXTDpeH8d5drfy57JF1oXHYOGG9iSluapt GGzL3tmIjdvumiK6NeGQCvi2hpMCyPUefno3QfDPGIaOIH4ArnwtY/MinV3Y/Z88jhFv iL6mIyFIMKOyFkAq7/ggXmLeHsIrRd1b1Hkk4y2jL0C8m7QcWTpKUkj1rDrfzE+CjN43 AEfCB58C/Ypty/U/YYpiJmWg5UfPF8SzT6nY5cqNFYmFKKwiFW0PD6XneYL7FAn5IM6a nkfA== 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=OM7/ZBsweEHQQFPt50lI+eLlVKDaLR0lSsGnYD/uIDg=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=xuZwm6dyWc5M7Q9MUiZfuDaz38KpHYKrcxTTcb9R7FRAbJ0VwNGZAFdLx8IKSgKd+2 82lUlP7aHh94Bi//tE1HIL/0Jrqqi2O4kaTKV+ghtsu2Zzpw0y7DyvZzyVhsrGSHpqVz F+F0pw0EmSLGz+5oDoN00kw8fa2SujWUgRtohSIPVhnq9aJFwh2vuN+dKcWHTm4epiU3 AoWUoN/yckRuoK7lrjXMfaZcuGWnXBsSTDI3oge8vZflltu+nj2xcXPSAfpB3/menBlL UfwXATybHTBsDrHGlxEtHpQCye/KeIGAylx/S3OMjgQhk8tFktRppxql9kcOrFzztqRR nLWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TL7YK71y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id le7-20020a170902fb0700b001bd949bcd75si10488271plb.575.2023.09.19.19.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 19:22:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TL7YK71y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id D1E6D820C35E; Tue, 19 Sep 2023 12:03:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232594AbjISTCZ (ORCPT + 26 others); Tue, 19 Sep 2023 15:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232503AbjISTCW (ORCPT ); Tue, 19 Sep 2023 15:02:22 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7298E1 for ; Tue, 19 Sep 2023 12:02:16 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59bdac026f7so73205247b3.0 for ; Tue, 19 Sep 2023 12:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150136; x=1695754936; 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=OM7/ZBsweEHQQFPt50lI+eLlVKDaLR0lSsGnYD/uIDg=; b=TL7YK71y+TUTy6fGHYiqdt4EtznmZCsTiHX38kHatN4xhHv67/jiXlPuGF2TixAK/m AwAnc1huXwj7Kkc1XDnMP1lT4t+s/lZd7VTuW6gu2fgOFm1OiPF7V4JZgnOuavWSO+EB OylC/CtOFWRfzrNpB0UKREr5Bd6tSYckKJXohuyIjLLv3vUrmi3dlHv4IahrJ2oaB3em UOpkZCFgCRhIanNHMSCO4awRhDvx3N9Y2pVAjUXrKBO6aqF93RDswWshoCVSVLu3ZgF2 km9BZHT3khi3N+Oi4nroprbc4fCKPDIMV1dfsdu29GaMjWZnK1xf66H5lDijGxxOdSrO h/lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150136; x=1695754936; 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=OM7/ZBsweEHQQFPt50lI+eLlVKDaLR0lSsGnYD/uIDg=; b=dRh4U7RAuuBxjfZVEwKn8TkULqOs1WF8Tqim8fb5SYDBaHHq7x8d4NSwiS5dPUSKf1 /40I5TJVFfeZudOpxciQ2lHsBf0vMKgDssIwioF2pVZTWGN+gu+wJcVAgsm3nUl0raE1 uB38eX8DxQkzksLEH4qpxi0Y4OmVDuIRh99Kx6E3MR9ep9fE0266zmxLPdNDqdwK7I0r hDRXDCldlkxBY1EWbEOSQsPYSD/ZZHoX1xwGXw/zI2QBMhA9ZoPlOS4inMXRaUDR46JT Aqr5MH2TGz0GdvC0orBkVRQSdRPr7p+lZcLbiWhAuxaN+325mPpxHJMJ8I5ektnJHEtl Ygyg== X-Gm-Message-State: AOJu0YycEw3Qy03Q8xo5Biljt1dYYt7UBRJbiZU3obbPG5u06X1mo9s5 KNZ8aX/9Zx3fcbdAI1+vkkP79a2dB/ya+HfHAFiH X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a25:ab48:0:b0:d81:68ac:e046 with SMTP id u66-20020a25ab48000000b00d8168ace046mr6411ybi.12.1695150135954; Tue, 19 Sep 2023 12:02:15 -0700 (PDT) Date: Tue, 19 Sep 2023 12:01:57 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-2-axelrasmussen@google.com> Subject: [PATCH 01/10] userfaultfd.2: briefly mention two-step feature handshake process 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:03:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777521477107112368 X-GMAIL-MSGID: 1777521477107112368 This process is critical for programs which depend on extra features, so it's worth mentioning here. Future commits will much more fully describe it in ioctl_userfaultfd.2. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/userfaultfd.2 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 40354065c..1b2af22f9 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -200,8 +200,9 @@ the application must enable it using the .B UFFDIO_API .BR ioctl (2) operation. -This operation allows a handshake between the kernel and user space -to determine the API version and supported features. +This operation allows a two-step handshake between the kernel and user space +to determine what API version and features the kernel supports, +and then to enable those features user space wants. This operation must be performed before any of the other .BR ioctl (2) operations described below (or those operations fail with the From patchwork Tue Sep 19 19:01:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3778780vqi; Tue, 19 Sep 2023 17:36:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmJTru0ruhxFwCdUgwNFPPbMYRe4+pO6hY4mQtpr8xhv4ZWdmuLLww8CzkQ3Tw8Z8ATDWq X-Received: by 2002:aca:2214:0:b0:3ac:cf91:9157 with SMTP id b20-20020aca2214000000b003accf919157mr868494oic.53.1695170193803; Tue, 19 Sep 2023 17:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695170193; cv=none; d=google.com; s=arc-20160816; b=EwyuEtFzorHOUWOixQmow0oyIgWMCtkoxHxPk07OEHEV+UQwY6NnLOZ5JKpw6HM0sG EeztxuXNtmBsCkfvie/kLaIRxaliXby8FfQFvU87lEDDnUeSkLYbr8dLlFDT45siR+WF 5TrymPQGxa52LuZ+SXQXhyjysb3y3jR8wwhhkHBB5kI6B3xhSG843D0P8KX8E/BI46PR Dr02AykNdCs7BHvWwXgGI7Al2IhcaMxj3o06rrLOFTZrf7sGN7fI9yPDpNv6f36vm+zO g4dpflcIhxDMzi+mfAVwQx47E/XGSqgE/+Onj9wa1QoEzfVEpVx9HpyguC6HcqHTXXjO JKOQ== 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=x6ui7w7cp8TYbfd07TcF3y+H8C9qnaw+znngkakEYjM=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=VTxVoNc8MV54NM0oDE7q4DI3PBt21DTHgpA7Ja022q1L5bDfWaH0UNoHmxoDdNesb8 J4+qQrPAnMSnWs5/zB5T84U+kbbRPmvgPQRdY93NcPicnkE2OW10iRouqeKddtQDCTQU DxKFqipSpIFbA4Nh2u7ciJLtytD0biA2TZEHPmh23JLEhCCbWQNogOuJXMHvZaZ8jwky kGShbATC1bOJ5iEYxCO9C4uVoO4xw9q7mI80xeNh2ixtRNxbvvrWMLrz6ObZKlI5U2np 2/90YNNNTFESApwOufdHqxfjrrIjfR4U8pS0Nleq12ckiqCUDKgGnoI/QykHAJMGl0+P ud9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=LcscbQOX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i3-20020a63e903000000b00543c84bf588si10703806pgh.473.2023.09.19.17.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 17:36:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=LcscbQOX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 46EC48301481; Tue, 19 Sep 2023 12:02:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232717AbjISTCd (ORCPT + 26 others); Tue, 19 Sep 2023 15:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232590AbjISTCY (ORCPT ); Tue, 19 Sep 2023 15:02:24 -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 7A974B3 for ; Tue, 19 Sep 2023 12:02:18 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d8141d6fbe3so6614023276.3 for ; Tue, 19 Sep 2023 12:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150137; x=1695754937; 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=x6ui7w7cp8TYbfd07TcF3y+H8C9qnaw+znngkakEYjM=; b=LcscbQOX3ImqVLH+5kec+ofiycAZm4qAuxza/IugfiRNp3zXc+GMQm+POfpFCPEeA+ 5lTTbanDD9Po9U/OHM6kYeaK9UKFVaj+CJPjwyfROJcdBXnmIHrShKZxCV8SuXBgvVBg UES1b6xTUdQZsGckZk+azzRakl5HCQYatGRqrDRPqetyEOrF4ARqjNgIr3Ppw8QL6lR4 RHjnz87lUQ7kE0cFJJfhGatk7AGkyeYXPh0LqIriz1pALWbB1JPkQn0Cz/IMDhAPM5fa YXkIlmKEm4AmLQIU7wOU5hVxLXPUTK9OziWtaeGheuhn+tJVeKBd/zZMlCpqxP5hF+ae JUfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150137; x=1695754937; 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=x6ui7w7cp8TYbfd07TcF3y+H8C9qnaw+znngkakEYjM=; b=Lz+Z1NjYwI8cofXe870KzDGjaol/KuTEdGuojwUudfApL4pvz69MWmp2FVFTt47TX1 QGY2NwReCtM1y1gEuFh/TF0gE6DLfey3wxdLU7VjzsL+FgtfkcrYv3l8joOSX7fxiOKl LS1nnpkkJueid+gT+eY/fa5z9OcPV1wpwhLW+S2qCpsmCRwAp/+tOzWQEzRTbzw0Ph17 Zv+D52tEFSotr1zDiIOtNe3OyOJpK8xnXvEbfdk9Kw4eGHjR65j0ah4+N/AYX/MzUFGl 9vowQMOv+4+qBm9dt/Rg6TUSs0MeMy7hSn9tqMCTiNM7XPfv9GWDV787b02wyz4RIXay KozQ== X-Gm-Message-State: AOJu0YwNUsYlRKGakid8sSvKU6EvOQoQEQ763SEma/Z3YUpveGlUL27d 2WWzmijpSj0FsGBlFbMI5MhhDRiZ6eZly+u7LJTJ X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a25:8b0c:0:b0:cf9:3564:33cc with SMTP id i12-20020a258b0c000000b00cf9356433ccmr8307ybl.13.1695150137798; Tue, 19 Sep 2023 12:02:17 -0700 (PDT) Date: Tue, 19 Sep 2023 12:01:58 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-3-axelrasmussen@google.com> Subject: [PATCH 02/10] userfaultfd.2: reword to account for new fault resolution ioctls 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:02:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777514781190239540 X-GMAIL-MSGID: 1777514781190239540 Basically, reword the sentence to clarify that this isn't a complete list. I don't believe it's worth maintaining a fully complete list here, instead ioctl_userfaultfd.2 is the place to do that. Let this just be an example. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/userfaultfd.2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 1b2af22f9..00d94e514 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -222,11 +222,12 @@ operation, a page fault occurring in the requested memory range, and satisfying the mode defined at the registration time, will be forwarded by the kernel to the user-space application. -The application can then use the +The application can then use various (e.g. .B UFFDIO_COPY , .B UFFDIO_ZEROPAGE , or .B UFFDIO_CONTINUE +) .BR ioctl (2) operations to resolve the page fault. .PP From patchwork Tue Sep 19 19:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142062 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3617188vqi; Tue, 19 Sep 2023 12:06:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4PC49j0XJBHBvu6I56etFY5ov915DFH2rOoNT5r/bNFjBs7m8G4uYo5KC//0mvFbwul43 X-Received: by 2002:a17:902:e804:b0:1c3:8031:1d9e with SMTP id u4-20020a170902e80400b001c380311d9emr390719plg.15.1695150419396; Tue, 19 Sep 2023 12:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695150419; cv=none; d=google.com; s=arc-20160816; b=QAsZYw7i67lirBIdZPGgoQTgvSTgNBmYuCczAUqFRgUV2023TKjuIbLhS6kYj1nYL/ 9hC8CbALAPeTM+mZWZy7tiMPaVqjsDEQn+f/B1uRLa5qn8N3J/eBdmZz+O8Jmsf/cPYk dlsLV0iBa5ZyFuQ9T9N2o+QoX9ZExsQrqu8IAQhKXCGMxn0LnZeH/C3Z31D5G/20uO9o eN5TKIP7n6FKKG+nvlpiCAXb2+l2WOm3OBVn9jzxUDqRSBLkM5sA2dLvqm2axA90+1Hb EedOC0vyBXKWe10Kk32cVIXPVsKAvd41v1E3dtjIgyRfSJ9Mv2/1Kb6RNq7SiRJud+6y ZnvA== 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=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=QOIJY1K2+sA0cbBAaMfHaMhKGsIEhJzithedU763yHVf7nvllMRG1wpLJaY6BwdE1t qORSvuXGk0vzWp+pBhINqVgT0FDOrEv4Jld6g+SbIvsMcMRNXaJLmZq9xfx1SIr6jQuA gNm7bcoqdewUn3vx8+T1PvMjLi3NBPHpiSb2AYe3j6SQEzXdYPyWGJU2MyzVESVHqfWR RXogqoPc96Qrrw9w4zncQiJyvfw8z4KhONRapZNkATF4QAlcKX2S3ZYWKvADGFrrWabn hDSoGfMnKEHFiQUiSahHpbIysqp1CSvcdHjxewsTX/iUHgXg2c5sfC2d+kY6bX6+n2pl UiOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RfuW+oLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id o17-20020a170903301100b001bb9d6794d3si9872338pla.72.2023.09.19.12.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 12:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RfuW+oLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id C9BA58081BCA; Tue, 19 Sep 2023 12:02:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232845AbjISTCh (ORCPT + 26 others); Tue, 19 Sep 2023 15:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232477AbjISTCa (ORCPT ); Tue, 19 Sep 2023 15:02:30 -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 D3A80F2 for ; Tue, 19 Sep 2023 12:02:20 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d81841ef79bso6655032276.1 for ; Tue, 19 Sep 2023 12:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150140; x=1695754940; 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=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; b=RfuW+oLrkSfj54woc+wxQPhieeRi54xqzswro7rv/4GQgHRZ+lKMdoytyLc4q6AdXp 2kUZmrFIkj59xZQnca8mIMCq1lI7nilMkEYXAYBqk9hXVdyoA/LjLr0eChf+6RQiQrQa 0S8WpnxdazGcTJacisCSD3zv7+YJxd6qKA2X2vqUzTiA+lz15do0s04RiWrUxV84SqDD dGNGh7R2fslNnrsksgagle0lkIU1rf6Vbzd5fKid4OuCkiJMevQfa7ZFw2YbAeNXLpXx /q4/Ps2nZ2PT5ltz0txjUq94m8Cl1TNHZO6xNKZMoURfdqgdJtUI80T1GcCB+6H8dOVZ 8H1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150140; x=1695754940; 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=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; b=QBOkvNLeu4mRX4a0lpADvQioXKl6WMWzo04VQ9VI/cRZOrQYykboccAiyccuevF0FJ 7xz663cnsNs9zb12pqqsS/4iQedw9Kwp9EDW6nDwwbxeF/q+MKBSfiff0zTvobroPzDY jyOZbcqkazgpt9C0OGlRl5ueLPdENX0ZRRIU+vSxCu7oN6uLv7UMyJCGbRAmFTvHLejz FCz8z52tkpQFNyHRMpzV/yF5gjjiZxg5Wg9l2HS6nYyq5GTroifLY6bbLKreCmiuef70 CfUwUlOkEvyrc5sm5R1/2zntziZFEHpu89zizN/ZrO/+EiOY1Xvg0LStmPMNnBa8ADPR OfpQ== X-Gm-Message-State: AOJu0YxBtpqq9PX9hQOzFUvYxmy3wDt778th3ZLuNOHG7PJ+9pStvY1o 5/iSJkvuBKlzrvktdRWGbYu4e9kNk1HQ9TzKYsn8 X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:1805:b0:d77:f7c3:37db with SMTP id cf5-20020a056902180500b00d77f7c337dbmr7869ybb.8.1695150140155; Tue, 19 Sep 2023 12:02:20 -0700 (PDT) Date: Tue, 19 Sep 2023 12:01:59 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-4-axelrasmussen@google.com> Subject: [PATCH 03/10] userfaultfd.2: comment on feature detection in the example program 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:02:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777494046018429518 X-GMAIL-MSGID: 1777494046018429518 The example program doesn't depend on any extra features, so it does not make use of the two-step feature handshake process. This is fine, but it might set a bad example for programs which *do* depend on specific features (e.g. they may conclude they don't need to do anything to enable / detect them). No need to make the example program more complicated: let's just add a comment indicating why we do it the way we do it in the example, and describing briefly what a more complicated program would need to do instead. The comment is kept rather brief; a full description of this feature will be included in ioctl_userfaultfd.2 instead. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/userfaultfd.2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 00d94e514..b2b79f61d 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -881,6 +881,13 @@ main(int argc, char *argv[]) if (uffd == \-1) err(EXIT_FAILURE, "userfaultfd"); \& + /* NOTE: Two-step feature handshake is not needed here, since this + example doesn't require any specific features. + + Programs that *do* should call UFFDIO_API twice: once with + `features = 0` to detect features supported by this kernel, and + again with the subset of features the program actually wants to + enable. */ uffdio_api.api = UFFD_API; uffdio_api.features = 0; if (ioctl(uffd, UFFDIO_API, &uffdio_api) == \-1) From patchwork Tue Sep 19 19:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4259425vqi; Wed, 20 Sep 2023 09:20:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG94+DmlBJMRdvt7kYQAeKe3LShyY0FTLWf+bwo/a3/TiMfBJVWP6uMba67A//CbQhjdAAX X-Received: by 2002:a05:6a20:258f:b0:153:4ea6:d128 with SMTP id k15-20020a056a20258f00b001534ea6d128mr7332957pzd.13.1695226836980; Wed, 20 Sep 2023 09:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695226836; cv=none; d=google.com; s=arc-20160816; b=tLqX792HP/pQcK+Fxoiqv74wecjvUcGf9yPxE6x2QV5ljtC4QAHIclJxegCNuYeoBa F9oBppx0GCa0UkqaVBHb+05P6Txa5xndkRqkLOtRZlYzOVE7OTaSsoR0K7/GRv47BsBy ni05OFTEdC8dIkjhFoKt/l15Kt6eXExCE+4KooNkkP6eKBWUP4yHFvKyyzyVJqvbjhjp i29y/jUCGvWNAs4xu6m22Vgl3OCwwPImBYz5DGi7ta3F8Z01iJXxhaUqK5di7J5fiVCa GroqG3gZmKmT6IVVrMiJH4khMQJHwI9LEM5MKKOzlOEK4KyIjY1Pqmz2uRwFDJMxPfLn ADgQ== 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=gOdPMAxCjzIvLxf6qfx/KF9XXYtmYZAQcBo4SahEGKQ=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=YNe30hl+nELkRdloQe9lCD+1M1bey9orwfuxkHEnEJ+XVxnlQuTFs7FBSpqx+frK5W kbR0xoeSlFMQPCRfqqQf6JRrcdGVSq4fp+dyYNd8KdnPlctM2oWmVOoEY++jha2LJDof Ix4pdkGfpmJuRBmysZDBvpGRrFmHGSgnSZMIqfzLJIvTdJKVByjqWvhaOhsQjilI50Mc TragEzumv8LYrBzXEACTHuJwpbI21m0El0DMrmJL5CKTsyknq2ACdyvKebToPUFSFrWS uqLkOwWcpSszFhh8Qr8oSH7k3IyPB5c1AWMvYfkewqRyKL6WX28ejO1a9+JRD1nzGGCv TEgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1fJ3i6U0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id 19-20020a630c53000000b00564d6ad2746si3244804pgm.452.2023.09.20.09.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 09:20:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1fJ3i6U0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 949078301499; Tue, 19 Sep 2023 12:03:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbjISTCk (ORCPT + 26 others); Tue, 19 Sep 2023 15:02:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232714AbjISTCd (ORCPT ); Tue, 19 Sep 2023 15:02:33 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9EE5128 for ; Tue, 19 Sep 2023 12:02:22 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59eb7293017so22482317b3.3 for ; Tue, 19 Sep 2023 12:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150142; x=1695754942; 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=gOdPMAxCjzIvLxf6qfx/KF9XXYtmYZAQcBo4SahEGKQ=; b=1fJ3i6U0CgJ0P8Iemhm3nkJnQEjA+uvmLAt4yMlxiom3Q623ZdK1ISGVaIF2MTYEHZ cxYjxVtG6nMFSLcJNqpvSGSNwidMRCLg+uZidMoiHSUOv8VvHjA6DJaWGVBRTYL2739c MUXP1LgHr/Mbj0u8W8QNqhDY9HOICcpWouCBauXtTgo7bu7lotoLAJG6niCubYMm+4Zu xcz/E2aYBW12KDQMQxWy4MPhtD5GTKDv7f1viQIBAbtu5gYH0oaVUyYKbkhphtDEWdx7 bFCxPGdZpxvdW506J6KZ/VSvkQPFr9r0lxYerovKL27RjtQni4YccyniCz1gMZnm1ijV lDAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150142; x=1695754942; 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=gOdPMAxCjzIvLxf6qfx/KF9XXYtmYZAQcBo4SahEGKQ=; b=M9M2chrJ4sdZt2eLCP7x2trSMvcUJ6k36c9wFB/ikR1hOfLQaHM6pvceOJwig6ZJX4 zrZjIvqkz5sLKy1KweEGTM0FGGGSwzhey679gmnlfAWdG1CL0msq1HfS9bHwvVPcnl0E ZufrAu+9wMA/D1XQS0Bk3U4Cul3k7c7GOdbLzmlHNlOFQdvhpA7yTfEFQQihxvwc/YK4 g87SviPIdKREtOefZEK6uIZdJRAx4nRRgKHYj9YzJUmkhhQXNTyPyQReK+G4AoGdr916 J70s2zWLankbj2TYg2JP8eo2cBGD1AWcyU4I3vbThuIXUDj2Nne4hDZxsI1JWcIcMh2Q Be6w== X-Gm-Message-State: AOJu0YzrUbhS6jNiIRt1kBdmMSCfaf7036thHZaxUVQJe2NZGTdayXG5 0CyN7dNtSO3mR++nHBGg7mbXdXHWktiQ9sIJr3/I X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a81:b709:0:b0:59b:e669:c944 with SMTP id v9-20020a81b709000000b0059be669c944mr5687ywh.3.1695150142185; Tue, 19 Sep 2023 12:02:22 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:00 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-5-axelrasmussen@google.com> Subject: [PATCH 04/10] ioctl_userfaultfd.2: fix a few trivial mistakes 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:03:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777574175633476717 X-GMAIL-MSGID: 1777574175633476717 - Fix missing paragraph tag. The lack of this tag yielded no blank line in the rendere dpage, which is inconsistent with style elsewhere. - The description of UFFDIO_WRITEPROTECT was a sentence fragment; the last half of the sentence was left out by mistake. Add it in to fix the issue. - move UFFDIO_WRITEPROTECT 'since' to its own line All other ioctls note the kernel version introduced on a separate line from the ioctl name. Update UFFDIO_WRITEPROTECT to match the existing style. Signed-off-by: Axel Rasmussen --- man2/ioctl_userfaultfd.2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index b5281ec4c..339adf8fe 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -31,6 +31,7 @@ using calls of the form: ioctl(fd, cmd, argp); .EE .in +.PP In the above, .I fd is a file descriptor referring to a userfaultfd object, @@ -351,6 +352,7 @@ operation is supported. .B 1 << _UFFDIO_WRITEPROTECT The .B UFFDIO_WRITEPROTECT +operation is supported. .TP .B 1 << _UFFDIO_ZEROPAGE The @@ -693,7 +695,8 @@ field of the structure was not a multiple of the system page size; or .I len was zero; or the specified range was otherwise invalid. -.SS UFFDIO_WRITEPROTECT (Since Linux 5.7) +.SS UFFDIO_WRITEPROTECT +(Since Linux 5.7.) Write-protect or write-unprotect a userfaultfd-registered memory range registered with mode .BR UFFDIO_REGISTER_MODE_WP . From patchwork Tue Sep 19 19:02:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142078 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3652538vqi; Tue, 19 Sep 2023 13:10:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHG+dIPxM65Ro2mCJBHrOJErpXfKWzAJUJqoH5cAp2/VrxZf6zHhNtJdFaZQCvG+xUlQ2gC X-Received: by 2002:a17:902:b782:b0:1c4:a650:21df with SMTP id e2-20020a170902b78200b001c4a65021dfmr443844pls.50.1695154227483; Tue, 19 Sep 2023 13:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695154227; cv=none; d=google.com; s=arc-20160816; b=VPZ+3jqF2SaMiVAOO1jtBBxk5yj3bdD4/HuVaHIBgAIpkK4x9CwhLGQ2brLVCDQel3 9bQ5liVFEO36oCTTLzlua4kptD/aax+IDB2LtnJOncvjor8qlhcm+trkeN8XSz3ofla8 PZdQ7+s+NpzkK24tJUfbsz+4MY2B5YGSamfkrSz04SmhRsTxrKnPxiAGuHeiyRT9an5Z +A5cPbXta14zAYAyQoEqX4hjYOXep2Ozoa0uC6GjEH3WrfPq3syEQyZVTdZkGwLjfUv2 8e5PQYy4qZ6tdHdgGE5TDdqtPa1uQDMeQ5Kqy0h+zzGPAwyrm+ZD55Z29qMK8pHwr4LR oAJw== 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=yByc+t8MiUd/FlhKNAv002747b3UkcfIteNK5wC98N0=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=zlKqwpi/C9fJzEQVnCm3Cn1wmTpeywbHk7UYf7cZxCIvuefWJ0toX0Lph9hidTtocY s9h+XyQnd4sYnAKNwtzrCIbdtxKROFXF9jO/yMmsqEe/gtXUxIfEaGrq2UInl+vVyPwn mNroHmGrIG6ElvlkS66NSEI0nQViyUKZ7lcbvso8f+ziaO/kOg3lwFiR9toxApx35EQi GYJsmhNLZknsbFAQnVkTG9+WWxD/vL7tzN90RhWFyDZV4zF1U7LyjhIHwduo8nLky/Js uLrF0Qr4cpIPH1jQVllQCeaayXPFFYMaIeRAec/7Tv6z8HY6xJ9NyRRLdtvSLD4VmbcB 8VZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SgOcQtHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id ay6-20020a1709028b8600b001b9d800b487si10001183plb.87.2023.09.19.13.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 13:10:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SgOcQtHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 767EA82A9BAB; Tue, 19 Sep 2023 12:02:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232679AbjISTCo (ORCPT + 26 others); Tue, 19 Sep 2023 15:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232758AbjISTCf (ORCPT ); Tue, 19 Sep 2023 15:02:35 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C447B138 for ; Tue, 19 Sep 2023 12:02:24 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59b5a586da6so2485587b3.1 for ; Tue, 19 Sep 2023 12:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150144; x=1695754944; 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=yByc+t8MiUd/FlhKNAv002747b3UkcfIteNK5wC98N0=; b=SgOcQtHMjLK+EGkutrFRwTSKlH9Sc5Qc0BTau9o3MxVjYiaMeBlrZRW2K//iS4AsEB t5y6719VtwzZ5Zj7MGrm8AUC628FlAFhNmGiS5jwQSFCRYmo8D0ziMoEUK+iEOfqSJQs e3Uep8dyPpfXJZIi0ME9wSGnrHuEbTY6NnrnBqufYk3h03Jow4xC8m1io9D6eevaaYWZ c7GMg5v/0FXsANHfWX361BEfVqO5wgeGP1Vpif0J3rjqSrHtieptDWNKIZnWduHsk2kr O2+clrM4Efk1hgoEOqHEikBNsjzYZmfoRb7ZD+k+cchG/BUHug+ws3NWfXBpghk7z7rj Bmtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150144; x=1695754944; 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=yByc+t8MiUd/FlhKNAv002747b3UkcfIteNK5wC98N0=; b=biyLNDqf6tazUMU5R3WBhOLIQ2/D0LpRNgTgrtRRGSJb+X9jFGW7bN7pwZx+rk1+K6 n7p3QrjDRPKx6TdiHdZn4fPKGy6PSVHeQxVnb7Ay9ci3rg/P4sNRiNFVE0dDmJQHb4oT EQnjiGwxF13OREl1oySNkiQy2pCbFB3MtvTlnrtae3Q/BL71Zas4QayXq5U4cG5U0Hzh D/hqMWs4dOtFRlV0iuO4E6gcBKk02kbX/r/C3eiZ4ZHmzcVkuA4+FyBuuQOZU+aFug0I jNW6lY2qNl8ifqwIUr8JMqzIxZNFdHaXCKfCTBMEKPraNozsM4vMmAjRx8gcIF4yvEHN EEbQ== X-Gm-Message-State: AOJu0YyoXUbISfjZ/79GHkzA5vvA1A/8/odrdQb2xocUvpioqehZBCrw 32JUhmm6skt2Za0NM0U5wBQ11YUVE/Lyr+H4GoaP X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a05:690c:d8f:b0:59b:5a5b:3a91 with SMTP id da15-20020a05690c0d8f00b0059b5a5b3a91mr113072ywb.2.1695150144075; Tue, 19 Sep 2023 12:02:24 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:01 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-6-axelrasmussen@google.com> Subject: [PATCH 05/10] 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:02:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777498039386999935 X-GMAIL-MSGID: 1777498039386999935 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 From patchwork Tue Sep 19 19:02:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3662181vqi; Tue, 19 Sep 2023 13:27:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBi4U1CFir+rTbJDZwShv+XWOJ4XCgQUogAF/ghGmfpO/teoaSfxRph+sA0yM9kGhcvq93 X-Received: by 2002:a17:902:b782:b0:1c4:a650:21df with SMTP id e2-20020a170902b78200b001c4a65021dfmr483373pls.50.1695155265773; Tue, 19 Sep 2023 13:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695155265; cv=none; d=google.com; s=arc-20160816; b=f/IC2t7hPIYHj+GyQpv8MpaciZvA3x/rFpoRIXHm6xBhY7Tz38g7J7dKI5bqUPkWmM ejFNGjV827PYZ6liJz8EG9Wm0GR7Bd2vHNY/cna3VG49YR3/jwFWLmZcMQA15/lb6bhF Vqc5aLRn7EszF3FJUGHwZ8FfjXmslYiuvR1ClLuuF6AZ1Drh0xUHJkwPc2mTBxk1GOZw 9s5CKzaHcKm2mkC4iDQ/yZ7v2fhPsGccT/0MOAFJ0cRO/EleTMdHJtiFFb6Hmfq+QFU8 oafnZpqcWLugqYt7RjPxz2+rT+Po8BprQxh8lA2N15NrCjUWEUaT8xcYfOOWNBIiUjxe gBEQ== 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=NEXa90h/68GUsd6orjyORkWHy9a7mT47IoYQaYRrJqY=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=neb2ZZ6Qtr8dd3xCmcvTOLO16EyOjpPtyLcxrK8Ghr/aonfqhmg1UgJvZXmTo3USh9 4hJQQQtAxSpkjIVUaxxPbkrJwBP4gW3ZkA9O9bdoKk+Nay+cnr+SyGYCGnJ0OyGKXKiZ F+qi2D9Jd2pr1kLMqx0duzVV3rEC6cNEU+TPfXC9DGHeZcCTdP3elRmWyBOJzDDDkESE pWEjWwCyjNJe6iqdV8Ziq1JO2OEXEh7+RlDoOhkgaJyHbrGvcFNOmrPrRNTVEzXb6L44 mrhk8ugQLaE7sHOD6JS0bDCnzWDSHNh7jlr6zCiNrbTWXijhRJODk8+NFgyLIZphYr9b u40A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4BGM7sKN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id kg14-20020a170903060e00b001bf0e15c0a9si9362662plb.269.2023.09.19.13.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 13:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4BGM7sKN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id D0F31820C35C; Tue, 19 Sep 2023 12:03:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232734AbjISTCw (ORCPT + 26 others); Tue, 19 Sep 2023 15:02:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232805AbjISTCf (ORCPT ); Tue, 19 Sep 2023 15:02:35 -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 1B48EB3 for ; Tue, 19 Sep 2023 12:02:26 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d81646fcf3eso6628378276.0 for ; Tue, 19 Sep 2023 12:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150146; x=1695754946; 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=NEXa90h/68GUsd6orjyORkWHy9a7mT47IoYQaYRrJqY=; b=4BGM7sKNay44Df+g1Nw7jE50VV4DWrA0nROlWCooGG1H1RemZ7SOImOL3JqwGUF5p2 YG+SI8JO1m/4mD27dbBhBBEgNGOhzValgvOf7S8LqtniXOdj2CXynEgooHy6K1lfoQzI XXdbQmMQgUoVI6LGhPMudhzAvkbFtyWu6iL6RgVcAtrgAOcNArFcIEkO9z/HommLEkJK pEJ4zaP9tQbNq3F/AFP9sOHxPOJTMDEMps+2YVNSooWH+1bCNOQUcOmygMX/yv//z4H6 ZutUQhgR9lK5EJlnZiwZOyrnW6Zsu0eMJhp2rT6WGWyPWekZ3IZThOAIRWqu+JLcLfJT 8mBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150146; x=1695754946; 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=NEXa90h/68GUsd6orjyORkWHy9a7mT47IoYQaYRrJqY=; b=d33S8FtDyVc2WQnjDUW8DGNx2CqCMW2WU/Tl76KbWEq/H5AQIBnaS2Eu9CVQq3oTN9 CLA4W2AzAP5jQp2DcKyMRsS77pa4LjNiQ5nFEY6mZiwpe/NgYwrxMMAeYORXW/E0jwB5 /na+rKVXKZlgPfbSuzQXHBY4mMGAjg/GVXgZCMzl44RLVkfoUooDYSnzTvZqK+5ftdBC 0vmlAmwGvJ/OGzhDvVKlOg/ZPscumkt3CBGQqkbM1aUjm0Yps/XrqogpCTtR86vr9qFJ Ax38ihjuAsExWo/TY1W9T+i8oZ1PAHPXcFJVl38OsGrHsebSeXzQjlPRj4TWFwIbpEuy iCUA== X-Gm-Message-State: AOJu0YwiKNSjzwVwBVmCcgyZgCmEQ2dou79aXhlmw0C4D2VS0BqN/VuS NP+T6DYpi31p/TK09IIAdfA4+mxSgIlDVwnZajr3 X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a25:6802:0:b0:d7b:3917:4606 with SMTP id d2-20020a256802000000b00d7b39174606mr6912ybc.11.1695150145976; Tue, 19 Sep 2023 12:02:25 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:02 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-7-axelrasmussen@google.com> Subject: [PATCH 06/10] ioctl_userfaultfd.2: describe missing UFFDIO_API feature flags 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:03:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777499128181469610 X-GMAIL-MSGID: 1777499128181469610 Several new features have been added to the kernel recently, and the man page wasn't updated to describe these new features. So, add in descriptions of any missing features. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/ioctl_userfaultfd.2 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index e91a1dfc8..53b1f473f 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -204,6 +204,13 @@ If this feature bit is set, .I uffd_msg.pagefault.feat.ptid will be set to the faulted thread ID for each page-fault message. .TP +.BR UFFD_FEATURE_PAGEFAULT_FLAG_WP " (since Linux 5.10)" +If this feature bit is set, +userfaultfd supports write-protect faults +for anonymous memory. +(Note that shmem / hugetlbfs support +is indicated by a separate feature.) +.TP .BR UFFD_FEATURE_MINOR_HUGETLBFS " (since Linux 5.13)" If this feature bit is set, the kernel supports registering userfaultfd ranges @@ -221,6 +228,22 @@ will be set to the exact page-fault address that was reported by the hardware, and will not mask the offset within the page. Note that old Linux versions might indicate the exact address as well, even though the feature bit is not set. +.TP +.BR UFFD_FEATURE_WP_HUGETLBFS_SHMEM " (since Linux 5.19)" +If this feature bit is set, +userfaultfd supports write-protect faults +for hugetlbfs and shmem / tmpfs memory. +.TP +.BR UFFD_FEATURE_WP_UNPOPULATED " (since Linux 6.4)" +If this feature bit is set, +the kernel will handle anonymous memory the same way as file memory, +by allowing the user to write-protect unpopulated ptes. +.TP +.BR UFFD_FEATURE_POISON " (since Linux 6.6)" +If this feature bit is set, +the kernel supports resolving faults with the +.B UFFDIO_POISON +ioctl. .PP The returned .I ioctls From patchwork Tue Sep 19 19:02:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3851934vqi; Tue, 19 Sep 2023 20:41:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkE36/3DJVaVTF5l7CeUtOawiNcv/V4yVoNIqvUARLlv6WF1GpO3zqU1ecYCiWFzu62RbT X-Received: by 2002:a17:902:c106:b0:1bf:712:e4bd with SMTP id 6-20020a170902c10600b001bf0712e4bdmr1011318pli.65.1695181311118; Tue, 19 Sep 2023 20:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695181311; cv=none; d=google.com; s=arc-20160816; b=01XJpKyY8YuWc7rMREqVElWs84QLDyAIiihudnl8CZtgfMBtGuT8HgBT78Rabm2/xW lM2Tprr3hGmd4kpN+BxfTT7uuVwz49ffC51Vuc0YRJgYAowo0BR4hgQWQlNCbuY3RABX MogQb7o30GTSEQkqKzs8vSctjflm1nKkDNq4vPVqoMQRl4023OlT06+fAi1iJsiEoGib NIX59dyhQ6Jt9+j8qPFgKZybX/uIRTGjHfbuAg8hXD1wyBLvVcE68vcGeIn6AG+g8x51 DwW5Rp8m10x8PWWmx24mVzT0w7UsDjb4eSRLCZl560McP7oVrrfohxLbizYDXRAxj1Dr RWsA== 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=dATpzHjDHVSfxWhEgldjVmKuWzgWmKZlkhKuoIGibHA=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=oAEZuTVNMoLoiIpMLkdTScT1I/8NkD2FJxkED/yT7xecqmYr8zqFuRSXFdxFbOYk/B JI4L7vYL6WQa59oW+cgWXF/oDmXYQhtnEpo2Eq73NFQRA7WNi5iIKIWb+CPQWUg2XGyx GOa4/qI+F7FTRLsIz5+ckqS58Wx44gIWdt5fjyXo5SQsivi7vJtaRyt+LujF72oIoh7W eoWN3Tj9Nej/6Ac8nVe4CW6xbyfn66VtrOJutUp2q9mzUe9FoJ9ChFb+eeUBu3MIdASo +aVyaWNDxPAkrbQbWpfKuWx9C830o1L4AzX0lppvxWQrY0j933ZuzPY7/jY0pkDkFomR eHeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=v2yJA9+x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id u11-20020a170902e80b00b001bdc9c55295si11647581plg.593.2023.09.19.20.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 20:41:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=v2yJA9+x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 2B3A282A9BB5; Tue, 19 Sep 2023 12:03:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233134AbjISTCz (ORCPT + 26 others); Tue, 19 Sep 2023 15:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232838AbjISTCh (ORCPT ); Tue, 19 Sep 2023 15:02:37 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37A2EF3 for ; Tue, 19 Sep 2023 12:02:29 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-cf4cb742715so6610296276.2 for ; Tue, 19 Sep 2023 12:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150148; x=1695754948; 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=dATpzHjDHVSfxWhEgldjVmKuWzgWmKZlkhKuoIGibHA=; b=v2yJA9+xEArPA/74JMN0Hi694q+EDFyndB9ppvzcYvjeQ6RKM3MPV8k+s3kMjmOub6 8yQVjUtjnXSs4iiDS9jPgMtzYzoebk/scqukPobKHzl1J1/TAzCr70z/wmdE8Z8cNY8G 9LRGxHoUwdhVkJCEHtFfjcnDzLYg7MfFe9wiBDDOFrgafP30KwSNmyUbXxC2+7/cP1dg FVnin8rmElasfww5o03MI48xmZGPAo3TCOyUZnllrktI1WCO9YhVpfkeguMIpRx+PjHu r2g8s4stxr2TPEb28XzFYHoBfTx1Ikj20B80pj89tmzaLc2WhD1FH6apIb36AWYBe7+6 tTag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150148; x=1695754948; 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=dATpzHjDHVSfxWhEgldjVmKuWzgWmKZlkhKuoIGibHA=; b=Ht6Ac8vixi0wBGSieOkhXZLutLj+Sb1l0ZWQhCirtvofzo9YLFZ/P+/pFUwCApCGEW Ydx/X+VwaSpi46d03h4G4zfmGfx5uS4U7z7P6FE8ZrT5kD7O4LAaSBKstwBZKZq/BEXh HJcbp/akFa69k0nj3EGB1dlULKWA86WCBe3CzNqTMjHhSQCwbVF4XrULPfvDUHWqfVqK m+tMVUjEBPqPYH0YdxhCqzVv68Gf4Ta1bZYzHJTcmOJCpJp1z7GXmlQzjQXG1ME3ya0V XLqp4eNy9+IsWWkDvzR6TFdvtbzsgEmvyQGmkV6ImStJUjLnbQo0nfdIOMB2nxbzuyyf epmA== X-Gm-Message-State: AOJu0Yxqp1B8eLoKxkmLxNHft3Q/xFv5I+qXicRb39KkFqxm25NQZDzf uKMWr9UVvCQ1SLGwMNB6VRBhMNQm/ZoUgGqxVFi3 X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:1802:b0:d77:8641:670c with SMTP id cf2-20020a056902180200b00d778641670cmr8426ybb.10.1695150147917; Tue, 19 Sep 2023 12:02:27 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:03 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-8-axelrasmussen@google.com> Subject: [PATCH 07/10] ioctl_userfaultfd.2: correct and update UFFDIO_API ioctl error codes 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:03:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777526438445921285 X-GMAIL-MSGID: 1777526438445921285 First, it is not correct that repeated UFFDIO_API calls result in EINVAL. This is true *if both calls enable features*, but in the case where we're doing a two-step feature detection handshake, the kernel explicitly expects 2 calls (one with no features set). So, correct this description. Then, some new error cases have been added to the kernel recently, and the man page wasn't updated to note these. So, add in descriptions of these new error cases. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/ioctl_userfaultfd.2 | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index 53b1f473f..1aa9654be 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -280,17 +280,31 @@ refers to an address that is outside the calling process's accessible address space. .TP .B EINVAL -The userfaultfd has already been enabled by a previous -.B UFFDIO_API -operation. -.TP -.B EINVAL The API version requested in the .I api field is not supported by this kernel, or the .I features field passed to the kernel includes feature bits that are not supported by the current kernel version. +.TP +.B EPERM +The +.B UFFD_FEATURE_EVENT_FORK +feature was enabled, +but the calling process doesn't have the +.B CAP_SYS_PTRACE +capability. +.TP +.B EINVAL +A previous +.B UFFDIO_API +call already enabled one or more features for this userfaultfd. +Calling +.B UFFDIO_API +twice, +the first time with no features set, +is explicitly allowed +as per the two-step feature detection handshake. .\" FIXME In the above error case, the returned 'uffdio_api' structure is .\" zeroed out. Why is this done? This should be explained in the manual page. .\" From patchwork Tue Sep 19 19:02:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3830825vqi; Tue, 19 Sep 2023 19:45:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHij290v+vm+f7azBQZYYofFyMon+CuYmwSis9HVAM2C1YWh0qdeoyP2CJpYVQQq85wKUax X-Received: by 2002:a05:6358:5915:b0:142:ecad:c6e with SMTP id g21-20020a056358591500b00142ecad0c6emr1679675rwf.2.1695177914736; Tue, 19 Sep 2023 19:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695177914; cv=none; d=google.com; s=arc-20160816; b=0thwgVcYt3Okry3m7nfPduof8GIBk+EmNFDZnODYcDksfzyAy/HKkuMH3BSQtXSoXa T/huRaf1HxqeLEusFyTgKFW1pJ76aN+p2G7iJ8Hz9hj2TqTL9iFRtGuPfcvdfU0IebKf J34Vn3YQF8SuBGUKE/coZ0yZspzX3b0R7LS1nA/ZinRdMbbwHxzoIqGMzleMSFOzqCYx hglEL4AD9Iix/4Ifzwx0DRLpjsaxH90T9i0KOlWSaG48C4uzlQ0ESHICrscAFlxNNS1T v7DHUO0ewvxslca9pQfUf2EPq8vEgG+bSfImo+dlugaJ8UO517wGL7EOaCu6ICm9oogG Tr6g== 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=5/ZA4nlbby3TSOXQeGLhY3RgtFATqmihyuOhsYNku5o=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=cn1WfYvSO7bWQiRbdbz1aBdvY52SKtVFMQEtwYzP999XqgdGLO9uOYkxJ14o3XwP/l ltLWtQQoDkAr4mRg1xH4jcqiC0CuXnyrZ+NJDA9iSNw7TakLp0fLsttm7GxR0lcwNxEi GjnGlkY0DQ7m7LTbZZbebI0yGmzunfB9qwAUsa6cNlwUZUuGs1TmIwccoNUV8Zye4LNc CYAcfjDveyN0j6x7frJifyJeGVE4jKmWeLWk2HAmuxmbDwuX+BXn5fxfz3Uogm5tjECC gS7cAfGnY+e7lzAHF6zGsyaMJVGRjpf3MHhdtpD2n1bcAWuricYHN3yYlPM9CSboRJ+o xi4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ILqI7TNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id 22-20020a631756000000b00578b379922bsi2281072pgx.511.2023.09.19.19.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 19:45:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ILqI7TNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 4E633830148A; Tue, 19 Sep 2023 12:03:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232838AbjISTC6 (ORCPT + 26 others); Tue, 19 Sep 2023 15:02:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232714AbjISTCm (ORCPT ); Tue, 19 Sep 2023 15:02:42 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B959F9 for ; Tue, 19 Sep 2023 12:02:30 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d81841ef79bso6655200276.1 for ; Tue, 19 Sep 2023 12:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150149; x=1695754949; 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=5/ZA4nlbby3TSOXQeGLhY3RgtFATqmihyuOhsYNku5o=; b=ILqI7TNmSI3xoxz6Gb20TjikkOWe6V6TnyOB+d+IrFUhwShOf/Y+3+hjouGb4yRK6a 9uau1Ssjg3ISDR5w7vf2UkokaTzpPODfmFKHPeYF0NPSSqZFAqrZabPA/kRmi8surMqj 0jMTJ25dmpM4S+KzZqtwpGU3denfpfu0lG2ZVWROcE/HLPxQz8i80/z/UJFDCu0BydfH u1cey1gNaV6ZxysgKb+nOL0WbVLlzFjuYmIxuZm0/pVc1Sfz9t8x28sckj8bhB7MBTBP cZp0NIs+Gt1WzZzgW/67hGlFY8Xyju94ZXUcI5nExbLWXALfmArb8rESdhaSgGTSDYrR IFXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150149; x=1695754949; 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=5/ZA4nlbby3TSOXQeGLhY3RgtFATqmihyuOhsYNku5o=; b=hOTLvx4YlfuTw4jMo8yi2Z0jiu5EwBV5kZYq6KF8i+g7uqTfY7AeLp0eW9PcxywVQv e3e1s73kdKx5te6/Lex/wnWILtXN8YjIyMDZr2cIxshlQYjxov4YPtP7A4cDlSnsunsH c0GN4sPu70yfWlT1HdXP7mKKR/2kyD8Ou50b5wfDGoCf0wzK2Kqx6EAngXj2jWNAKDBl W9Os5vW+wni2PJN+ejU1hQJKnsVCZZD8KnvpcuyaL2kg8dOEDlVXn9m/2z1luQyvGxBX z8Ukx+V1uIcNgtZSHFtOZOxxHX4KnxbvGrwT5Jvv+d/wV1YMVgIy+Uz/bna4GwHNf5SJ HVkA== X-Gm-Message-State: AOJu0Ywdqe8d46wjiguzYAIQWxZZlkzs9qf6sy9JYt3FdHQxw+Ss76HA 2ytO1GLPrQp1fYLhaKZr0o90oaMnijZwhg2FXD6o X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:1805:b0:d77:f7c3:37db with SMTP id cf5-20020a056902180500b00d77f7c337dbmr7876ybb.8.1695150149582; Tue, 19 Sep 2023 12:02:29 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:04 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-9-axelrasmussen@google.com> Subject: [PATCH 08/10] ioctl_userfaultfd.2: clarify the state of the uffdio_api structure on error 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:03:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777522877012270003 X-GMAIL-MSGID: 1777522877012270003 The old FIXME noted that the zeroing was done to differentiate the two EINVAL cases. It's possible something like this was true historically, but in current Linux we zero it in *both* EINVAL cases, so this is at least no longer true. After reading the code, I can't determine any clear reason why we zero it in some cases but not in others. So, some simple advice we can give userspace is: if an error occurs, treat the contents of the structure as unspecified. Just re-initialize it before retrying UFFDIO_API again. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/ioctl_userfaultfd.2 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index 1aa9654be..29dca1f6b 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -272,6 +272,14 @@ operation returns 0 on success. On error, \-1 is returned and .I errno is set to indicate the error. +If an error occurs, +the kernel may zero the provided +.I uffdio_api +structure. +The caller should treat its contents as unspecified, +and reinitialize it before re-attempting another +.B UFFDIO_API +call. Possible errors include: .TP .B EFAULT @@ -305,14 +313,6 @@ twice, the first time with no features set, is explicitly allowed as per the two-step feature detection handshake. -.\" FIXME In the above error case, the returned 'uffdio_api' structure is -.\" zeroed out. Why is this done? This should be explained in the manual page. -.\" -.\" Mike Rapoport: -.\" In my understanding the uffdio_api -.\" structure is zeroed to allow the caller -.\" to distinguish the reasons for -EINVAL. -.\" .SS UFFDIO_REGISTER (Since Linux 4.3.) Register a memory address range with the userfaultfd object. From patchwork Tue Sep 19 19:02:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142069 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3637019vqi; Tue, 19 Sep 2023 12:41:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGoGbnERmxr+4oc899Aws0Dy2/adGzCd5Gn5yObgg4f5fsW5G47gE44NN2Lweee8SYtzVxi X-Received: by 2002:a17:902:f68b:b0:1bf:13a7:d3ef with SMTP id l11-20020a170902f68b00b001bf13a7d3efmr333120plg.66.1695152473811; Tue, 19 Sep 2023 12:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695152473; cv=none; d=google.com; s=arc-20160816; b=USOaqwDZlUaQv/XmyZpnFi95DhUiAE1Q7Btozrz/qfs7S4PYLPsp5T3lZcwNgmNAxK wjvkHBXSwmZKWWC8blYfwco1kW/es6YKzXAIVaXD32AqLQRjKFrLJnkaeOSBY1fA7gzV TrIXWWTBf/H7IgfVeSuaIuF4AlQoy5HuaphEDdykNrD7VxSx8jiODTygShxlkL6GPcWe exQY9xtyGN9djC/oaGuf34PQvjgpoW2sCqTQrC7+5e84204eNKBZGLO/JWYFxl23WG77 KXB+8vlH3QWtTbGoZhX1s44s2y2LHjZBraJYVGQBpdnwPWpfnZeNO1HyveGjPopZVRVO Z14g== 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=B/mBNxS046NndSUiuzLhVh8+as48kp1msWTNOB3shRo=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=q7PkxAzWxTYQ7tKLVTCDzGSH9D/jB2AfNgBpXzLK9Q3IZ9gt8ZQmFOqjhNueXJtTnN l+VZk3T4LD+Er7DhOM2wvNx4VjDYoe7SueqmzdJhh0lN7RnujirqUddFaV0cQVxN8LRd YPYw6/9ElCO5x8vh4eB0XCB+n0toylAgxDh8r8lIa0bPGRCW8iIZxHSDco3SQfhriuZ8 rrF9Ti0mwj0tcjB4JVF4D/XBlHrh9VJmbZ4V7zgg8PwTpGW8m6UTHKPoq8/dgOJcR4R9 gSPGNmdsNVfVPbSsC+7NSMfRh4Nz6gnV7YB+oIu5nWzwk//wNCsltkZH4wrW75ut9Vi0 bW5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ua8QGL2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q15-20020a17090311cf00b001b02e044c87si10552769plh.320.2023.09.19.12.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 12:41:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ua8QGL2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 15C8E820C361; Tue, 19 Sep 2023 12:03:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233165AbjISTDC (ORCPT + 26 others); Tue, 19 Sep 2023 15:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232706AbjISTCt (ORCPT ); Tue, 19 Sep 2023 15:02:49 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F34221A6 for ; Tue, 19 Sep 2023 12:02:32 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59e758d6236so36987027b3.1 for ; Tue, 19 Sep 2023 12:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150151; x=1695754951; 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=B/mBNxS046NndSUiuzLhVh8+as48kp1msWTNOB3shRo=; b=Ua8QGL2++mD9dEdg+sAx/FcJHqAsM5UhJQ3xLWs1T3+FEAbdPlQBBbZiTzJZPtRJcj zEo2awLPU7Rl3GJYMA/0fCdInO64l3hdcByzrVvS9DfW/6sZ41Ny/1Z2A2KCr5xGXn26 sPcH9s9TSoeqDyh6IrLOhngvAGHRM9dC3yZ9VbblH0ueTgc4oUxhkNvOYZdwfBPUSaKL wqG3vLEVq+rqRbN+jo1/6jTBdkNAGXOr8XidYggPftdGrLmDdCXpTgn3G2GHZ+p7bSxW 8mvRjrXS9Na7HQdrpOlKEyskvUrCScfa0mscy4cxzVDEcv3tsD0FfD/7b/ZNiUm6xKKY X6hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150151; x=1695754951; 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=B/mBNxS046NndSUiuzLhVh8+as48kp1msWTNOB3shRo=; b=gHiQwUwatWM8vANfFjCnulNze7UIeiRsMj8VlDbQkOBAF5sgAPJ0DmscQf8S1KAsk4 J5tdH8xMvsKUUIpbv1PD4k/WYQvsx0qOusF0r9qtOehy8zL5h4THx6XM+MRzUltH220+ bKYF/dFLeugaShNjBJkNGx1ROUs2LZSmdiBor6TTKa9bmwhIJyaWPmfMbD2HgfVzUEvH wFPHus2bRBdYEtaoJZG5WfOhQEXi5PcSwW8U8sBTApFN7u5rjonsvtgH+fkpL436wMKr 6ZUwl199v1JCARexlYXcTQ6ZcrvF6/M/8jXs5JyIGj1Ct5QIbUS8rpTIi0ke7pXubqf2 2wGg== X-Gm-Message-State: AOJu0YwGwvgfBvH39+jpKrzLiySY7gpfswEe/DzSKUMF/PSlhcGp/K8h w/akMUWAl/oFc5We4OLDvH71lwqtkz7kercP4vU/ X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a81:ae07:0:b0:59b:ba8a:97d0 with SMTP id m7-20020a81ae07000000b0059bba8a97d0mr6086ywh.3.1695150151389; Tue, 19 Sep 2023 12:02:31 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:05 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-10-axelrasmussen@google.com> Subject: [PATCH 09/10] ioctl_userfaultfd.2: fix / update UFFDIO_REGISTER error code list 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:03:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777496200391526655 X-GMAIL-MSGID: 1777496200391526655 The list of error codes in the man page was out of date with respect to the current state of the kernel. Some errors were partially / incorrectly described. Update the error code listing, so it matches the current state of the kernel, and correctly describes all the errors. 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 29dca1f6b..afe3caffc 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -413,12 +413,6 @@ On error, \-1 is returned and .I errno is set to indicate the error. Possible errors include: -.\" FIXME Is the following error list correct? -.\" -.TP -.B EBUSY -A mapping in the specified range is registered with another -userfaultfd object. .TP .B EFAULT .I argp @@ -433,21 +427,32 @@ field; or the field was zero. .TP .B EINVAL -There is no mapping in the specified address range. -.TP -.B EINVAL +The specified address range was invalid. +More specifically, +no mapping exists in the given range, +or the mapping that exists there is invalid +(e.g. unsupported type of memory), +or the range values ( .I range.start or .I range.len -is not a multiple of the system page size; or, +) are not multiples of the relevant page size, +or .I range.len -is zero; or these fields are otherwise invalid. +is zero. .TP -.B EINVAL -There as an incompatible mapping in the specified address range. -.\" Mike Rapoport: -.\" ENOMEM if the process is exiting and the -.\" mm_struct has gone by the time userfault grabs it. +.B ENOMEM +The process is exiting, +and its address space has already been torn down +when userfaultfd attempts to reference it. +.TP +.B EPERM +The userfaultfd would allow writing to a file backing the mapping, +but the calling process lacks such write permissions. +.TP +.B EBUSY +A mapping in the specified range is registered with another +userfaultfd object. .SS UFFDIO_UNREGISTER (Since Linux 4.3.) Unregister a memory address range from userfaultfd. From patchwork Tue Sep 19 19:02:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 142195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3847300vqi; Tue, 19 Sep 2023 20:28:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXvdyY/WIXRrWJky1uqXyBtacgKr8ZTalHcPcHdhNg35Fp4YoaTosyCInw7zyi/FiTH7Kw X-Received: by 2002:a05:620a:63c9:b0:773:d99a:49e9 with SMTP id pw9-20020a05620a63c900b00773d99a49e9mr1229153qkn.66.1695180517828; Tue, 19 Sep 2023 20:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695180517; cv=none; d=google.com; s=arc-20160816; b=H2+iMwmU/71zMAuBZlujvqP/x7qRKd4j7DDyabQB8MNrtmy/CsevaXnjt5Sq/yhTyd 13jfnSbrMLbgzRUL84KetQ4O1AfERqL2zojtOCKeODWvvo5ID2+FLp20MH66Xe9uElWY //oS1kmmGxdMb83skH+k+T0hw+phWTMipjD/USYGRFhKPLkumAAukCYWNT1+cRBd+Uy4 NoFgoZ68RsYhJ6OhGmKn3TetREk2G4goNx2pwTCnml9MDvhxLOPRvk1caehr/36AaWF+ 47/XiURtWKqZFyra5yRGyDuAjz1Z5C6gMNElvDXHyHItgKPv+Pmi4X3m7k6+sU/lucLa invg== 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=eY7SX8EsQtNfNMnrsSEHLyVvDJFOwMWgHyNV+Npddic=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=jrtpFJNy0tF+qPkuoyXtDmTzwTZVqXHTu9ipO2WZ7+9Uh/ZKG+dMgzsN5FRtUqqskf kvGb9X66TCWvVNA/Cij+UpIdYsIUwv5qr00ZVG/Ub8oW2rAGQsL1nq5Th80q4mGYnHtc 59HncjnC7HrxNji7oq5popDG/ilTpdGsXHIgNeQlkSpbOzZ7xc7kziXHkk3SDpwfW2wJ QNa+rMGJCpMRP2VicfYalhzKGHQvH0iGRwaBXyd1M6k6z0QrDBmOEDsfAby+Fr4yz5AR 4T+8YD9/Fln0g77I3KpCX4azz4XOHCPRutrdnpiFW3KfArAnKAzUAjGjnVLoU7gQ6DxB ZTzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GpGgJfdz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id n3-20020a6546c3000000b00563a0bacbb4si2718782pgr.694.2023.09.19.20.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 20:28:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GpGgJfdz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 42F56820C364; Tue, 19 Sep 2023 12:03:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232804AbjISTDK (ORCPT + 26 others); Tue, 19 Sep 2023 15:03:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232960AbjISTCu (ORCPT ); Tue, 19 Sep 2023 15:02:50 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 197811B3 for ; Tue, 19 Sep 2023 12:02:34 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59beb3a8291so75108207b3.1 for ; Tue, 19 Sep 2023 12:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150153; x=1695754953; 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=eY7SX8EsQtNfNMnrsSEHLyVvDJFOwMWgHyNV+Npddic=; b=GpGgJfdziP0T/pNiXVddEP1K/Ux6EdfOFFB79TdlY1L/ZPC2HhgE4xXyrs3h+BMGpX R1E5QoGjEV/KNuQWUFzEjJR1zuyGllv2a6b7Np+8gZYBzT61hgjOl6rBGGsmNZhSy7SE g5A5iti4sDDv6txnntWC7uYID6S7DhAW5bibedJI3jEgNBE99/yY3S597orD1ltXdsZu U3ZGxUFHcHeUhm2VRaP1rUw7dW/vSgPEf2YFJoNFYMjSSikWO4o0uoF2tZyaCis0Wxcx TlSYZvQKLO7ucSSfkCrhBS2qfheOcKmTeOdYt8NBTsLGQmo9jM0FVoJJv0Y2azgb11ba UJ/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150153; x=1695754953; 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=eY7SX8EsQtNfNMnrsSEHLyVvDJFOwMWgHyNV+Npddic=; b=akFOlgfL3tnQUeN/vhtW8Eq76VI57Ruy/lmC//QIm551woiCZfGu44Ju2l2PqmuExN fUziHmYqybrp81SdXrmur7bkAn7ZbW7asj4lUdHSw2/Og5dSDPPMGzByhQx0VAYCGw7i n5YF5PnchoNynrrS+ISy/410xi380cklCP4Yab18KbvoC1Do1U6VYSHHb22/ydWs3wiy 4b61WyoZZOyagp83m1ScOjeU6fGExfeupjJYxx9ZFnMcQwQTx6W7HAKnFnaH1Q1rjnD0 NaZHOlJhTP1RjXUwpHx9w689abe6IolHClUsUBpK9lCmn9tWhcFI7sDwdPc+9lr/wVQI /yvw== X-Gm-Message-State: AOJu0Yytn+6rnbn4MsH5bX058SKv6dhO2LEXQoRq2XXIkiYYXti5AthA SaZSSj/tzZMKcmQvgozJ9bi2yB4QdM5/p1VrK6mZ X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a81:ae57:0:b0:59b:ee27:bbe9 with SMTP id g23-20020a81ae57000000b0059bee27bbe9mr5207ywk.9.1695150153232; Tue, 19 Sep 2023 12:02:33 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:06 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-11-axelrasmussen@google.com> Subject: [PATCH 10/10] ioctl_userfaultfd.2: document new UFFDIO_POISON ioctl 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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:03:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777525606613584932 X-GMAIL-MSGID: 1777525606613584932 This is a new feature recently added to the kernel. So, document the new ioctl the same way we do other UFFDIO_* ioctls. Also note the corresponding new ioctl flag we can return in reponse to a UFFDIO_REGISTER call. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/ioctl_userfaultfd.2 | 112 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index afe3caffc..1282f63e1 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -405,6 +405,11 @@ operation is supported. The .B UFFDIO_CONTINUE operation is supported. +.TP +.B 1 << _UFFDIO_POISON +The +.B UFFDIO_POISON +operation is supported. .PP This .BR ioctl (2) @@ -916,6 +921,113 @@ The faulting process has exited at the time of a .B UFFDIO_CONTINUE operation. .\" +.SS UFFDIO_POISON +(Since Linux 6.6.) +Mark an address range as "poisoned". +Future accesses to these addresses will raise a +.B SIGBUS +signal. +Unlike +.B MADV_HWPOISON +this works by installing page table entries, +rather than "really" poisoning the underlying physical pages. +This means it only affects this particular address space. +.PP +The +.I argp +argument is a pointer to a +.I uffdio_continue +structure as shown below: +.PP +.in +4n +.EX +struct uffdio_poison { + struct uffdio_range range; + /* Range to install poison PTE markers in */ + __u64 mode; /* Flags controlling the behavior of poison */ + __s64 updated; /* Number of bytes poisoned, or negated error */ +}; +.EE +.in +.PP +The following value may be bitwise ORed in +.I mode +to change the behavior of the +.B UFFDIO_POISON +operation: +.TP +.B UFFDIO_POISON_MODE_DONTWAKE +Do not wake up the thread that waits for page-fault resolution. +.PP +The +.I updated +field is used by the kernel +to return the number of bytes that were actually poisoned, +or an error in the same manner as +.BR UFFDIO_COPY . +If the value returned in the +.I updated +field doesn't match the value that was specified in +.IR range.len , +the operation fails with the error +.BR EAGAIN . +The +.I updated +field is output-only; +it is not read by the +.B UFFDIO_POISON +operation. +.PP +This +.BR ioctl (2) +operation returns 0 on success. +In this case, +the entire area was poisoned. +On error, \-1 is returned and +.I errno +is set to indicate the error. +Possible errors include: +.TP +.B EAGAIN +The number of bytes mapped +(i.e., the value returned in the +.I updated +field) +does not equal the value that was specified in the +.I range.len +field. +.TP +.B EINVAL +Either +.I range.start +or +.I range.len +was not a multiple of the system page size; or +.I range.len +was zero; or the range specified was invalid. +.TP +.B EINVAL +An invalid bit was specified in the +.I mode +field. +.TP +.B EEXIST +One or more pages were already mapped in the given range. +.TP +.B ENOENT +The faulting process has changed its virtual memory layout simultaneously with +an outstanding +.B UFFDIO_POISON +operation. +.TP +.B ENOMEM +Allocating memory for page table entries failed. +.TP +.B ESRCH +The faulting process has exited at the time of a +.B UFFDIO_POISON +operation. +.\" .SH RETURN VALUE See descriptions of the individual operations, above. .SH ERRORS