Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3466138rdg; Tue, 17 Oct 2023 16:20:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuIJ6MAxUfxmF9Eo3Qo1Dwt8aRTNA9aPfu6FU8oy8SM34FiIb0tfugTONyyVLwXaiSadMY X-Received: by 2002:a05:6870:12d6:b0:1d7:876:c825 with SMTP id 22-20020a05687012d600b001d70876c825mr4022524oam.48.1697584845249; Tue, 17 Oct 2023 16:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697584845; cv=none; d=google.com; s=arc-20160816; b=XxKHEsISmfPWDSwZy50wPeWpxXlgcWuEGjDcFgRcY45Aa7ZmSMm7QB7ldTVTmZuQqh ZDfcn/SF7/aATnpTmw0ahRUm2BIeR41oJqaNjb5+y/E4Mwr+t5IkTDd4Kxsy3Is6X5VO oKUX3dG98gZkATpo2WyroXCrZ617vCTclBpe62G9sFRItF3AZrY2OXVOIsn19A95Nr50 eeRB4Cr1PSnyDziisCH5ybpeb1asM7rf89IPR9a17sAdbCbdy0XQWn+RPXrk+xc3J/Yo 28f2pbMpDhl4lt/ho49v1xcMOeSyGpfo7IyGv6qrO4rLBCEtfVQBSrx+vuQ0icuDKla/ SrZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4JgbUHMbAaHzwgmc4IiZLmSdhEVIDt8ysuXAzFN0fXU=; fh=OxNTFWLvleFI0MvhCKNAD6iL+6/Ozgzt5PlGMZDxH8o=; b=vz8xypej4Ftoqws/AylWjSHeDG4I41lJ8OQ9gRhS05/g3YJVo6ZwhoAYblILTtF4Qy HTW2ht/3N1IZvjPthjSYyq+eCETylipGRxNEbJ1kKDKpqEwMeg4z83Alru/BDz9YKodA cOUkLTcOMu/QPlifUxGsM5wDaHmt4MG7bAE6LyOvdmTw1OSM+QgNrpUVT2JVg8ZeHhpu FQd0s0YxXv2w/QosH6C2bSko/QLeKR4LIpy0wTFySxZK30I/NqLogmAHm7r05ts4BtE5 nkkyIztBsYa8/3vJW7dzO1mwRwOUxOPBaBaKWaGVmWGVd75gugF0q3lHaEcHdy6x6C/p 8gQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YSOouqGC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k11-20020a637b4b000000b005b7180bc067si862538pgn.17.2023.10.17.16.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 16:20:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YSOouqGC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D193580FC180; Tue, 17 Oct 2023 16:20:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344122AbjJQXUY (ORCPT + 99 others); Tue, 17 Oct 2023 19:20:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234836AbjJQXUX (ORCPT ); Tue, 17 Oct 2023 19:20:23 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC8D7F5; Tue, 17 Oct 2023 16:20:20 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21BF3C433C8; Tue, 17 Oct 2023 23:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697584820; bh=wNpEvk0qKh6nYz+ayWMmRr37IWRnGddjjXUD6ljHCLY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YSOouqGCnsYyQxPfXlyoccKal7pbNwsPT/wKZjjn7dOKycpjuKEPlv6vMBJVGi1+f gVdCvKXQbo22jDLeI4yt6j2Qj4dP0G2SWWZ9i3bpasM3igb4DYBfHwzMrR4OEmNLfb jgE1cG4Z8o9x1drp1mAN7/Kp7ClrwJGDUc9RdxvCEJNlH/S2FkNwEv1Y39otFMHH1d W3Q8eZHoZJmmIqa8yNRBodzAXAGMDmdNZTf/vBVGsPUlHm26Oyxp3QZwVzDZmRLRnk kBB14c0qSGbM+m9whuuLileWR7GYnr7aQAdkWydJGTbaYVkVxszYeyJZETch2Rccri zCBoKQAL7jnmg== Date: Wed, 18 Oct 2023 01:20:16 +0200 From: Alejandro Colomar To: Axel Rasmussen Cc: Mike Rapoport , Peter Xu , linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] ioctl_userfaultfd.2: document new UFFDIO_POISON ioctl Message-ID: References: <20231017230110.3170850-1-axelrasmussen@google.com> <20231017230110.3170850-4-axelrasmussen@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gcjukqSUCbN9YfrY" Content-Disposition: inline In-Reply-To: <20231017230110.3170850-4-axelrasmussen@google.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Tue, 17 Oct 2023 16:20:42 -0700 (PDT) --gcjukqSUCbN9YfrY Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Wed, 18 Oct 2023 01:20:16 +0200 From: Alejandro Colomar To: Axel Rasmussen Cc: Mike Rapoport , Peter Xu , linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] ioctl_userfaultfd.2: document new UFFDIO_POISON ioctl On Tue, Oct 17, 2023 at 04:01:10PM -0700, Axel Rasmussen wrote: > This is a new feature recently added to the kernel. So, document the new > ioctl the same way we do other UFFDIO_* ioctls. >=20 > Also note the corresponding new ioctl flag we can return in response to > a UFFDIO_REGISTER call. >=20 > Reviewed-by: Mike Rapoport (IBM) > Signed-off-by: Axel Rasmussen Thanks for the patch and the review. Patch applied. Cheers, Alex > --- > man2/ioctl_userfaultfd.2 | 124 +++++++++++++++++++++++++++++++++++++-- > 1 file changed, 118 insertions(+), 6 deletions(-) >=20 > diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 > index 40528001e..a9131515c 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) > @@ -886,6 +891,12 @@ does not equal the value that was specified in the > .I range.len > field. > .TP > +.B EEXIST > +One or more pages were already mapped in the given range. > +.TP > +.B EFAULT > +No existing page could be found in the page cache for the given range. > +.TP > .B EINVAL > Either > .I range.start > @@ -900,9 +911,6 @@ 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 simultaneousl= y with > an outstanding > @@ -912,14 +920,118 @@ operation. > .B ENOMEM > Allocating memory needed to setup the page table mappings failed. > .TP > -.B EFAULT > -No existing page could be found in the page cache for the given range. > -.TP > .B ESRCH > 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_poison > +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 simultaneousl= y 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 > --=20 > 2.42.0.655.g421f12c284-goog >=20 --=20 --gcjukqSUCbN9YfrY Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmUvFrAACgkQnowa+77/ 2zLLSA//QJlLtyVG1VE2REu9OjkUgvej/adUPeZPOMBXUgGn4yCw2aaWA9vCcFAK O0eC90Ju2qDw92q6vvVO7SVfuv9K28bM5rBLuD1Sku0uPArDeLsW940ujPmDAP6L i5sXGv6iHqOK9nSC2xHELw15O9Gjds1hoaspujYqPI95FQ3lOkLUdz6c5TGqfh8H VGVOR6/Pujcv1SaYWmqZtmhzBUAUea4TzEUi9ztpUe3AZTwXQlohhvB0dG364JJ3 H/sHlsKmXfQC8wdUoOzONY7npVr/vjIushM/rFiWAYJkNdau1PlXy2lOonHrze7z 819Qq3wSKdgYiuLCmMqgMDb3eCLmaEp8JbH9Gl5o4RBwcoss31JTiapYOLx7gHg3 Gbq4u9nJc6KHM6X/ELNVVh89Z2vTkWEWbKgrfO2e6Ku80oim4uy/wVse6ZCbJXk7 zxTtiLrGXhmGNyJK4oYHzGJRCxvKhFdTBhFGFdEWQtFGNxqynmXFxTaguKKpKg4h OdDp81U6FIm3tBMGvlUttWTqAjawysrV6NnsFiEsSW0SNOD03lVELryP3X6/pn5x X/TaT/ZQ2Z0OQiYFrJMr1d3m1h7lbBMhZJCBIFGwDckp92N/eJPkphg16izefv+T RGVWa0Oj2b/5IEfO8DCGxeXmaXNmhqf6qWNYppC4GBP8tbAxaQg= =bNM8 -----END PGP SIGNATURE----- --gcjukqSUCbN9YfrY--