From patchwork Tue Sep 19 19:01:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13391771 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 72916CE79AB for ; Tue, 19 Sep 2023 19:02:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE4F36B00B5; Tue, 19 Sep 2023 15:02:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D96396B00B6; Tue, 19 Sep 2023 15:02:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5E016B00B7; Tue, 19 Sep 2023 15:02:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B87C86B00B5 for ; Tue, 19 Sep 2023 15:02:19 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 88FC5160DEA for ; Tue, 19 Sep 2023 19:02:19 +0000 (UTC) X-FDA: 81254267598.23.F580E10 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf15.hostedemail.com (Postfix) with ESMTP id CC811A0036 for ; Tue, 19 Sep 2023 19:02:16 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gikkBPOF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of 3N_AJZQ0KCG4MjQXdMeYgeeQZSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--axelrasmussen.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3N_AJZQ0KCG4MjQXdMeYgeeQZSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695150136; 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=OM7/ZBsweEHQQFPt50lI+eLlVKDaLR0lSsGnYD/uIDg=; b=ydXUpCkc7P+9/oz8YmzLCoPFT08t7E4uCO9AKwcbyLDY9dPDQxAD+mRsk/dhzDcV0dstIL 7qBjp/Lei+JrV7LnGlNK7qbvFnPUCAuEM1EyDqxgErV1OsLPcvJayb14eW4J/lru6BrOl1 UN6uUT3aAT7QNWCSxAj4MFYinswMpak= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gikkBPOF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of 3N_AJZQ0KCG4MjQXdMeYgeeQZSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--axelrasmussen.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3N_AJZQ0KCG4MjQXdMeYgeeQZSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150136; a=rsa-sha256; cv=none; b=CgXxPMEwx9P0jRaLy8zkvv7ncYBydBEf2QPm1knz2USDrOZS0rSZfsaAPy0LQLq/k6NZm1 sscjbmSBI3KO2jeCmkADOA9rriyWxKsp6BAJigDotVfwdXa/3auT3+AfRacEGlfKw7fway c2DS1MoUY4YfhSOE3/uqSUWmGeBqVn4= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-59c240e637aso48602977b3.3 for ; Tue, 19 Sep 2023 12:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150136; x=1695754936; 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=OM7/ZBsweEHQQFPt50lI+eLlVKDaLR0lSsGnYD/uIDg=; b=gikkBPOFHF4nUNdXls6DWfsxajrFW3Oy4wsat8jeCBA/MZ4Zpa7ftfJ11aFpZLNMqj Ei7S51WgYN1Kllz2vdO/cuRiS5jU+UqDBqCPamTFPLo9f+EAUY16IBx5oj1rYyCd9gw/ QPQxJKKjn+6sWzZu13Sb0Dymt+BFpWGpQ4gjEWSS/PO8+Z9hiL7vOEi3V3AXs/Z+baEi g45Aa8iQUw0meS7uNDLuECvwjTOB4Ri7QujquTRRuVSGFmN0Nj/eDYbcjdDu5Mly2ny1 HlsHEFbe43vM7Jn6sM4MymZ7Cv+U9icfuqakrBLuHJRM98shDIV34C4ITu9m1BXShBME pWQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150136; x=1695754936; 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=OM7/ZBsweEHQQFPt50lI+eLlVKDaLR0lSsGnYD/uIDg=; b=Tai4cDYRLyeilhavy1dkGX+/+mVX3xQFt4SyDxIXJ07ZXgc2+tucFx/HaL0gb+/pW+ ctxViCr29DrLrM+XjENEECkJw9hkX3V11+1tR4dEbXOwPk3K8wuoNklUaMJ47wLXieKh I8GxA58xV/mENgyG6Fxe5zSVtZFFjVVxi1GX59LTcGgMY64mAMGs5L2zlTER4axUCa5B N3Hwvrey4gIoXNapgtTtUd/yBIj2k1UxbaVAgjgAQPrOT51dHU7x7Z0RznqLzf3uNV5T OOOrQXz/2l7uQZkvh3A0IbRszpvwzcGiZVno90XypPuD7OjpVmXQjPNFKHx3zGoJQOca 5Bvg== X-Gm-Message-State: AOJu0YwyQdow22I1hRDbP1zjTcxRkHOWVelgOfeRMPUCYZROqc9zw57M qVVS9E4i1poNN2ZxXFkG1SrePJylvdUSRTz1f2LR X-Google-Smtp-Source: AGHT+IFf0kRJIOcrKDJvGyy+9uuMetyVG0rmWrcYJuPzwTUle78T8JRLjh7ImzOta7b6zc579tMrz4KeWMgNFH3qWKPl X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a25:ab48:0:b0:d81:68ac:e046 with SMTP id u66-20020a25ab48000000b00d8168ace046mr6411ybi.12.1695150135954; Tue, 19 Sep 2023 12:02:15 -0700 (PDT) Date: Tue, 19 Sep 2023 12:01:57 -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-2-axelrasmussen@google.com> Subject: [PATCH 01/10] userfaultfd.2: briefly mention two-step feature handshake process 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-Rspamd-Queue-Id: CC811A0036 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: um3d91eun4na1p16s5nfyj98q7hcqu15 X-HE-Tag: 1695150136-90569 X-HE-Meta: U2FsdGVkX19ICr/bzpZ2JlE1y1r2xX9XWoftRBNgScfrSKio49PQ5Z4bLDfWFKTWewIfujhKsw8wzbd+y1fcRkxpNdn7SgSYBTVbp7ba/O1skCiIj8J/IrSWUACJUhPNXsZ5h7o7RHyXshXM7uvCkgjHM149Y+1B2jqpPoh0DQLGZLFIbiviZaAPSzid7ALwOcasRO8iZy0b+QzaabIZQ3h4VQCSK7czCa7k6SHJvXcMMXSEqMupTLUAZUms4xkMcWGqc8C1Ti8GoXItQc7KDIM7s7lqqQ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KBpDEb10AAsXSRTJRoxRjGvWfmTkXHYxo0onGlTXJqcEKRQTWWNi6r+5AnqwM0fa6tVLRf/awrz3xnZzIZEzj+FgNPyo38vfs06ra42ZL/w48LMr+vvbStIuRIWiVJyeSj6ASWHKZSC1atAPK9FionbSsQXdwOVuUfhc3CsaTzqPeW/zqxcYfRnxwLQCUdIfGXCDi1BABF0GHDqEm9CJoOTKSRVPnQwNJQHFrWODEqJ5Abiwz4Qnx1V2p3xdmJiyoFPCwU6zLUGKGN3v7PVS9rtPRfBM+0Ow2yUpO95FzYgF+IHG6a X-Bogosity: Ham, tests=bogofilter, spamicity=0.312132, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This process is critical for programs which depend on extra features, so it's worth mentioning here. Future commits will much more fully describe it in ioctl_userfaultfd.2. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/userfaultfd.2 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 40354065c..1b2af22f9 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -200,8 +200,9 @@ the application must enable it using the .B UFFDIO_API .BR ioctl (2) operation. -This operation allows a handshake between the kernel and user space -to determine the API version and supported features. +This operation allows a two-step handshake between the kernel and user space +to determine what API version and features the kernel supports, +and then to enable those features user space wants. This operation must be performed before any of the other .BR ioctl (2) operations described below (or those operations fail with the From patchwork Tue Sep 19 19:01:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13391772 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 69D13CE79A8 for ; Tue, 19 Sep 2023 19:02:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF7B66B00B6; Tue, 19 Sep 2023 15:02:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECE5F6B00B7; Tue, 19 Sep 2023 15:02:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C849E6B00B8; Tue, 19 Sep 2023 15:02:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B90B16B00B6 for ; Tue, 19 Sep 2023 15:02:20 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7E0E2806AC for ; Tue, 19 Sep 2023 19:02:20 +0000 (UTC) X-FDA: 81254267640.05.D3CE635 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf19.hostedemail.com (Postfix) with ESMTP id 938FB1A0008 for ; Tue, 19 Sep 2023 19:02:18 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=sqsR5F5L; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of 3OfAJZQ0KCHAOlSZfOgaiggSbUccUZS.QcaZWbil-aaYjOQY.cfU@flex--axelrasmussen.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3OfAJZQ0KCHAOlSZfOgaiggSbUccUZS.QcaZWbil-aaYjOQY.cfU@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695150138; 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=x6ui7w7cp8TYbfd07TcF3y+H8C9qnaw+znngkakEYjM=; b=FVUG3Urw/EFOgYm0HKjGfHyJt9JIF3mTJO34G+EAjudQTpr5zhJmGI+xgLukTOrp0Cbd+2 jV2/wOdOo5XPJO/7rHVEt8MQCBhLqZiRGLKRjjTvhgfoJ2lJyJIPTF3HS0s7QrYpq+8R01 BD2P/2RSQTw+wCbANNGFjeTs5BgKXho= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=sqsR5F5L; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of 3OfAJZQ0KCHAOlSZfOgaiggSbUccUZS.QcaZWbil-aaYjOQY.cfU@flex--axelrasmussen.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3OfAJZQ0KCHAOlSZfOgaiggSbUccUZS.QcaZWbil-aaYjOQY.cfU@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150138; a=rsa-sha256; cv=none; b=ObcviWoMMoZl9xUuiRQ1F8c0yZMHtt4tDAtlAhUPJHYMR3nibrmXxlzPZK4OF8+RljRdhB cIXfz5MDql65YdbfSD4s5GuRxE8znoGY3OhR9cF2F9PZb7MagIdmvchHWwDENcSwXuxpMf 7zU3xVjrBGupfW5/N8sDvF+oRcSZyjo= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-d8486b5e780so3315999276.0 for ; Tue, 19 Sep 2023 12:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150137; x=1695754937; 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=x6ui7w7cp8TYbfd07TcF3y+H8C9qnaw+znngkakEYjM=; b=sqsR5F5LMrU+Y+ZIMLpBkH43A4Evg1CZE+qtppKEiKb95BuJGKPviT6eco6ccAffmq 4mLDgVP4oHcQg3ErwTrFYVZ492ydJV2zPOnMTgNjpsIE2IRyNYLAXGqreJsTDOAFqdd2 BUwHDeiut109myI4/l0CIFp1+OwGLYdyQQpjmavwRtK0JIPmfTQupgB4IiznkwMf7X9X INlHDMZ3VTsskKxShaeZd+A82Bg6Gx+YV1sui4mLt3Chxb79E+5qSSGM3R7GguDjtUBC DkeQBJCQ3M0GYuqM3/21UhVKMNZlCb5fRxWiQaRvQK9Y6NYVPHhZfQvnfMCt5OJgTcjF 4wsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150137; x=1695754937; 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=x6ui7w7cp8TYbfd07TcF3y+H8C9qnaw+znngkakEYjM=; b=ikguRCv8oNMltmDDtJ+sn2mM8VAISu5Cew/tRW0WvWLj4f/00s4nYjUiUL4gPd5HDc 49Nf0Kir5fIfCNK/b87Aj6x5SzBsZm96ABi2lPBui42xJ6TE0ex9HNWmXrLP8Lzoc9Hd V43Y/GxMQag0r7f1GfjJBJCewYMr16uwbDmu7jFN4B1tvv+I0Yv0fr4yI0jhu15K/ifg paGrtT8KKqqg2ENFHdeTjyrPzdIiMmUxb6x8kx/ByAyWqX2rpDjYOtPzJdRy1teMuoiB sR9VDdlwzrDugvKNq5dGab1vMWaWl9i0F4VYGFYGG4MNryvOk9vcj131hd9iwOClrznl M4EQ== X-Gm-Message-State: AOJu0YxKvyPEiPFuarCTmLGPB8QQwqaaJS2JXCiLuPozQI0FqY4pxz4X ptw8I31fWXYxuWWje4ah5cvxST2dlaGW660LsmnT X-Google-Smtp-Source: AGHT+IF7EWSh/N5MMPZLdhCjlunDyn3WMMhW7XdriIWLhkImYiN4zAjIc9dNexk394B25SiyeJMGHk+g/2e7wceTI23w X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a25:8b0c:0:b0:cf9:3564:33cc with SMTP id i12-20020a258b0c000000b00cf9356433ccmr8307ybl.13.1695150137798; Tue, 19 Sep 2023 12:02:17 -0700 (PDT) Date: Tue, 19 Sep 2023 12:01:58 -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-3-axelrasmussen@google.com> Subject: [PATCH 02/10] userfaultfd.2: reword to account for new fault resolution ioctls 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-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 938FB1A0008 X-Stat-Signature: 35s77peti1y4zm19di9oy3dt96ranwgn X-HE-Tag: 1695150138-517999 X-HE-Meta: U2FsdGVkX1/iwc4Savfv7ceHUyd2QBRXHqqIj2i1kVKS8zOJeqjsIpywKx7ot9YGYvsm41zPU7duFAXjePruqoKpv4OmcnMdNqp0vDmM57X2IfInKt8nACldJSHKjXzPLUO+wkIT3Nv0WfKCevc2+Fv60Exw0zVAb0zAeIZFXMIeOzg8mprtA2m8iTM3ERVFcnIi4nHoNg8fyXtSLc9mFIZJ98lrPLwZ7hDH434GMslJ2K62BEsdqVWnSgSOG1ESXbBtEuk9MYek8khjdHbBAD+bnevfZ2u8ZV5bS3clvMUbC8QVm9tu1uFdqXwTpy7J9ZqPXTGdNckq0DvfshgwbDxDccOO1ZhFAnARq7nnDYy+J4AZF5i4Yta9Pdqs3KnfJFGQCjWKZUewRyEWSQtalC2KTBd/dTHmOzNhwBsOwlNw9RStx7bKr3ev6uQA2mhzxkcX8UNYRkjNP2TMn3QGRsuP+83U3g+1uVWETOJ982i0wQxHDsYKg/4qcFmZeUJsHsOsO/mKIOhnCOR1aes2tyGURJ9ZTeBYqNDUz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KnyS26SsR3AjLATg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.296964, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Basically, reword the sentence to clarify that this isn't a complete list. I don't believe it's worth maintaining a fully complete list here, instead ioctl_userfaultfd.2 is the place to do that. Let this just be an example. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/userfaultfd.2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 1b2af22f9..00d94e514 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -222,11 +222,12 @@ operation, a page fault occurring in the requested memory range, and satisfying the mode defined at the registration time, will be forwarded by the kernel to the user-space application. -The application can then use the +The application can then use various (e.g. .B UFFDIO_COPY , .B UFFDIO_ZEROPAGE , or .B UFFDIO_CONTINUE +) .BR ioctl (2) operations to resolve the page fault. .PP From patchwork Tue Sep 19 19:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13391773 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 76FE2CE79AA for ; Tue, 19 Sep 2023 19:02:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07B0A6B00B8; Tue, 19 Sep 2023 15:02:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 034426B00B9; Tue, 19 Sep 2023 15:02:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBD786B00BA; Tue, 19 Sep 2023 15:02:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C892F6B00B8 for ; Tue, 19 Sep 2023 15:02:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AC43EC06B2 for ; Tue, 19 Sep 2023 19:02:22 +0000 (UTC) X-FDA: 81254267724.05.D5E59D8 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf11.hostedemail.com (Postfix) with ESMTP id D1C014001E for ; Tue, 19 Sep 2023 19:02:20 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=tpW+7o8w; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of 3PPAJZQ0KCHMRoVciRjdljjVeXffXcV.TfdcZelo-ddbmRTb.fiX@flex--axelrasmussen.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3PPAJZQ0KCHMRoVciRjdljjVeXffXcV.TfdcZelo-ddbmRTb.fiX@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150140; a=rsa-sha256; cv=none; b=Uza0l64UFMa94uSccriULer9Hxx0ywlA8Ea9gjKgiugs/VkJqFejbUuNEiSsepjxwu1EAL dJIB0qxAjLn/n4ykuYMXIY+de/7krVFlWrNH7hi6wzLWzjzeZqbqUElgezJ/R+BWAnCQRG LiS+LwACmz3wYCXU92P28Ys0tk0q0Nk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=tpW+7o8w; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of 3PPAJZQ0KCHMRoVciRjdljjVeXffXcV.TfdcZelo-ddbmRTb.fiX@flex--axelrasmussen.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3PPAJZQ0KCHMRoVciRjdljjVeXffXcV.TfdcZelo-ddbmRTb.fiX@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695150140; 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=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; b=M1i66Gf6hJE8gF8dMwj25mFwJDz9mqEojjE4sce2mAJsQBNHXjDbvkGfDnIqf01Bu6gkY6 lzsOQU0DqlCroamU/jdKP3TDr3VDCUvLoY+7x0q5doaRlSdiQAgnVhWQp6jZCrDnKxj0zv NvIjuIwJdbZWUA0/5sASCFOEOA/nqtw= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-d859ac9ea15so277230276.2 for ; Tue, 19 Sep 2023 12:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150140; x=1695754940; 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=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; b=tpW+7o8wdfKa1VXIW8WjxrflhEGWEySQ+qNLeng/e8XS+zHRHl39P0bPUSQ5MJfLxF plhrJAL2x32P0vmtqov0Sc1TqCwrx52IH1+AhPbWiGELddLBw7U+JHue/OPKhYdYqgUH BQ0wmTVypsphWWzPhIwR2lEeNOmcLT7XuU6STOyaZA9m4I7dj/XAbDoASNgko1kDOPli N6KryCCPEWgC2XD8DZvooBKkLVZiP+Mje6dHb2RhJhd2SlR6IORRZHjVjJ40FWMtYJBu 1HcgoaiGjkJU9IA9YqGyzzYN0Nyp1gBruhwCqc5NtJx0TK0pCbxLj4GiveOX/TnKGqzT XaxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150140; x=1695754940; 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=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; b=UIKscpzyVAin7EXQQblNPLtR4aBZq7kg+c1SXVFzpk1TFVw74whdLaz9YxXB0PPMtQ ysw1cafbk0qaukPeGsTyhVUAiNoN1iHd/MI1cEYy+BJ3ytTPug0mW5p9OTB4cBFaYkq5 wZmeMsW0G0riE8iyXRuk559q0du4Bn5rMuoDrujBMAK8O0s5Cg6y/SFBELXxVPnKX+NX St2jPbpj14WIuYcLeZsBxmTE010gIpBxshM65euYJow4MtGZWq2bS/Ja66Sx2uwRAV2l plS1w3+j0uJ+lhZ+fK3Z9BcSQcuxwhrL8Gm2cKMlautQXbb2hLU9rIK5mvy+ID+5IUB2 Y0BQ== X-Gm-Message-State: AOJu0Yw0EWbtmHaoMAQcIJKKvQ1yhlZ1Vzmi37So2UtxrUMYyDFLpo9O wH2BrSx0fKjvVOc6/kCX7sfOkDGg1hUCxCUmSrHB X-Google-Smtp-Source: AGHT+IGXSMthavzGtM+I960Ina2tCwgtxbX7+5w8vKtVGs3oDe4TAyxfuIyBkIIgO4pFyUZosMmWqGuYU0BoHxollsgu X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:1805:b0:d77:f7c3:37db with SMTP id cf5-20020a056902180500b00d77f7c337dbmr7869ybb.8.1695150140155; Tue, 19 Sep 2023 12:02:20 -0700 (PDT) Date: Tue, 19 Sep 2023 12:01:59 -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-4-axelrasmussen@google.com> Subject: [PATCH 03/10] userfaultfd.2: comment on feature detection in the example program 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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D1C014001E X-Stat-Signature: kboyroqffsyqizeeogfps3yj64ef6qs6 X-HE-Tag: 1695150140-317995 X-HE-Meta: U2FsdGVkX1+H+SoYOWYrSs212lGGlW1RObCatc6r5+m/15g6pq8TILAUV9vx6PwAROTjoFx2FP50gWFXGyyqFXMpx813KrEcMTR4PyocXmZn2KKJeIULAD+wpxRVQl7/hC/RzZAr+3L84s5RSRZgwBX7KmxFJYKVrHSCw6/o5QbtdXbQdSqcA4JHdVy9N+ytEojJ+7zvfOeAn4UOD0/AexR8WrC4N6nlwOhG4GtyZBAacCi7BIb8QYT7MuuwiWFaymdfwherflg9NlLi7/anU9rWwwulznGNFECufYS4c2h+jvay8La481yol4+L0NqKuKk+xSP5Hoq/6T8/L9lhidUUzMvnJk8BejQ0KPtucKmWJ4k3bpnIR/i+uGXoQtDSa2tjh4tiF5jHvuedd7bQ04ZQKCGWQbUIXqKXbNxaz5koaC00CF1vUD2kAAM3w+0+JqHHaVRY3RVR8dVWJnXNGd7qJr0UqLT4siwvWl4syCYZtoJKnHlJ0npTa3iP0zEOxjjPjerpAMohHv1crqlXmk1RcBy1OQPLL86ZaNz4W2wDX8jHjYcLU3KzwC9pODSBTMeyvBgcFm2g8hgwFep9pBFmzyWz0qjMUY+yHRHJYQltmW9Fts5b7inlSnTu1C9JL0zovBGBpmjLqibo9ksK95D72vQOVXM8fP/rwmztHfXC6YuVjubZ7alfqeLjUdB6M7Z5/fjdcmI6R8oDPyV7FRi9HtLVJKsIOhRPoLueNut8OCb0lYFnr+aH4E3xU3W0A9NLBUMoTB7qp7/NUUWq5Bbts5+WXLCzUJhTUypUhbQ25qmfLuASE5fGo+UuK4oBUVLioGPQsTLeSjp/oDdRVwkAild4ZrVIhEnwNJMDCYuf9qRv9D4PwmR06+ZOYDwURbqUDUh19iMsw1+RYqGvI2UbWKn+nKB5LguV3gUzJ8L1lkP5uGajiUUEt40eJq3+tgjP4k/WM/vJ5IQUvDK tOyrXkVl WE8W7iyYyswG3Brmyj5zQN36pZzAJBdnB+gD7CKEOeLYv1MBNUlZwMp5BuTaKFI/bRgFoev1NUdbmT5Cmn9XD8w9WX1MDZngCfZNc9rw+zaM0Ma/1vg5Nw1suuCS+uvRiSzzd/gWtLoqXMxlM3ok3+VNQcywli+ZlEETam1aByXLBs6AF1lkh24N2WnxKW/lfCIy27ACsB6pjdYFwmpFVMNa8NA2O43/nV4H/mwt4mpRi8Z+DAKGPbQT+ODT33pzOvkcmSBo4pQ3S+Qamx2OGOhVB0nabn9VXnHylPyvv1uQYW4a0EaJHvm5UxGnq7GWDVhK+0PiHZAfq0CrmUdoWtGxyMRq8xzA1inW5hJcSS2a0jcnmBtzUiTuGHJA9sbmL0yNh6bveEi8jpYoLRm9SCL2jMhP5dtt1GntiWkdR1GqLfg2Ttx0EyWZtrPz7RPXiJn00IZC3CrenI0Y5N8vi1UbmildVv5uw2fY+49rPDm7AmR5hWcZX4NL6KN7nKTGDnRsFEaXrl7Bn9FqV2SXIrH2kXU1QCK0ifudHxePvHHHv1xajnNcP2KdPYSMKKbuqRs/fF+W5LirOVIn5VsDvcTw/5vyHNx3J69V9g8/+YHkitvOuP8Ye4neFqkIgDCrUUfHl/yVhoOPRzSkJskoaj4brng== X-Bogosity: Ham, tests=bogofilter, spamicity=0.136434, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The example program doesn't depend on any extra features, so it does not make use of the two-step feature handshake process. This is fine, but it might set a bad example for programs which *do* depend on specific features (e.g. they may conclude they don't need to do anything to enable / detect them). No need to make the example program more complicated: let's just add a comment indicating why we do it the way we do it in the example, and describing briefly what a more complicated program would need to do instead. The comment is kept rather brief; a full description of this feature will be included in ioctl_userfaultfd.2 instead. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/userfaultfd.2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 00d94e514..b2b79f61d 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -881,6 +881,13 @@ main(int argc, char *argv[]) if (uffd == \-1) err(EXIT_FAILURE, "userfaultfd"); \& + /* NOTE: Two-step feature handshake is not needed here, since this + example doesn't require any specific features. + + Programs that *do* should call UFFDIO_API twice: once with + `features = 0` to detect features supported by this kernel, and + again with the subset of features the program actually wants to + enable. */ uffdio_api.api = UFFD_API; uffdio_api.features = 0; if (ioctl(uffd, UFFDIO_API, &uffdio_api) == \-1) From patchwork Tue Sep 19 19:02:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13391774 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 609DDCE79A8 for ; Tue, 19 Sep 2023 19:02:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5CC86B00BA; Tue, 19 Sep 2023 15:02:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0AF86B00BB; Tue, 19 Sep 2023 15:02:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAC3F6B00BC; Tue, 19 Sep 2023 15:02:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B70536B00BA for ; Tue, 19 Sep 2023 15:02:26 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 912C7806AC for ; Tue, 19 Sep 2023 19:02:26 +0000 (UTC) X-FDA: 81254267892.05.F904825 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf21.hostedemail.com (Postfix) with ESMTP id CDBED1C000A for ; Tue, 19 Sep 2023 19:02:24 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=miRqSbZF; spf=pass (imf21.hostedemail.com: domain of 3QPAJZQ0KCHcVsZgmVnhpnnZibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--axelrasmussen.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3QPAJZQ0KCHcVsZgmVnhpnnZibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--axelrasmussen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150144; a=rsa-sha256; cv=none; b=Vkk5+HPNdozMdsTwEZryDFYsn+K4ymJ848mXgC2vgG2dq/TZJbaqvudcj9vnEFZtFCUKQG KBGnkQtsA9Fki/j4a7EplzXVnlyPe9LoieoZux1KKdTJFnLBQjy2ySFPDtK3H+Lx6CA+6k 4Mq2vpXPgeYg0teF+xFmYEgiTZSQHvA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=miRqSbZF; spf=pass (imf21.hostedemail.com: domain of 3QPAJZQ0KCHcVsZgmVnhpnnZibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--axelrasmussen.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3QPAJZQ0KCHcVsZgmVnhpnnZibjjbgZ.Xjhgdips-hhfqVXf.jmb@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=1695150144; 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=yByc+t8MiUd/FlhKNAv002747b3UkcfIteNK5wC98N0=; b=o41gc5BZGtwufl+6u6myzea99MQ6ygf97voW7iv4mptgNb8ZHiinOoKVqRQLoaoEHw0BhU BgOxO4THTkhRrJFeWva5kUJ608a4RacTUd8cmysJXb2a0uZLROjjQtnM4Uh5Y49BLPnuVo K32/6sEsbc5lnO4WwVdGs6H12Fv4dGs= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-59beea5ce93so2663497b3.0 for ; Tue, 19 Sep 2023 12:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150144; x=1695754944; 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=yByc+t8MiUd/FlhKNAv002747b3UkcfIteNK5wC98N0=; b=miRqSbZF83uXZXHvw2Vx57LlCxSLL74UsDOVCJWO/JfCRLGSbrST/Kw78fQrQ9r1MZ gfpVdzYQj6N0yWLTM4jXbegKOnyy75I9uJ9rXsT6XIx2RXpMTMyWuIOgyg0Q1rofKtn5 end0x8amKHozR/4Qd9DzrpLTn3+qct/Cyz2wqOnGRbs99zZlCu1UOmvC0sV7PMMKPgOz w28V5XOJROXtZ0EODRTgwmfnmFE3qK+0m72t3rT04E3sPc1xJ3YgA4Ew0isjLtWPKxiz UMM6qgCREoNFFFH3fb3vPvXrUUg0P2aYs4/oWPPXSm+CfUyUBpukxR5+prPccY9CFVoD G64Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150144; x=1695754944; 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=yByc+t8MiUd/FlhKNAv002747b3UkcfIteNK5wC98N0=; b=smAi7U5S0wO+wr0Mh1hW7XDlb1AZqgRG4Mk7bFFoB7MLeGlm2HaJVnYkweNBq8Kll0 GW0+EP9XnbC+oiiXcoBkcx5wTKT54hw2y535P5VoxiSsWVHsJ/4znev9pvlYIXmK1sdM vTc9F39LJcyEfFdOPpb3oxUD5e19CL/EIn+Zb6g6GuXSYX+1RO/EpNHnN/aJfsYjy5gE fbB72uViVdrlaDJxhBy6ScznFuuzWnWQx67qBGfKn/BJ7RaN4WP0tZZqvkg15g43AYsI V7EqY6NDMqvPmUgyUpsIGRVJYVp7Bo6f4Jt/NGDY1huuDDXJ0MGy6lPe3YrMbzeRLwFp z7Sw== X-Gm-Message-State: AOJu0YwAVhj6/IIprT8OESfJiq74QzPHlZnR0CrX1NJqqFP/i/e+JgY3 ktzsTO9VtOKyuJiAb7qrMiN6EqV0lQMy6saYl78M X-Google-Smtp-Source: AGHT+IFoQhXcjpZz0tNIspX2HizUbJrBHJVvEou6jQsnzb8YUr35yLjePVG0NBfJ9xY4w5XR/FlOcKZy982n0Y9YdDP2 X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a05:690c:d8f:b0:59b:5a5b:3a91 with SMTP id da15-20020a05690c0d8f00b0059b5a5b3a91mr113072ywb.2.1695150144075; Tue, 19 Sep 2023 12:02:24 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:01 -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-6-axelrasmussen@google.com> Subject: [PATCH 05/10] ioctl_userfaultfd.2: describe two-step feature handshake 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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CDBED1C000A X-Stat-Signature: rkpbezg8jqise5cuydfdzhacdqtuzszx X-Rspam-User: X-HE-Tag: 1695150144-425323 X-HE-Meta: U2FsdGVkX19YslEE4WWWeqhUks8rzfVrroEdLLIvbkDJMdPR4eR9arD8A4peshTVy5WN9aanN4qEjmS9a8L5W7WHglmQH1hYZgdu/+l8RsW0RuA57tQQsVIC31ioKMuPKzLvVGckDW09BSqjyGDao06iA7wpV7xilKfBLABUnIA5HRfkMxzltQX3+aDFElSiuCkowoL0XEc1rZMUbbS7BirjG+rK9a25KhRhxghQjZMcKlNL4xIP42WT5vDaT4TkTMWiKMB9a/suU+ZPsUPFIS4IQ8RWqOpMIPgS+lP9L4/VWx0izeQikIz3XW+/Q84Gzuu2Bngn3DAStSYubYuJ0/HmMSr5WAUK/NTBI24B5oGo6REZzGVky5zZxAWjisFQ7rJ04IMwbvKgiKojSzOHCwsfqC393xwiC7sJWBdccSCxPLoJ8QW2rZE/uwDDWBqmHizHWIcuaeWxjRnp9EQ1M9wbdWFPAey9HtJnjdzeTpW00Z7+f03LL+wLdcm/g5OsKYSkigRvQiBbliYq7Ii6qlOywO0epSq8DMwxPxYv+gz916wi6G1LF7rmM79RS+amnlaUa+XlJyRc/oXHA++7nMZtw25C7h+AkFXE6e4h5kfcmabZSVn/RMd1nBPpSFEACCUOiT0lhi1livJHZOOVLDySsYHxZ4C75BJLDSX4dlxGfL32Ub8vOulUqDtMZLAhdhSex8mf+W27R6YUxOadN8zFBxz4LRInj4XUQiUP6ujpIDPc3d3WlY6ZKuU8y8tgQQ0V7wLd2MW8Cs5NcNfC9LwwuP9K58bORJI8a9FQtBmxyrgRUZ3enK2oT7EZnvg/3GhlzIJDPS0YDXuVYfoP98DSP2gkPkugE21kZ6YM8/oHYsvRZfUgD9SyhJibgvImTQ2yyArdejyvo+ybs5OJERa3MVTLWdtBwPWw2O9VvVlnBl+kXLU/d1EmH4X+/NCWbeSuFHJb/xlERkpUDrl oKjIkwto VQxb45D+dwINIJzR9UbSSq0bvkpYIffwgviZDJ/fg4V/A8gfekL3u/Wk42PReoi/sQwkW/uMaP0Dozm0u41kH1u62AQmBtzfMwV0RCNj39YE5gTSZryp2RcYjd2VEfLNSZI4vKkhNl6xnKNSJqJWYBRy7q+tVRAgj4Kd+OaOaUt9UMXnLGS7CLVC0QyKkZVII9ygW7bA3VXUIOiKkvEiiOxiVMCFjQNqzgufu2PXtaQOAkWBIVGBnf94jio9za9h4i9m6/0mpxY+g8TYQXyaW+9S3TW++uWXDcw30tNAzdUd/r2I7GufoK3nGQ02vDtPn3lXg+1Lr6YUSmPTStGjFUlVMmzWzzGagOfZlEEqPJ8jj6u3FrwKZ8v9CcDPbrcSAlJHzO5u0wgr7ugWXvJjahiF/PAuMBcCZKU+f8wAgTytWYLt9M0A4Ur9aTOS3ygmrsCxtK17NjfZKM2fphS3or0HyjwJPor26smT4Znui2pigzGwRnfPr7FeANpr5fRpoNSGtd+8Du8z2LtkFabMCdgm2d1QP87KD3GbuYCo+xe69CmKfL4yEW4QZ6n7Xlm7CTYYL9ORmIFcAGkJirehdZptQDVSQKiF3j7HgXduZQOgLc1wSK0uE+IyRccPiJwKB5fHQuZPyqEYI67wCQcbfTf6dXmTgLvPEBpkI3Xw3pEhnl6gudqIK3egUKhRI4zCKPCjSTBtnz36mra4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.080998, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Fully describe how UFFDIO_API can be used to perform a two-step feature handshake, and also note the case where this isn't necessary (programs which don't depend on any extra features). This lets us clean up an old FIXME asking for this to be described. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/ioctl_userfaultfd.2 | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index 339adf8fe..e91a1dfc8 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -83,7 +83,6 @@ struct uffdio_api { The .I api field denotes the API version requested by the application. -.PP The kernel verifies that it can support the requested API version, and sets the .I features @@ -93,6 +92,25 @@ fields to bit masks representing all the available features and the generic .BR ioctl (2) operations available. .PP +After Linux 4.11, +applications should use the +.I features +field to perform a two-step handshake. +First, +.BR UFFDIO_API +is called with the +.I features +field set to zero. +The kernel responsds by setting all supported feature bits. +.PP +Applications which do not require any specific features +can begin using the userfaultfd immediately. +Applications which do need specific features +should call +.BR UFFDIO_API +again with a subset of the reported feature bits set +to enable those features. +.PP Before Linux 4.11, the .I features field must be initialized to zero before the call to @@ -102,24 +120,11 @@ and zero (i.e., no feature bits) is placed in the field by the kernel upon return from .BR ioctl (2). .PP -Starting from Linux 4.11, the -.I features -field can be used to ask whether particular features are supported -and explicitly enable userfaultfd features that are disabled by default. -The kernel always reports all the available features in the -.I features -field. -.PP -To enable userfaultfd features the application should set -a bit corresponding to each feature it wants to enable in the -.I features -field. -If the kernel supports all the requested features it will enable them. -Otherwise it will zero out the returned +If the application sets unsupported feature bits, +the kernel will zero out the returned .I uffdio_api structure and return .BR EINVAL . -.\" FIXME add more details about feature negotiation and enablement .PP The following feature bits may be set: .TP From patchwork Tue Sep 19 19:02:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13391775 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 9F1DDCE79AB for ; Tue, 19 Sep 2023 19:02:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D4EC6B00BC; Tue, 19 Sep 2023 15:02:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 336216B00BD; Tue, 19 Sep 2023 15:02:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13A2D6B00BE; Tue, 19 Sep 2023 15:02:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id F25B46B00BC for ; Tue, 19 Sep 2023 15:02:28 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B024EC0DFC for ; Tue, 19 Sep 2023 19:02:28 +0000 (UTC) X-FDA: 81254267976.04.C29B491 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf04.hostedemail.com (Postfix) with ESMTP id BB93F40002 for ; Tue, 19 Sep 2023 19:02:26 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jzRoDWQV; spf=pass (imf04.hostedemail.com: domain of 3QfAJZQ0KCHgWtahnWoiqooajckkcha.Ykihejqt-iigrWYg.knc@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3QfAJZQ0KCHgWtahnWoiqooajckkcha.Ykihejqt-iigrWYg.knc@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=1695150146; 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=NEXa90h/68GUsd6orjyORkWHy9a7mT47IoYQaYRrJqY=; b=NNhLm0YijYCdzB6F5ISFh5ZxjUofGPCQIJoyueMLRzRh9PZ4j99WlKY5vOv9JnWoGMLJx8 g4FAJSiAIMXIQpL0Ljv6Ioz6P9UrJgxeKf/IXqaZZGXZQ0z+L1rrjTCWaNCATtogtnACi6 6fxiSG8Xjxh7lRsAjq5XvgeLIfNClb0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150146; a=rsa-sha256; cv=none; b=aBlrtMS/QlqMmf6wgcLBgNwMDIBz+CrEWY7NG4qC1Tra4zrob1oSO7jKBl5MXsNRPjoFKa Bz6pcj22e4l66LlASZnbRzYP+A52CxbNLOxMvWcaVRwBp4ynawrvav1BOgoGXY6QZzVTlD FqWHMu8Ihfli25WU6cLyoN8wRCe+W5I= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jzRoDWQV; spf=pass (imf04.hostedemail.com: domain of 3QfAJZQ0KCHgWtahnWoiqooajckkcha.Ykihejqt-iigrWYg.knc@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3QfAJZQ0KCHgWtahnWoiqooajckkcha.Ykihejqt-iigrWYg.knc@flex--axelrasmussen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d814634fe4bso6613708276.1 for ; Tue, 19 Sep 2023 12:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150146; x=1695754946; 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=NEXa90h/68GUsd6orjyORkWHy9a7mT47IoYQaYRrJqY=; b=jzRoDWQVkHkDogMwEs0Tl4z8JwkiYyUAXvqe9n3jmEgX2gt17otAut4U3OML+zhSsZ yC9jjBHenmXyaNA6pW1trrZyEOXV5baxzNTFYQP73jW9iREPMb3jrF1tIZtMwZMXZLfM Q/Op2zZlnI+1P/FbrYQ4wlNKwtnx8hv/gRw4+FK6oY6RkdnjYnCJixTu9/XEf5a+3Si3 n8zkpep9QlShLszbSf1IveY6pgSUyN+7exgnqHuuyWevdYuN9nKIJ4/4vBvvRus9tbdx +l7eFDWhBlArVLKswWfbgJSvXe8dnbbe5804nPrVLMcJGP+6lqUjblfDGHF2Ty9YVCJT 0tmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150146; x=1695754946; 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=NEXa90h/68GUsd6orjyORkWHy9a7mT47IoYQaYRrJqY=; b=UKaU5aRctLVT5YpkBMvN7bM8kALk8VXYIfAvDifBJhKEu2mrdwxVzOkvX/q2eGYYsm qW41pByLo1lHBaos9PtsTl8nf/k+WfKF167I5C+02+e5K/+/2L4TPXT01fOmMWdhQW0V Ly1TngsHt+oipgqNO9ic2PEhn4U9DkO9RCH290sdrcsTxONbY7O1P0FVxm4KJHW+NJYc 3VxFeVMWsyUqZmwGH029eQ70hyt/H172vS1++YpvsqTkWDUMrHBTeQqiRnZUoJKyWhVe Pxp+jkhNw4xm6ZH72+Da/c7KW7A8xmpQyxQbcORZeFXpL1HHHgFlJS0SrtbXUELduAKR d7gA== X-Gm-Message-State: AOJu0YyvQ/+Maimrj6RJibfXtIO5hYHjdzCjTz2+Nh+4qZAC8GEmnvvh iMsCP562RJ714lopu8shHd7WMJbutaLyVjpHbSv/ X-Google-Smtp-Source: AGHT+IFCWTBj+STf+JQII+aukLsaaJkmL6LUdqEggx41JkN/znYtNCrIQg6lN+ju+ooY+qcE8V78UIKtBAjD3/9uU5Cw X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a25:6802:0:b0:d7b:3917:4606 with SMTP id d2-20020a256802000000b00d7b39174606mr6912ybc.11.1695150145976; Tue, 19 Sep 2023 12:02:25 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:02 -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-7-axelrasmussen@google.com> Subject: [PATCH 06/10] ioctl_userfaultfd.2: describe missing UFFDIO_API feature flags 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-Rspamd-Queue-Id: BB93F40002 X-Rspam-User: X-Stat-Signature: shc1jxwhqwf1kyjdhcxqhqubh56odiny X-Rspamd-Server: rspam03 X-HE-Tag: 1695150146-343546 X-HE-Meta: U2FsdGVkX1/I2odIQnu3/+TQHvDmBmIBCWo8REE5USMJeMCxpwpHToHReDVqggLE9+kGWQUOeQpkPLEa8BVMDTxt8exKd1kKBAIN2bwMWuo+fY90X8y08Yd8qk+mvag0NZm8ALS06s9nxx2lAs/lBTGQVFgbU9Ee9UdYsiZWQFIHa6I9swrEo2LjM8dxmqkLCUHUt/QcqphFc41KYTjDU5otKMj5fTusPho9VaS5wijMCL4pwiEpT4C6+U/kT5srv9c2yBPuNih2GSrU/DUl1hkCUl2EtT08cd6hfSTXa4252yYyxvAwl0En1mB7vbYSupmJxIYwNHtULZdvN1jbD9JVwtiH2vrrY5A7mvGYzqlqXAet7603xy8qpr9Gg7s4ZyUPJYwhvk2wIRUOF8+ehqTmdasSZyeGe1yRdVeJO2HkmHUpbwghw2LPz3cSCSd9KLmHKcLm8D/Xhs3OgbqvnrtzN9ImxyhP7iRKA6Wu6YL1oKgOl/nNhFSaaM0ENSW9wIeTxAwurBTnDv2B456cSB3EkAvJvNwPyc52sCrnf4ZTcURoEtwfJGaKF5gU6H/0IzKIHb0zzPzbqyp0NgaWcfzvjFDR2NfoR8mcrKquBvTni4/rCBTSxJfWJFlK8j1mco/i7r2+x/smE9wht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1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Several new features have been added to the kernel recently, and the man page wasn't updated to describe these new features. So, add in descriptions of any missing features. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/ioctl_userfaultfd.2 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index e91a1dfc8..53b1f473f 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -204,6 +204,13 @@ If this feature bit is set, .I uffd_msg.pagefault.feat.ptid will be set to the faulted thread ID for each page-fault message. .TP +.BR UFFD_FEATURE_PAGEFAULT_FLAG_WP " (since Linux 5.10)" +If this feature bit is set, +userfaultfd supports write-protect faults +for anonymous memory. +(Note that shmem / hugetlbfs support +is indicated by a separate feature.) +.TP .BR UFFD_FEATURE_MINOR_HUGETLBFS " (since Linux 5.13)" If this feature bit is set, the kernel supports registering userfaultfd ranges @@ -221,6 +228,22 @@ will be set to the exact page-fault address that was reported by the hardware, and will not mask the offset within the page. Note that old Linux versions might indicate the exact address as well, even though the feature bit is not set. +.TP +.BR UFFD_FEATURE_WP_HUGETLBFS_SHMEM " (since Linux 5.19)" +If this feature bit is set, +userfaultfd supports write-protect faults +for hugetlbfs and shmem / tmpfs memory. +.TP +.BR UFFD_FEATURE_WP_UNPOPULATED " (since Linux 6.4)" +If this feature bit is set, +the kernel will handle anonymous memory the same way as file memory, +by allowing the user to write-protect unpopulated ptes. +.TP +.BR UFFD_FEATURE_POISON " (since Linux 6.6)" +If this feature bit is set, +the kernel supports resolving faults with the +.B UFFDIO_POISON +ioctl. .PP The returned .I ioctls From patchwork Tue Sep 19 19:02:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13391776 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 5ADF0CE79AB for ; Tue, 19 Sep 2023 19:02:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0D416B00BD; Tue, 19 Sep 2023 15:02:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBD1C6B00BE; Tue, 19 Sep 2023 15:02:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0FA96B00BF; Tue, 19 Sep 2023 15:02:31 -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 ACE036B00BD for ; Tue, 19 Sep 2023 15:02:31 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 70AA31A0557 for ; Tue, 19 Sep 2023 19:02:31 +0000 (UTC) X-FDA: 81254268102.14.9B5C425 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf13.hostedemail.com (Postfix) with ESMTP id BAAAB2000D for ; Tue, 19 Sep 2023 19:02:28 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Ls/yNoeT"; spf=pass (imf13.hostedemail.com: domain of 3Q_AJZQ0KCHoYvcjpYqksqqclemmejc.amkjglsv-kkitYai.mpe@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3Q_AJZQ0KCHoYvcjpYqksqqclemmejc.amkjglsv-kkitYai.mpe@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=1695150148; 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=dATpzHjDHVSfxWhEgldjVmKuWzgWmKZlkhKuoIGibHA=; b=CrFX2/6lVX1Lkl0usaQDYgu9xjMtEFpA2TNOA7Y3iPJChL7OXWrWrgVf6a+Jsu1kP5mueP vtdD8wT9+qk+hPe/Ir+CY9DmScfGqQidBj/x39fg/dI04mqOLnJ9X4ATbW8M0vT7JX1N4C T7eD4i62/7nbH95tOaGbFMo/VTEGJM4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150148; a=rsa-sha256; cv=none; b=sUwPdgQCdorub3QewVCIDahRTxdFqf6GQFNOmA4Q9zeH9ysh8mfvtZj+8VUfzazaxiJvcp WIpdB2d3pOHQc7YZ5UPMQM691GvibXGqS9fPyfg6py3PktfQx+oqjXWF60kX7M0rkyKZav NwnHWGIvvdTliggUhs97sK1yYj6yMqw= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Ls/yNoeT"; spf=pass (imf13.hostedemail.com: domain of 3Q_AJZQ0KCHoYvcjpYqksqqclemmejc.amkjglsv-kkitYai.mpe@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3Q_AJZQ0KCHoYvcjpYqksqqclemmejc.amkjglsv-kkitYai.mpe@flex--axelrasmussen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d8191a1d5acso6227242276.1 for ; Tue, 19 Sep 2023 12:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150148; x=1695754948; 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=dATpzHjDHVSfxWhEgldjVmKuWzgWmKZlkhKuoIGibHA=; b=Ls/yNoeTtdTsB3rmasXi16pO/PoJU7NVEQ8JkrbZGsbbbW4U6k4hk8rNeHUXn1w9LR MCU1f9MNESSn7gua7k4qst0GAd5fZ08RvF9HyuVvprfTRNQHAJ4fQ2giF8+tlk2mFnY6 caqi7o5wLXHRq/idwf5qeovJfTUgfYRukVfXZBOGQYaH/IYCEyBNoERch78JfKWLN4+0 W/RMPG3OGSHh8k0I7ek5PyUZIWZmP0ceXwtvE1v40YzRsfH6/k4HgMSzn5dABwEp5Ajm byBJTwrBZdXJAZ4IeW2foualM8TlNy7XkSNxyPWS2JjxxOPAN8HZWP0jzouo3FSzNZ1X +tew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150148; x=1695754948; 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=dATpzHjDHVSfxWhEgldjVmKuWzgWmKZlkhKuoIGibHA=; b=ZfYf73ZgXYNPeRFaaVSVCVCsD+sWSOG0J4XiZFtXiPXC8BT3+uHipnlUH+T5Krhcan Af2lZ4I5wg4aBtC+Y+RUkjTfYeiuuv3VOU9ErlmmitW2h5n0V13iGE24fEC+tc8/JwlW 6poVAkpBFpgLO0pQ5hNTLcCeJtpi3SvBOj9LYOIq96Ymkfkg8c9rz6ev2ysKnTHUr9AG zrBpleE9hDrJ5cIFZKbfeIvw0RodOfEpW90kk9SJE30O73OQjJj+0Iyht5RLSW2kyuBZ dWgiAHRpkbBv/9MBqaW9OSZWPGOLoIxLeaMhLGhpG56Aq6zVEi7Ujw99lmRx3vsUPG/M DLOA== X-Gm-Message-State: AOJu0YxxeOBsVUyJ2P26g12NeRZtSUHvUoZd3ygs0ZnSIDoaZaHUNk8T 4fCtGc80wC1z24bkAdZjhQCFIjYIaiRPgh/ApeLj X-Google-Smtp-Source: AGHT+IF45ElZoDnMndnZOu1lqkwCh0nmxIEmNv3ls7RqY7t81Fhtx/Bi4C+mC54hjZ/x4utF8vcipSUw1i7E3maljlSH X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:1802:b0:d77:8641:670c with SMTP id cf2-20020a056902180200b00d778641670cmr8426ybb.10.1695150147917; Tue, 19 Sep 2023 12:02:27 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:03 -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-8-axelrasmussen@google.com> Subject: [PATCH 07/10] ioctl_userfaultfd.2: correct and update UFFDIO_API ioctl error codes 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-Rspamd-Queue-Id: BAAAB2000D X-Rspam-User: X-Stat-Signature: zc8pxo4z4cxkgbdhisgmx6m7mo3aypbd X-Rspamd-Server: rspam03 X-HE-Tag: 1695150148-80428 X-HE-Meta: U2FsdGVkX1+142PNoBvCjkUkr2UUfxZS+rdcRU3sZ8ZOMOLoO4xCQby+fRYMsoe2BYzDqhxGahTXtrnMOBfuWjR9RMQD+IFakciGHD97ciuqzLxRcOwh0Kujtw2CwKGeQZ/8YJgd8G40mWoa7r+TADOApGa6tV3YYEvrsxHWyx1XiN/5SlNwnREtgU38rFGUCR16R5hqzZxI8kC10JyX3wTTTeztnNwb2JEqNqZZeWUUut+yYl0YE5ScuOuZBdu5mVq81rLhfJALCPAg4CwFdlNqy8k9IhcXTbGG4hgwhhQUcetvSNCSttf/Pm7DEBxpo9ol+0rfljqy8g+PbYDJU/SibCCJPQyPrrzk2gPJiGRoz47smnzuBZPVk3llQX/WpncMYWX1Y54QkkrD4yJ/iADP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RWAGTfy5bqB4d0GikeoP4qdvbdYYvJdPqx4hxi4EHdTmnJiUKTYOwelOurqs/lGKsSTlsThYq6MnF0Es1wzWYPXhUkwnO8t6RDw+YOnSVhV21tLXn4ct9NecbpqAOIH2hb2jjOVSgHQHKRs5hrHvQ5NkUB+azW1qKiKYiJ6RO31WiGDiLup0oz2NeL1Fi3i2zAlIoxen1YnL7yb9iaI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.069453, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: First, it is not correct that repeated UFFDIO_API calls result in EINVAL. This is true *if both calls enable features*, but in the case where we're doing a two-step feature detection handshake, the kernel explicitly expects 2 calls (one with no features set). So, correct this description. Then, some new error cases have been added to the kernel recently, and the man page wasn't updated to note these. So, add in descriptions of these new error cases. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/ioctl_userfaultfd.2 | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index 53b1f473f..1aa9654be 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -280,17 +280,31 @@ refers to an address that is outside the calling process's accessible address space. .TP .B EINVAL -The userfaultfd has already been enabled by a previous -.B UFFDIO_API -operation. -.TP -.B EINVAL The API version requested in the .I api field is not supported by this kernel, or the .I features field passed to the kernel includes feature bits that are not supported by the current kernel version. +.TP +.B EPERM +The +.B UFFD_FEATURE_EVENT_FORK +feature was enabled, +but the calling process doesn't have the +.B CAP_SYS_PTRACE +capability. +.TP +.B EINVAL +A previous +.B UFFDIO_API +call already enabled one or more features for this userfaultfd. +Calling +.B UFFDIO_API +twice, +the first time with no features set, +is explicitly allowed +as per the two-step feature detection handshake. .\" FIXME In the above error case, the returned 'uffdio_api' structure is .\" zeroed out. Why is this done? This should be explained in the manual page. .\" From patchwork Tue Sep 19 19:02:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13391777 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 3B6A8CE79AC for ; Tue, 19 Sep 2023 19:02:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADB886B00BF; Tue, 19 Sep 2023 15:02:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A157B6B00C0; Tue, 19 Sep 2023 15:02:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 890586B00C1; Tue, 19 Sep 2023 15:02:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 740366B00BF for ; Tue, 19 Sep 2023 15:02:32 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 491E3C0DFF for ; Tue, 19 Sep 2023 19:02:32 +0000 (UTC) X-FDA: 81254268144.04.6DAC985 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf30.hostedemail.com (Postfix) with ESMTP id 639DB80036 for ; Tue, 19 Sep 2023 19:02:30 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lfC1rVxa; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3RfAJZQ0KCHwf2jqwfxrzxxjslttlqj.htrqnsz2-rrp0fhp.twl@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3RfAJZQ0KCHwf2jqwfxrzxxjslttlqj.htrqnsz2-rrp0fhp.twl@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695150150; 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=5/ZA4nlbby3TSOXQeGLhY3RgtFATqmihyuOhsYNku5o=; b=VAgUSJ0W7g6JSVgzRf9Y5deU3dj8ut5k7LK6V6i7fwhH3YPTKKXjFeFiYV3Z7HT8Yzc0mk BUvSVVSEnpeEju8vyl7Ogayv/l6h89fNLv5+q9FVukYUij28mEGAeGzbqpGxJ9X3CD5kD3 Y/Dtb3lN4sQaajxqCXg88jCOMic8+sE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lfC1rVxa; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3RfAJZQ0KCHwf2jqwfxrzxxjslttlqj.htrqnsz2-rrp0fhp.twl@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3RfAJZQ0KCHwf2jqwfxrzxxjslttlqj.htrqnsz2-rrp0fhp.twl@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150150; a=rsa-sha256; cv=none; b=V3cQjg/8VXi4HZUBT7+ppkYBR2sBo4PNQe2AKUkVbkc94KhPa4glTB10Gh7FJOdCtWMS6d IJj4kZd7gbJJPdsVQTB1t6Ac/T1r/gb7wvoVNUhdEb3ArSRFQ7yWdn4c/EK8rtrYDT3P2w MzyRDJAHlR1ed6uQOWNds9mbAdiZrOY= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-59b6a51f360so68228307b3.1 for ; Tue, 19 Sep 2023 12:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150149; x=1695754949; 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=5/ZA4nlbby3TSOXQeGLhY3RgtFATqmihyuOhsYNku5o=; b=lfC1rVxaISsaYOJ+z1L9w1IYo9FtOXnQKKVhgv2fiqcKfim/yK+9kYhOmx0RbAxVrP iIqrmxjibuQ7zYBMVYB1YNkUpy1UIwa6KNPHQYE3ZvXV9uDEnrxuDYRHwV+Mw2AlEiZg hfR/y/5DKXQrPY8nn0zEFYfMP+nrXoOAehGv7cFI/ZnZZLDVotgyL5fofT3se71yPFSO h84kKbZpdwaat/ndUDtFlPRTsOKqseWVy8GVdFItP9o15yscnUxz8WlbVbRqF6Em1Tdm WC2orPjhilxUNGkNVBKT8S7It48DQBth5lZOZmNwBIQNdWSnSdpgJSUdw7ADnxe/kQnU WIEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150149; x=1695754949; 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=5/ZA4nlbby3TSOXQeGLhY3RgtFATqmihyuOhsYNku5o=; b=TmwAdLXG3S8yJ24oT5hCrPiqeaH6Wo9NGmPSOpf7YUvBcoqoTIsGmWrkSB77tLeV9L GgiUB8BJuKKJyVLsUH3V4NYBhxAyjtxC0d0qJ70nH6x2HhfCbX8EPpMiRUjKsSWCFMFm 6JowwL1HHKKn4YsRhAuHMgscC8aT0agc2fYDjUApgS/Fg0+H71P+ewdtjSsgB48zi/Ex vEaqKTEEjetY7hDP1hn/5XKk+9EVm84HnjGxupy/zuwLAQIDkKqrvo2ZkMLCbflhxYxX VTCC/uIXzqVhAbAN7Ud9/uE5WvGK9HCEylqwnEIM92L4Qa6wLGSPbq5XqCTIBWqWqIRl 2/XQ== X-Gm-Message-State: AOJu0YxKVEJZAXj3jX5kXcGKHQ/1foyeekh/EicXMzDYDM/yoyqB+kfk CdH0GIoAc4QWiTFllsdVCgdLOLumAps+kQI5oM+P X-Google-Smtp-Source: AGHT+IG8eaTU7hxdY5mgOyKHs6IeTw13//TND4ha10SPnops/i3jjzvDx1XteSAjjRbmIb2msTY9QDo9nytSfSAHrvmQ X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:1805:b0:d77:f7c3:37db with SMTP id cf5-20020a056902180500b00d77f7c337dbmr7876ybb.8.1695150149582; Tue, 19 Sep 2023 12:02:29 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:04 -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-9-axelrasmussen@google.com> Subject: [PATCH 08/10] ioctl_userfaultfd.2: clarify the state of the uffdio_api structure on error 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-Rspamd-Queue-Id: 639DB80036 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: a6uarcp5ihgtn5zuig5dyxgy8bjq9re8 X-HE-Tag: 1695150150-290460 X-HE-Meta: U2FsdGVkX1+fl2cI8GfDxKh27NcN26L+78ynvAYx+wXtoza7QPfIxo/d2GcC8dOGsF+5UjBe1SlCFCVoKgXChT+jwl3t00UWOS7l+oVOH2XV1he+lBLdeM2uzwAwa3LBYEmnDxKo6lFTjVmAhoUyI6dF2zZbkyuzZGZv0XqZK8mRNBfcaceCx4GGmUHBTmH0WIXXPoO85oZn+TFkzfrnkWQAksD4AJZe1SJbex8cqOZ6vFYxekQIWv06fj2woQOWPf8unUdEzXKeO25aWSNGH9l6p5O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GxpqB9tYMc/+/zKMeM/+jG7+C7RwjOa12IH8n/Qi5scnQ12IZAgtskANiUB1zkoKNc9i3Cn45SYojWCQ3/phNEgXC5dRa4e7bvpswn+AjG6o8FTSyhx+/JvvUdK2dY5rvZbrhfSPH+5PX6rg9wxrOfs5IjmxRC0Oc3q4sfGKCuqrZj8jId6+PBYT/oZXE99Rvd3+GoY7XSHhdMY9sl5mCSrLe4WQxwNmyZGIAgitwpMtSVSwdJ6hHvaggdyXtWcoKYs4Eg40/ev4dRR6+1ujjMPPUJrE0q5JOZ0une8niJmYmdr6VzgXZcJegDDp4O1Rxo/GHBRD X-Bogosity: Ham, tests=bogofilter, spamicity=0.244157, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The old FIXME noted that the zeroing was done to differentiate the two EINVAL cases. It's possible something like this was true historically, but in current Linux we zero it in *both* EINVAL cases, so this is at least no longer true. After reading the code, I can't determine any clear reason why we zero it in some cases but not in others. So, some simple advice we can give userspace is: if an error occurs, treat the contents of the structure as unspecified. Just re-initialize it before retrying UFFDIO_API again. Signed-off-by: Axel Rasmussen Reviewed-by: Mike Rapoport (IBM) --- man2/ioctl_userfaultfd.2 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index 1aa9654be..29dca1f6b 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -272,6 +272,14 @@ operation returns 0 on success. On error, \-1 is returned and .I errno is set to indicate the error. +If an error occurs, +the kernel may zero the provided +.I uffdio_api +structure. +The caller should treat its contents as unspecified, +and reinitialize it before re-attempting another +.B UFFDIO_API +call. Possible errors include: .TP .B EFAULT @@ -305,14 +313,6 @@ twice, the first time with no features set, is explicitly allowed as per the two-step feature detection handshake. -.\" FIXME In the above error case, the returned 'uffdio_api' structure is -.\" zeroed out. Why is this done? This should be explained in the manual page. -.\" -.\" Mike Rapoport: -.\" In my understanding the uffdio_api -.\" structure is zeroed to allow the caller -.\" to distinguish the reasons for -EINVAL. -.\" .SS UFFDIO_REGISTER (Since Linux 4.3.) Register a memory address range with the userfaultfd object. From patchwork Tue Sep 19 19:02:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13391778 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 343D7CE79A9 for ; Tue, 19 Sep 2023 19:02:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9F7D6B00C1; Tue, 19 Sep 2023 15:02:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B07D26B00C2; Tue, 19 Sep 2023 15:02:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99FC46B00C3; Tue, 19 Sep 2023 15:02:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7E5686B00C1 for ; Tue, 19 Sep 2023 15:02:34 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 41033140DB6 for ; Tue, 19 Sep 2023 19:02:34 +0000 (UTC) X-FDA: 81254268228.04.9D20193 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf02.hostedemail.com (Postfix) with ESMTP id 37D2780035 for ; Tue, 19 Sep 2023 19:02:32 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ww97wj1V; spf=pass (imf02.hostedemail.com: domain of 3R_AJZQ0KCH4czgntcuowuugpiqqing.eqonkpwz-oomxcem.qti@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3R_AJZQ0KCH4czgntcuowuugpiqqing.eqonkpwz-oomxcem.qti@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=1695150152; 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=B/mBNxS046NndSUiuzLhVh8+as48kp1msWTNOB3shRo=; b=zCbalQJge6Ir4DWXrTIYq4xZtRP5XOCV7OJcir7/iwJ4YhlGRvVZxT3BcUJbNZ/id8GQCD TxBowFTQsiPL/a2g9uzDAEdLEtszVXcIk5hiKzOqoUB+fL+Tv/HWh0i80GFskFj7sbxbQQ WD58//ld0Wp3A640cCjWpDVSw4qs+lw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150152; a=rsa-sha256; cv=none; b=K0ZPV8UJMZUXQUqYJYvO70M3X1HbI8vZM7EyyiW8F62X3IRZVhfuyu7s7mM9EUgsBY0j8B PMD4s5QngdJNZVt6wrlAOcskvDUvUKdocWM7VagYygS9EVf4WQSZCtq3SSMbtw6JQdAMHF 07i6Xz6TridKJiBqbpebiDyfzElhSNA= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ww97wj1V; spf=pass (imf02.hostedemail.com: domain of 3R_AJZQ0KCH4czgntcuowuugpiqqing.eqonkpwz-oomxcem.qti@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3R_AJZQ0KCH4czgntcuowuugpiqqing.eqonkpwz-oomxcem.qti@flex--axelrasmussen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-59eea906b40so1362747b3.0 for ; Tue, 19 Sep 2023 12:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150151; x=1695754951; 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=B/mBNxS046NndSUiuzLhVh8+as48kp1msWTNOB3shRo=; b=ww97wj1VNlNpLwc99GsMJRMrlcx2BrR/EuDN+lXl24SlHxkcSDguc5bw/q9zonM3/J fqOFU1YfznfrAP4Xe4zCgpxhVW67uUcy3nX3wA6uSdi4wILwSKT/M9eLN2aMvVfgyM7a 7JRqVk5AppVwNTIJzwigvJP+AFoTMD+4O4O9lHpFQ3xARoPhW0ROXfv11wwqhucYVbJJ RSuf9tPXgpkz//2Ab325n0K2cZqWnnRsc5Ql36h4tdVQ6m27FILYRj+gajvK0ol1gC7B C49aW2OeyU8kdRmKi8yNCrO0DzODgA64pnBn6p5oc9Al3j/zB8H/D9hfTVOGoBhML3jW 8PDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150151; x=1695754951; 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=B/mBNxS046NndSUiuzLhVh8+as48kp1msWTNOB3shRo=; b=bK3a24zaWGoUarIPMFEj55/Tg/wrAxJEoPksKNQki5MTKa3g6AhOqsXrVBw3elXLoK 8AjbyotTz4jWBeAemdNSleQIL54uM3mKczHGVhbXDqM+PLCTBLaciOZVs3t6Zo1ExovC IiFSum9P+zV1U670UMTCpEcDxuDeLQjfBYGaOrnwg+l4VeA/EsDWi7WdOvPTRySQAL4E 6t/cM02LELy42sQAmAW/imNkxqCogLh9DAhWA5tFTbH6wFPcAnaRDrnG5Y9t9D8/LS/b 75QPer3ZN8bg3dYiXeDu+A2tMGJycYu/jyiPiQwxDPWwt/1OzPJ0b06B2v1b1IaTDg5e G4og== X-Gm-Message-State: AOJu0Yzv8ijHA3sdOe+2+BAa2A++2hZy2wOSvOJdcSyeyITB9a8YorfI Ess+8ApdTgzfrPMup4C1gbWsDnCd7uL/gBipUl9h X-Google-Smtp-Source: AGHT+IH7a8feDFG+W7LkkHL8xBQ33JOSLVkr8l24lseUZrRLYRoJu9ErPhz702o9Ru0cy8y+86WKdCJVmDC1f0ZBz4hx X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a81:ae07:0:b0:59b:ba8a:97d0 with SMTP id m7-20020a81ae07000000b0059bba8a97d0mr6086ywh.3.1695150151389; Tue, 19 Sep 2023 12:02:31 -0700 (PDT) Date: Tue, 19 Sep 2023 12:02:05 -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-10-axelrasmussen@google.com> Subject: [PATCH 09/10] ioctl_userfaultfd.2: fix / update UFFDIO_REGISTER error code list 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-Rspamd-Queue-Id: 37D2780035 X-Rspam-User: X-Stat-Signature: a4kape4c77xe9wsogksb4u41eu1cwogm X-Rspamd-Server: rspam03 X-HE-Tag: 1695150152-686511 X-HE-Meta: U2FsdGVkX1+rM9KITmQWYsQfhC0PRrQQHTgq+RR7Ck3bgtrvZLr5pE8dT+ZdH79rGpX42ryKMcDG4LbiUgmo49BskSl87qApq5/7DITyzup/loAuV6Wk0V1D0ZLn1o1aJJDbx2Zf44JpeL6TOMZUoklaP94j5IhrRsv85siuXGbhWPQoRtSh4EUqMwyaXY0/m6VSOEVYOvkttPnGFD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EwaVSdEGSbVH+Qy5TkXnp+njyPuppJeNNr8XdkU+KpTQrg5kebaV8P8KsUO6Xz1ogstz8xaSGZs1BgFspdJ2wre0WAgyNOnVMdHS3zMEwNCi7k7md5ipiNtMhhlBvNKxuSems79VuZsI6JxiaXQc5VDmoN07HHEat0zS3wylkEtsSFDcDT9It7DqtIDyVSy2ndb/BcAjREren7Xu5GRSk+mcA7hdoNSzxSXVMbAEvbPxsVKmHgpqvV+erWc9TiZhtBBQR4G/fcWqSVuPZak1vGjGCnEtetZpN0bGBz8RpsCPk0lVW//ANbZidSY9GpvGt9xqNaK8EZy2B7mPm5CGLyuLMgRhLCFBjxq85JBK0XQAMAx9OfooCl3G28RDxxtPn2pty8uTU6ONYTXJefiX85NThgM9NZyoUjCZXGGsrCY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.057216, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The list of error codes in the man page was out of date with respect to the current state of the kernel. Some errors were partially / incorrectly described. Update the error code listing, so it matches the current state of the kernel, and correctly describes all the errors. Signed-off-by: Axel Rasmussen --- man2/ioctl_userfaultfd.2 | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index 29dca1f6b..afe3caffc 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -413,12 +413,6 @@ On error, \-1 is returned and .I errno is set to indicate the error. Possible errors include: -.\" FIXME Is the following error list correct? -.\" -.TP -.B EBUSY -A mapping in the specified range is registered with another -userfaultfd object. .TP .B EFAULT .I argp @@ -433,21 +427,32 @@ field; or the field was zero. .TP .B EINVAL -There is no mapping in the specified address range. -.TP -.B EINVAL +The specified address range was invalid. +More specifically, +no mapping exists in the given range, +or the mapping that exists there is invalid +(e.g. unsupported type of memory), +or the range values ( .I range.start or .I range.len -is not a multiple of the system page size; or, +) are not multiples of the relevant page size, +or .I range.len -is zero; or these fields are otherwise invalid. +is zero. .TP -.B EINVAL -There as an incompatible mapping in the specified address range. -.\" Mike Rapoport: -.\" ENOMEM if the process is exiting and the -.\" mm_struct has gone by the time userfault grabs it. +.B ENOMEM +The process is exiting, +and its address space has already been torn down +when userfaultfd attempts to reference it. +.TP +.B EPERM +The userfaultfd would allow writing to a file backing the mapping, +but the calling process lacks such write permissions. +.TP +.B EBUSY +A mapping in the specified range is registered with another +userfaultfd object. .SS UFFDIO_UNREGISTER (Since Linux 4.3.) Unregister a memory address range from userfaultfd. 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: U2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3LHu21xiifhO6ClhSLBbUw3Q7qWKAkKvCWx6hzrqzdS5jvmFTmxtHC4ujeetihu6GlNmZapTWX/EuaxTsiQqR9tbpekY3MKkLnCowW2xlDbzNzGUJDyQMzXOOha4pH2fbXon3nhErqu577aRUUAc4lcqKmBMypNCU95yZ9E+RnxxGSVb7wyqpyAtPOcycOaHfhl0cvVQ7qcP8ppVQsF/QmgOSDF7Q002rzPyYARJy/x61Q/qbhHHh3Kv+EiN3VMokDbYg+85Fk7tc6aoFT+jfJRFHr8VVBi0Fp/uValJRnMYXWfWevkKnT+tWKGUPRFvWwN4F0oDLZpaot5VdsgBx6RJ56vkAsxMdr+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