From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A09C1CDB474 for ; Tue, 17 Oct 2023 22:26:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2052A8D0013; Tue, 17 Oct 2023 18:26:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B5438D0005; Tue, 17 Oct 2023 18:26:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 055B88D0013; Tue, 17 Oct 2023 18:26:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E918E8D0005 for ; Tue, 17 Oct 2023 18:26:15 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C43471A0F29 for ; Tue, 17 Oct 2023 22:26:15 +0000 (UTC) X-FDA: 81356387910.09.1436CC7 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf19.hostedemail.com (Postfix) with ESMTP id 0A7911A0016 for ; Tue, 17 Oct 2023 22:26:13 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=AaJmw6ys; spf=pass (imf19.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=axelrasmussen@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697581574; a=rsa-sha256; cv=none; b=j5DwSFH2EYMlelskGc89FgQJhBi/XhqctBW9nZeku1zdOPB6p6f9NO8g5OBrwf9ElM7qko J47wGpDtq+l2hp+iIwSYuTachdTXyvFt1oACSKhmkQxy5xb4iMEwAlZYyqN0Kwti6OVQiO nkgGwdePa8BcT0NDziLqWR+CdOLjdjo= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=AaJmw6ys; spf=pass (imf19.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=axelrasmussen@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697581574; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Cp96MNyT4CvGx8BgoCKI8MBtXKv0iatQDCMkj4fahr4=; b=Pu8vGTbxE1DIkzea2lvMSry+vns+AeUmmRfBgDA2dvogtfta2rT7XVw/IOo8SxuPAL4ANi tnD3PI4blonux+bGxIH45EvI4Ev6bwwkzC/b0KM5G3j+T+ISVV3G+Es4ue6avGMeT6eENv heOIqii5Vv/u7CdE5QvwRQhgRqCm66E= Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-9bda758748eso711985666b.2 for ; Tue, 17 Oct 2023 15:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697581572; x=1698186372; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Cp96MNyT4CvGx8BgoCKI8MBtXKv0iatQDCMkj4fahr4=; b=AaJmw6ysG5xRerUD5jNxbP+qFvVGLGtv1AIEhCt2Ke1av/IPV8WLA/BGPowOriLMF7 v3exXkRzUKX1Cc4syAQswusbVN0Ji3aPxGGgKnozwYDJhQYTWZPr1daNXp1/xzELDtt7 6y6lBsdw8zxXhs2WUFL9zk/mpggd8OdiCngrAOIUHiM1aqJHqJBmLiPT0dp+ohd0yQCZ wU1502fwvfigqV4JdtD/2REscawha6lm5VMMz45fv7vjosSN/R/P25MsWGllEylAlXAe eHUngUyXllq+nGHAHxqZKwjN/qCQkaEtMQgIQPdCsgBw+vegdoQUBVdcwUdGT415lLSC UoFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697581572; x=1698186372; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cp96MNyT4CvGx8BgoCKI8MBtXKv0iatQDCMkj4fahr4=; b=TM7rAmrESmaDwhgLb72XKmmmCFW0VAYD66GTGIyhmE5AXSTl+OB7IwBjFszJrgwU/Z bVyODRvVIU491m77JP+mPhdupe5kT742UZURXm7K6cvuQXJ0QLgjbsSbm8Jxxr6qC9r5 2ileUl71PtPDRj+I7mKhgYRY5RRYKOVbol8iK3Ks7rMsC8SGzw92mwe3BJ5vl1mi6LLP hgofdgAIlX5uHM7r+xIEx/2ZJi6UWZJ1ynB7ykH9OGP/kWP5DYbtw/7Ad9mYUDrZH+OL Y5wbyS+kL9E0QKi96LUB7GgmKc0d2ITcgXNjWD8XdfBojqma/ctCzuZp0U0fwulv6NUf 17tA== X-Gm-Message-State: AOJu0YykLufGvu9Wg84hyE38IX4UJvbEQggJz1s0nKaFOzJVMFx7/NZe GVCsbud9G7zS17VjJrQhdf1k82t8/X18+l/ygOgNxw== X-Google-Smtp-Source: AGHT+IHxsN+TQx6uE7iRVzZOAHEvWw5QYqXOgJqCk9dwzbCPQxD5DPQ90BNQqJihFCe+pa/1nlHu4axwP3EZDYkr+4w= X-Received: by 2002:a17:907:84b:b0:9ad:ef31:6efc with SMTP id ww11-20020a170907084b00b009adef316efcmr2650933ejb.21.1697581572248; Tue, 17 Oct 2023 15:26:12 -0700 (PDT) MIME-Version: 1.0 References: <20231003194547.2237424-1-axelrasmussen@google.com> <20231003194547.2237424-6-axelrasmussen@google.com> In-Reply-To: From: Axel Rasmussen Date: Tue, 17 Oct 2023 15:25:36 -0700 Message-ID: Subject: Re: [PATCH v2 5/5] ioctl_userfaultfd.2: document new UFFDIO_POISON ioctl To: Alejandro Colomar Cc: Peter Xu , linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0A7911A0016 X-Stat-Signature: bhuboq1okwxkmbtqh4qi3wq43wdnxdnb X-Rspam-User: X-HE-Tag: 1697581573-342553 X-HE-Meta: U2FsdGVkX1/LcsJomWP6LQyuaECjfjTmY0KkdywxEBv7ApyELG3KJLmZ70hbod5HeQHJpWt7K2No2wzpmhBnppgSkFUaUyDxS+eXkvCKG6lPzG5McgcxSLm/oxTl2S76KzCIb2IthZbPl7Ohe8+hExKMYTk3RlkaV3XJLSpLP7kfPNl8E5X32oaYZQ0pKKQ4/IVYDLI5J5ttaNB9X24COOVX4CsjkhVuFNXupF2E09KGmpIwkDiT6kKoRsOHBQ8WDKupNZ00wMTheufn0Grgow6+K2HmdipnIanl4ESKbh7pwEyxgDF/R1iIhKCgs61AYTK0K/khqXl9xejV1jQE+RA3MuiAKt3AK5KsxS0MkFV/1E/9/0zX/v+IKePXaJKIG00xL2/stlzqV1Fx3dt+dNTTIOUHyzf3v7H4cG5vvdc5MpgxB40EVO3KOS7ta+F/0guMnzhq3Lt7qSW79DTQgxihoW/Susmrvwzwe89V6Ykf5yDqiKBFFn2JcUZkOrt9Xi5MhWUj0WuJDRcYPxs8Czic48y+9xhOnQmFVuN8JgxhRz3D91PayXLExYBJpBjU3OIaciInMVZ6b7nnCrr1hwxi2ZUYMLMUCbSZQ4CENnQf/JYLF2uaCz5Kig0c8/1SV5gQ04aIWtiaVo+11hOcUwDcNuQ+symYjL8lAbmeiEi4M+5b3cD96MSb63T4LH9XbQ4rKh6+8m0LCUxHs/hYq7ZLHFGvWTvzEIXhkDwB4kgl2xF8mvTu0J+XRDlVMOtuXZ9DGbOJjWGyBY31it+nsPz370HkfZ3PN0x36mVebe97KkE2eMtWxDacbQ8tqg0xlRmE3fhkiYFuoG+uAx2tV/l5rgiupZP0wy3NXmv6lbIshKq6JJ9+Xiv7QpfHqoJBi7HnzeYGayrAiFqkBLEXVhtkj4dY5pk14Efb6XlTUim9CmXc5b35Cmh/6WZ4UayaSAZ5wNESkw+NsYGhb5G W4Ceu6Bp vkhpq3AHVow5mJwGE4fcjOgxtLumxa06PwZwl981RbNzst7qIfTZBkhJoqSGV7XbpVxV+tnVNFTuSRGEK4rZaGjQ8c9z31tQDG0eSz6/bcrDJdIVxXNWc8aUT3xKn/rlBkwfW6YH/9QSW9OUIwDXAxONdzKg1Jc9mxRpfDE49I8PSiL3JqQ7L4zci+XF8Dj5hrdnt+8FaW62RpvAVEaDAAL6yj1kdsXone3I25Ky+8Xhf2/dAmgkH8aRDx/VSOnP3wqckbjmdO5o2REu0N41qIsPij5CbTDsPo6fsVxrEk18acwCYiXbrarkVtWY8H+2A4Ahmitaszsx4BI8AqBLrFeVnBUQrkXtVCUKM10YovoXYIMw/JBOu+W6gw+cYJfMy1z5hq4pVnulvBMSlKNVth9zIMo+cWgpBpsMG X-Bogosity: Ham, tests=bogofilter, spamicity=0.016582, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Oct 8, 2023 at 3:23=E2=80=AFPM Alejandro Colomar w= rote: > > Hi Axel, > > On Tue, Oct 03, 2023 at 12:45:47PM -0700, Axel Rasmussen wrote: > > This is a new feature recently added to the kernel. So, document the ne= w > > 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 > > --- > > man2/ioctl_userfaultfd.2 | 112 +++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 112 insertions(+) > > > > diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 > > index 95d69f773..6b6980d4a 100644 > > --- a/man2/ioctl_userfaultfd.2 > > +++ b/man2/ioctl_userfaultfd.2 > > @@ -380,6 +380,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) > > @@ -890,6 +895,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 > > Any reasons for this order, or should we use alphabetic order? This is the order the conditions are checked in code, but I agree alphabetic order is better. :) I'll send a v3. > > Thanks, > Alex > > > +One or more pages were already mapped in the given range. > > +.TP > > +.B ENOENT > > +The faulting process has changed its virtual memory layout simultaneou= sly 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 > > -- > > 2.42.0.609.gbb76f46606-goog > > > > -- >