From patchwork Tue Oct 3 19:45:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13407948 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 64C7BE8FDB2 for ; Tue, 3 Oct 2023 19:46:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD8988D008B; Tue, 3 Oct 2023 15:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A63A48D0003; Tue, 3 Oct 2023 15:46:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8637F8D008B; Tue, 3 Oct 2023 15:46:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6C77A8D0003 for ; Tue, 3 Oct 2023 15:46:07 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3DF8340458 for ; Tue, 3 Oct 2023 19:46:07 +0000 (UTC) X-FDA: 81305181174.01.F0AB579 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf24.hostedemail.com (Postfix) with ESMTP id 7844C180023 for ; Tue, 3 Oct 2023 19:46:05 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=AIjr10qh; spf=pass (imf24.hostedemail.com: domain of 3fG8cZQ0KCPsd0houdvpxvvhqjrrjoh.frpolqx0-ppnydfn.ruj@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3fG8cZQ0KCPsd0houdvpxvvhqjrrjoh.frpolqx0-ppnydfn.ruj@flex--axelrasmussen.bounces.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=1696362365; 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=ocOKNhdUvGY6/aq7ieB9QOD0OYSMZQy4WsHc5CUE0HE=; b=OGxakpoWtgGt7n4VVKdKIfdRLmANE/OFBXr5b7Vp6jZHkIAaFk6/VGPKENCZqTfdHojndi lukUAEL7TVEQnicFgd5MqFq8++Ospl2PlMQ0m7OMy+VOxCADdFtqBwe+Nk8THr98ZtnuWC DPOI0ISr4dByVAgWnAyxrO5I3bi+l5I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696362365; a=rsa-sha256; cv=none; b=QP9z+E+/EyQ2rI66bpbmq9MbrX3Sd0ytc37UMTEJLDMq8wRDP1yHrg1vT0kC1us9d/plSV 8JLuDR2x5u5drgnrc4SctZ+vRxFpCcpZrq5FcfHQ6+5MtCdMeCoqt6XlPGXNVa7YHsetfm 2k6dcxWEkM/ueaVZSjmMSLZkAKNMfvI= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=AIjr10qh; spf=pass (imf24.hostedemail.com: domain of 3fG8cZQ0KCPsd0houdvpxvvhqjrrjoh.frpolqx0-ppnydfn.ruj@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3fG8cZQ0KCPsd0houdvpxvvhqjrrjoh.frpolqx0-ppnydfn.ruj@flex--axelrasmussen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5a20c7295bbso1539167b3.0 for ; Tue, 03 Oct 2023 12:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696362364; x=1696967164; 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=ocOKNhdUvGY6/aq7ieB9QOD0OYSMZQy4WsHc5CUE0HE=; b=AIjr10qhGCageKCrymw5d5TFtD03y0Uo8U2TDv/r1Bv579OJA2RKHBlBTpZVWHltTe g3CpKXsDCSyUxQ1flBxaFuk1WENhujk/bipmG0ZdN8Ammg4DhjhCOZT+ZxzEFonrvuz8 ShIYr2vobTGRZmfA38KhyFwDVYzEHB/RirC64Ta7afuGeDvx/Ne8eFPauMmMexGmGyoa hpNqLeOV5fQrAwxHbexetjK8lE8smcPyjNdjfcrY8DVhWMou7rx0rKkLu54KtHpHgu0J 0aW8dLfmgoC4QZVpA1eQWq7BqWDezQbaYsgigdyng9MMBApj4pAxP1WJSz9L4o3wjmV5 pYhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696362364; x=1696967164; 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=ocOKNhdUvGY6/aq7ieB9QOD0OYSMZQy4WsHc5CUE0HE=; b=UyF80zdR/qldVLjunlN7/DgyXtC/6DFoW1MnCZifBXRfNeeS294wwHLAPKGXIWS9QL eyQq8XgCBJ07pgh0gh5aOoN3phDZH4hND7CYszPlTLaa/QtkdVXCAMqMRhecZRR/2FHl AKGBaoPmojH+Ew5LlmRYJsCiYL20LcwLqhHel0SxVI64h6Y7UaAc6D1OIA1HTo2c+dk4 p8uSibuMPKNida17GHPlhQQHUZG8yS06HZ6fae7+0aGAFVZHJtfCl/As181GYhaBFE3o VR7cosZLTBocBv3yh9SikzBmKnXWSgMv/afUI3BSUobhexvL3tSxo4JarFQBwypgAZzK AgZg== X-Gm-Message-State: AOJu0Yy//F7Oq1SP0dMVYAJDvyhz887SyGagide4wA7TVjGhk7UIQnRk C4XA1gQtZREf7PqBeQnkX8rMqo5ddifkMEQ8XURK X-Google-Smtp-Source: AGHT+IGX6pNwu3ESq/UN3DQ8E4VR3aqp5GHkfoy0UspQ/ctrBmmE6u0DHXZ9fEYmIiF/O9MZkGLTajhNajMrNK//v5a7 X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:6577:b8c1:dd2d:1c93]) (user=axelrasmussen job=sendgmr) by 2002:a81:d106:0:b0:595:8166:7be with SMTP id w6-20020a81d106000000b00595816607bemr6831ywi.0.1696362364727; Tue, 03 Oct 2023 12:46:04 -0700 (PDT) Date: Tue, 3 Oct 2023 12:45:47 -0700 In-Reply-To: <20231003194547.2237424-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20231003194547.2237424-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231003194547.2237424-6-axelrasmussen@google.com> Subject: [PATCH v2 5/5] 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-Stat-Signature: zzmepjpiwu7axxisx8debfyi5ejx96tm X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7844C180023 X-Rspam-User: X-HE-Tag: 1696362365-984302 X-HE-Meta: U2FsdGVkX18KYWZJ1ybTQSkauEnlMjRPyjStIFXv11MHYzReLRYU3xrqzhRF/DlB/4gp4IK5x/FihahXxHMSw74fJ+dzHYMsnwqG/tKmqCgn6ua1ohbzuB3/3eTsrVrCtu6LM+WL5b8H2tMdD9OdzHA0LWmx972BZjGtDR+01YgOia2OKGWqbfcA+bXsoxZWdiJUmr1AXoVaHdbctCmQn1mEqJg5OtmDTFGMmLsx2GbrjYpeVjcRZvFcsbhWp9pNj1zQ8FMYtJmpwkzdIchBIiFqx/MjvPaOi7foIB1ZSeLH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PuC6dZ+HJVN70yGlMnjCCsNizA7AN6e2HfH0/KKtJPG3yyPXd4bfwwFbpQ5MisuCCEzUwYKeI/afkH1p6lhgX2D9W03J/onwRVCB7jxAWGe4017QI95Vic70DYyWbbuSKbtLZzzQTXFYRfJvIZK1bQ7fql7OEDkFPUgPOwK7t/pCHQu6GxNV9HmoPaGGNjpI9ExU8MdK49hrjvIALhKruaeMDXGHdXmUTklmwcYgnizy70OakB2YiKAGOSU1ZYd47j7VquJ+uu1EXOwEdMvmShXFNtpQjJF6XocJG4J5uzexM91wHb+hgZWlCT+5txzU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.004466, 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 --- 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 +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