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 D2FF2CD8CA9 for ; Tue, 10 Oct 2023 17:14:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EEAD8D00C7; Tue, 10 Oct 2023 13:14:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49EC98D0002; Tue, 10 Oct 2023 13:14:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 366278D00C7; Tue, 10 Oct 2023 13:14:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2623E8D0002 for ; Tue, 10 Oct 2023 13:14:35 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CD42A14037E for ; Tue, 10 Oct 2023 17:14:34 +0000 (UTC) X-FDA: 81330200868.29.8F9F097 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by imf20.hostedemail.com (Postfix) with ESMTP id D49061C0004 for ; Tue, 10 Oct 2023 17:14:32 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=32gTk3K5; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.221.46 as permitted sender) smtp.mailfrom=axelrasmussen@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696958072; 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=mL1ONcr61Ib7ScjkzkKZysiMUjN95IuX6Qlc25Z4TEY=; b=C5Bc9GJwEOtcWPVf5dOlNG5aoxp8zxxo6HEcFSsRKz+bs7tXWr/TWhELZnasN6GreDPFJa MWZ8OUjyXBLafP6Q1gqNQuM3gL0ikgGcnkoPmPkWa7izV9KPnEbkapDrUScNoOZ+0bCdzn qv07TftYsE571kRrcq3k5a/FN/TEpGM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=32gTk3K5; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.221.46 as permitted sender) smtp.mailfrom=axelrasmussen@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696958072; a=rsa-sha256; cv=none; b=dveif23HDfqOK2E+l+h2tQadl82jDWjbN2/da5S2Z5o+kMx7GZfTkKJQm41B69Ty041EMR CWu3kESI5p7xekIwo9ye2hWyprPyo6lBSXaUguHbEbVqNBIUiMqz6clz2gLT54JUV99Jmz 1THOTA1l2KdQqLb3IMDYUMd23RD7D1I= Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3296b3f03e5so3929288f8f.2 for ; Tue, 10 Oct 2023 10:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696958071; x=1697562871; 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=mL1ONcr61Ib7ScjkzkKZysiMUjN95IuX6Qlc25Z4TEY=; b=32gTk3K5YjHGAwT0kJ0g2DGFQd9iAtj/zJDXWuCS2h8/XJyWut32gyZ2EIXizXwGzB /RCKybABpFDTQ0Um5gH5ITpV9mMBWoCjSBEuC5hXhS2sQPKoRGb9th+umbOSFfxy8hRp hm0AGgn0oHJzjALeJ2Yjm165+GiRcz8Q5TCLMHZTRaFVzerrgiSJwy9ALAlu+Uf7VpLB ocI/N8iywYbpi+GQep4inO5673qKk4+mDT2k/3E1uVQ2lEmU4eXVGnmEvRJcW569BtCp 6XlMamzXe8S3ikajasbu07WicADIIHJEmllMLgkPJYYcjAfcI1HAamoxAZ6xO8dzxoS+ 79rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696958071; x=1697562871; 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=mL1ONcr61Ib7ScjkzkKZysiMUjN95IuX6Qlc25Z4TEY=; b=cwlY51TX64p+hd++wmlII6U7F86EwW8vU7SPk4g5wDEnInYs6i+W6MVmNEnttVXFHU W8jnt6WFgoaQG2SoyoJLH2J5fVRlQ7U/VmJOTj/TQU4sw6BtfbFu9dLFfIvMPcGvTLmJ X7L5Efu8GyceaQMzyw6jL6x/Pnv+72bK34aGU2YH2Bte5ORE7aWpQAGGIRi825KKxpWj ZSx/oQhBjNsUTh81ZbOUjZjy7Afi0qV99+ATiILx3bBBzzyyYVfjU2ixmmMl+9hysqBB pXfcIwcsIFePTMHzdCQIJ1GYMLP7Hu2mHAzcpP+BRTidc9b4PgQho/iXacDvcKPHh/+v Xwzg== X-Gm-Message-State: AOJu0YyS0DZpwdJC7Jx16sjjhxVqNYPd2nRt9JJEo5Q2Y8uRRTmc4sse AFDdCtEj5Prc+/AE/cbD0Ytcp4YgxvXjt9DaidKZyQ== X-Google-Smtp-Source: AGHT+IHQTIjhlkcO+mnCKlDvZWLFRrQo86zWj0NhaSwIn/+at3tMnwfJLah8RLYmnfVLfaXqf4+J2NO3xAhZGnhx1Gg= X-Received: by 2002:adf:e9c7:0:b0:320:b1b:86a9 with SMTP id l7-20020adfe9c7000000b003200b1b86a9mr16081518wrn.24.1696958071211; Tue, 10 Oct 2023 10:14:31 -0700 (PDT) MIME-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> <20230919190206.388896-11-axelrasmussen@google.com> <20231009090951.GM3303@kernel.org> In-Reply-To: <20231009090951.GM3303@kernel.org> From: Axel Rasmussen Date: Tue, 10 Oct 2023 10:13:53 -0700 Message-ID: Subject: Re: [PATCH 10/10] ioctl_userfaultfd.2: document new UFFDIO_POISON ioctl To: Mike Rapoport Cc: Alejandro Colomar , 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: rspam09 X-Rspamd-Queue-Id: D49061C0004 X-Stat-Signature: i8pw7t3iox5bnzzkz8wr45dqzdex1a1o X-Rspam-User: X-HE-Tag: 1696958072-619608 X-HE-Meta: U2FsdGVkX1/E6I8QPGJ84BZCxyRg1FPp+MQz0daQRfOCcZDPZCrcogVk60uVdWwkHrhlV6YuEFb2uvlAWP2bhERTBPer+ySgq9TwzZwOzbM5hDPc1xOe18PFCZdIvIYTzxbr6+0iyTXjSHNQXQQ0e5g8kbQxSnwV5y3pTMiEnpO/v7J07KL7BAk8WdeR2yGR3CQRaJ0a6J/EtnZwW6ZEOOW1pwjMT7WEzPJvcdDJAMTYukvwRIMz8/k764qgK617OnP+K6ljZNVrNPc6p1TgAn0c9+HwyU46MPGet7DsMJNNfPiu0AkAmv/H8sI9RHcuOcwwJ3AvPpLSjqZFpmghW8c7XdWoH+q+x73WYlNqrWeyragYzkGOANNLGjxApC5kKMAnwPu4r32P4gd+m6J+RpAGzSJ50hOsMjCbEHa9Q/Jc/pxRo3s1q/k/qVfX69zpK9tN39zeBWa6w8uMNcpCcKcsj7f6SCD8BV9nuLPfLMcRRp4Gsu/u8+P8X0iCUw8U9B7smKE86LQo/ZRWgPsS+J7Xny9SlxZ+DXNYcsr4t5h3bfCTRL2CCtbkI67aJ1fzKnUgcJNRUSCVqMoCZyL/IdD7TWN5y9Yc8CYyQ5hcz5/eWPo53MfXQWus5W/nuxuO1kY2lXjEETUZRPa+Z5KQAHzORY3rSlRk56bEzDcdpQrNx0xCy8pDVh370jI+jexhqVnW16GRD8d0OeQ6Ppqto1Mz9x1UNMxq38RxX2/ohROMWjh+GkT5mgShcFwczfTIdkeOm1XzAjAuoi+WdDS/tFFiRP9O4CaqswJEY2Q6PJ0UPwrZcxYCHOn+41V2PHoppOItQg1YVrXHqotsgueB3vQ0CDxSptGnXbLc8k0sL7c1YrJSs4gCk1AjSVB8dnQBnGCaPt+ai2rFxybc8FwyMZnz5Xs32qzqCChRAkyV3YvU1JgDIBhccefcBs3h65pyenXRmXRAegNariLw4gw M42DJCOJ y7pYFmqFfsBJn9HEXPB0Lz6crS1r57aHkbw8dHhhKGV2vVW0YWWEj/e3rhFyuT8FDUQeFQx9RdvQpIezWI6d9JaF+KpDLizuD5L5uSNW8iTjDhaZJoI3kPIbynIWmrDLIlyIhLJrtgjz726VV1FESAttQBPmuQ7KBikjJeODLruPs92VmdQPmBFwNsadXWCarki2byLNTJ3ogo9JWmCYOCymYrqTkHOUMw8IQPwDI8tjjAvoXwvi9x5uv+mjCW+HwczSa6VqPcl4B4Lgf1Khq8uAIkGqAilDKznU0c9D5oP9XwvZrALjD0lOnbPgWKgoGK0T+lr/AXay0Vs/Pebcpec13xse196V3lgNA X-Bogosity: Ham, tests=bogofilter, spamicity=0.000008, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Oct 9, 2023 at 2:10=E2=80=AFAM Mike Rapoport wrot= e: > > On Tue, Sep 19, 2023 at 12:02:06PM -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 > > With a small correction > > 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 > > Did you mean uffdio_poison? Ah, yes. :) Should have copy/pasted more carefully. I can send a v3 with this small correction. > > > +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 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.459.ge4e396fd5e-goog > > > > > > -- > Sincerely yours, > Mike.