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: 13391780 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 7B5DECE79A8 for ; Tue, 19 Sep 2023 19:08:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B4C86B00C7; Tue, 19 Sep 2023 15:08:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13EB86B00C8; Tue, 19 Sep 2023 15:08:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F20C66B00C9; Tue, 19 Sep 2023 15:08:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DB90F6B00C7 for ; Tue, 19 Sep 2023 15:08:15 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AC9F1A0E41 for ; Tue, 19 Sep 2023 19:08:15 +0000 (UTC) X-FDA: 81254282550.07.68FB082 Received: from mail-oi1-f202.google.com (mail-oi1-f202.google.com [209.85.167.202]) by imf04.hostedemail.com (Postfix) with ESMTP id D9A984001E for ; Tue, 19 Sep 2023 19:08:13 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Iide+A3V; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf04.hostedemail.com: domain of 3SfAJZQ0KCIAe1ipvewqywwirksskpi.gsqpmry1-qqozego.svk@flex--axelrasmussen.bounces.google.com designates 209.85.167.202 as permitted sender) smtp.mailfrom=3SfAJZQ0KCIAe1ipvewqywwirksskpi.gsqpmry1-qqozego.svk@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695150493; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eY7SX8EsQtNfNMnrsSEHLyVvDJFOwMWgHyNV+Npddic=; b=eEsNesrxDByq+syyXKbNDaKr660gS10C+iRYQGRWH006C/eeRQB/6ALctosQZVJJ96AErn 0pv4vaprzUHunpNxr1z81MX79ED5WcXuM6x9LSis7k41Aa4XyNxJAYe+vDUDkj4ysccH1k TgTSwt9xsw5d5AyW2Up14J+1Drl3Qe0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Iide+A3V; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf04.hostedemail.com: domain of 3SfAJZQ0KCIAe1ipvewqywwirksskpi.gsqpmry1-qqozego.svk@flex--axelrasmussen.bounces.google.com designates 209.85.167.202 as permitted sender) smtp.mailfrom=3SfAJZQ0KCIAe1ipvewqywwirksskpi.gsqpmry1-qqozego.svk@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150493; a=rsa-sha256; cv=none; b=dmPCWy0F2T/ikS2HkvQjPTTms40iV9tvpYSinU7DPC3uO7DMyrtsOImfNWf0IJXKxaLmbF HZaPnVvNvbMN2OgjqXetRgL/KHlkC8gp97rzP1s9KrUJ6pDVq4KEz4v1gVpt8K8D7Cyy0/ cUwzTiU1UJIW65kOfy0s6YkVp9mAU4s= Received: by mail-oi1-f202.google.com with SMTP id 5614622812f47-3ab7fb1173cso9449112b6e.3 for ; Tue, 19 Sep 2023 12:08:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150493; x=1695755293; darn=kvack.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=Iide+A3VN8Ruc25fiLiHUmqwogp1YyS47FJyU/GsvEmEnxx84NpoM8XZ1f+T3nRsQ7 F7ZF5zKg+nBHb+AXaJGOcHRLSWyZ3Ie4Kk80S2nqbp/SyzuU/5jfm9ETOkl2rQEWeX04 6gLsrqjfw+dvHXNizBYgpnQ/TNNsPkZh0yNuzY9OpGPw4de31b41lOfyH8oxQH2VVAro Zt40tEDurc5d7FBHBibzcwADSRPYKQ1msOkmHFatjx3cGgGv9uY4ta42JEWB0nqtRktY 3yBFneYyzinB6Tq4b+iRK1g03llU2XB5xSrWz+P3NvZ2xbLmoE6ugqLe4tSgKFpHHwLJ MjIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150493; x=1695755293; 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=pVfd2sZTAQHF6Uy5G5wogDj3jRafgl+P42D/0sNjMvEaFw0LdhhVjOggR3DlJeVjCd XPn+JsXWx5dRa8l8XatBpjZOLA54aZ0/u7Hl/SHOGrwKUkunUc0oppiGojv3xXa+juiw s97IAbkoLPkQFw24zl667uGj2SX7QwfHWtmpLmUHc8gGC1sbtkgGEX4MMrR4dgwYN+tn zqoYU+5rqfun0EhNxqmW0FptnUbxHGxLZnZYYot9RRm239lPG1LJvUDji23/SA8urGGl vG6siEtHhaJs6M5OvGLxzGFZ/DBOODknefV1bu751kdsansG+q/JDYoPn1yptZ5ollI4 yWGQ== X-Gm-Message-State: AOJu0YwBD/MB5I03PSDVanNeMsCNL0ojiH+7pwwKsux10WJLxGQxbZZF B9MC2k6KoxM9cLGfm0J4enHqCgnOlaafVEJSSKD2 X-Google-Smtp-Source: AGHT+IHpPbS96Mx6MQbi9mIPwv0TNNEi8isBoT3vJcnpji3vR4bjpJymIgfnAn4/hr01wOog5Jn9kpIhiLjimfXb/edb 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-Rspam-User: X-Stat-Signature: 8whirq43f7q63tghyi9cq14sghoswsx1 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D9A984001E X-HE-Tag: 1695150493-579525 X-HE-Meta: U2FsdGVkX19sAFZlyrvjrc9Xhc/fIdbVHUKE4YFIdc9ctQP7JTlhh0NOmbTn9HKpLvhQrsG+DPOmpRdfwYZ130+jRnT7PCgk8Y874Rlyl+wi8NPF2ySZtnFt2xi4sQeXezTeDwiMLsN6X4WTDl04uGnFXzYSHBAao0Z9wwJofFQuOmq4Tr0Qdu1HhrsU+Vj6pRzkPgzZiCRjnw3Mj+dwIOWYBBYzwZrAwbogisI15iQ1lejjqoiYHwWoh4Q4+0RbZmqeMIMwRYbhXD5EHE7hq6ztm2eHtjevetwMUysCjVJsB+LkRXfR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RFvWwN4F0oDLZpaot5VdsgBx6RJ56vkAsxMdr+TfwvjXgJps4RRshAPCA4wolg1gY9kQritT2U1JdXC4h5AmiEOgHA30xc+A2lPVqWFcJuRRPF6Q3fon2kzmmRuVZuTTKfwCEYglJNRpWeOzsIfO1zNGTT61bNlYtVcbiR9MCq8P333AZhiHY2O0+sZBR0w5xhZcqc23nszai0gyMwpiI2b3rxw57dhY4mvBq7KQrO90rhNKwwI57QkGMB3569juEexdQIm2LfGBj021PS/N143c/3B4q9IHqH1i25TJX+usTK7p2lPJ/45c7A4kc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000500, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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