Message ID | 20240418-alice-mm-v6-0-cb8f3e5d688f@google.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 4D826C4345F for <linux-mm@archiver.kernel.org>; Thu, 18 Apr 2024 08:59:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B24CC6B0089; Thu, 18 Apr 2024 04:59:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD42C6B008C; Thu, 18 Apr 2024 04:59:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99BEE6B0092; Thu, 18 Apr 2024 04:59:34 -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 7BFA66B0089 for <linux-mm@kvack.org>; Thu, 18 Apr 2024 04:59:34 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 25E05141287 for <linux-mm@kvack.org>; Thu, 18 Apr 2024 08:59:34 +0000 (UTC) X-FDA: 82022054268.12.E1F5BCC Received: from mail-lj1-f202.google.com (mail-lj1-f202.google.com [209.85.208.202]) by imf07.hostedemail.com (Postfix) with ESMTP id 3B17540003 for <linux-mm@kvack.org>; Thu, 18 Apr 2024 08:59:32 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=J1SoYQNu; spf=pass (imf07.hostedemail.com: domain of 38uAgZgkKCG8NYVPRelUYTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--aliceryhl.bounces.google.com designates 209.85.208.202 as permitted sender) smtp.mailfrom=38uAgZgkKCG8NYVPRelUYTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--aliceryhl.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=1713430772; 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: references:dkim-signature; bh=tjcuz1zEduZDelE435DU7CODjxYuJ/nMkJoF3xPyrOQ=; b=LoUHTz/Tvo+yIIT2gMTeom9mvOxJXNp6P84BHWiRKbah92kdlhhDt3Ih0p/KShlHPwrvLH 2KnkSaBuwnZBp8bUvNr4PxasoFOgjNBN7EYvUxjX03voj+dMGeVR5ERxgPqnvF+xm5408Z vargyLQPblXqKXaNaQnTqjfTXnicexg= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=J1SoYQNu; spf=pass (imf07.hostedemail.com: domain of 38uAgZgkKCG8NYVPRelUYTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--aliceryhl.bounces.google.com designates 209.85.208.202 as permitted sender) smtp.mailfrom=38uAgZgkKCG8NYVPRelUYTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--aliceryhl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713430772; a=rsa-sha256; cv=none; b=NkdzDSLd6CcEdvRj1sa35l49+qNruCJfpwRyJJUTzGOh9E+mjj636NBQTo0j+RpGUjPKAT alm4vz+xfycW2PICvM0B6s0D4YRCUFMOk7EBF7JO1tljH893xsUyCQ9HV37BUKEPnZpPIK UypHzc/DqcOuapqGrlfkm6Xa2lkYjsY= Received: by mail-lj1-f202.google.com with SMTP id 38308e7fff4ca-2d8781cabdaso4863491fa.2 for <linux-mm@kvack.org>; Thu, 18 Apr 2024 01:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713430771; x=1714035571; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=tjcuz1zEduZDelE435DU7CODjxYuJ/nMkJoF3xPyrOQ=; b=J1SoYQNu9SHXeZBMdfWvWyvMXjamK7F1I2xjzk6xGifzYENUbFKJ9ZBCpGcKn7d6i+ G2P9nk7kVew5wY6OUVtyRhL4zon4gWbNNR5nPWfUHw1siyVrBweB9HXFRGShBhy+E5Yk Nd38F66yBJZ20lQCRqPs7VuhcLEda1mURYSmGyGLxBIlmwaTxy9cbwCB5G5+i7S0NX5Y ohYXfMuKprTC2hUSwP/w8s+veP89D3GU4QHOcbIWJ+ZXxrnVIcjOlxPqELHNHtRq4i9+ SdajeqDtrTj9JWJgcqBm/Udn0abWUCnA9cCwigTptlIO1Ooos/Qnr/QROUgerb/0hHqh 9Csg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713430771; x=1714035571; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tjcuz1zEduZDelE435DU7CODjxYuJ/nMkJoF3xPyrOQ=; b=jXcq4zhcNNk3gYxAHscmt8adiazgjyEg6/PrXmUpzL+1Xq9hZHoPMok4tTOvKsTJYf bQkgk+Z2kuzPs0INMtxOml5P4IROSB5bn2cYb1xTJzLjnyk7ojdLUwCDFe/zPQdl7uAB ABYDDc9+NbZxdgoOrCXGVi9xBPZIuir/pxoAq3/Pb4e9+7fJWlkUNyXsBqhjqhEvul/0 +fMwXEpRZTAPLLeZt5PjjonM7AymjFYU+7OvLIkKGBSxqafTGvStag6TGCyOrSGzrnix 05dPsXe0xgwe3+/BtSgEtJ5wWk6d6ZNo+a9bdGJowqTA1iZpl09RTzC3r/SWeIFPd1YV ZApg== X-Forwarded-Encrypted: i=1; AJvYcCVhx4uOrMoaCTmWUeKP/Q9YX8+fKKMgbjbujPqkkhuXVPfvPBinSsaYuj3DoFHj/YFO0Tyf2lEUZdk1F/TvrIZwIPI= X-Gm-Message-State: AOJu0Yx+GfbCgZjBKD2XUQsbaniVafB0bwUnrdnPMt2DIFa+eLqpBC6l FlPoEsi4j6usQTh0VjDSTBiH563WxYQuf+Mni6kWVAHk5lXpx6kczmHpu3RcBm/pFQTb1g40i4y cCcZWdrTkEf3zGA== X-Google-Smtp-Source: AGHT+IFD4zFEKLzwwqRcxHO2U42hED49hamO66nHcnOSUg2YEF8UQokeTd73CF3AhLyw0IFIrk8AVfurp0BM69Q= X-Received: from aliceryhl2.c.googlers.com ([fda3:e722:ac3:cc00:68:949d:c0a8:572]) (user=aliceryhl job=sendgmr) by 2002:a2e:a801:0:b0:2dc:14d2:20f7 with SMTP id l1-20020a2ea801000000b002dc14d220f7mr203ljq.9.1713430770579; Thu, 18 Apr 2024 01:59:30 -0700 (PDT) Date: Thu, 18 Apr 2024 08:59:16 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAOTgIGYC/2XOwW7DIAwG4FepOI8JjMnoTnuPaQfimBSpKVUyo U1V3n1OL2GKOP2G7zcPtfCceVHvp4eaueYll5uE7uWk6BJvI+s8SFZgwFkLQcdrJtbTpHvyzqH viDkoeX6fOeWfZ9Xnl+RLXr7L/PtsrnabbiVoLOBeUq02erCxJ6bgCPFjLGW88iuVSW0tFXYJp llfYZMBLHi5wNgdpNulfL2RTiQN6a13UeSZDhJ3KaeRKBLPMSAgUDJwkL6R1jfSi+yS94xD4OT tP7mu6x9zHjE7iQEAAA== X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=5147; i=aliceryhl@google.com; h=from:subject:message-id; bh=EKOb+HQOdPSDwGBxYIVC+gfTRfSx/aJkWNgqulepRkI=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBmIODpvn8YfthhJyGIeqFlR8yHa3C9Ul13gEsd0 HVls3uAQBOJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZiDg6QAKCRAEWL7uWMY5 RkZ/D/96tk+NcZHWL5a1hchXVUpuXjVL0AymcssJSlYyOWYe2xnTOVbpQwg4Oo5cANiWPFyOoya hNONBYZCjpxUbQRkVi+yYKhVjHgILqf+b2vuR2xRKD+b4OPCIMO9GMvn+HAdZOEBqbxTN4S9vR3 PMVu1Ma8aAYwHNIcvrRc84iTW+q9C6Ez8UfwGfN8Wro1WFguJmsInBfPzy0DDDAJbK3kmafpwqg 8VNMHnr111Psg88SZVCQOjehLlTCLWEv9xO89rW4vMZ0g4alszYGUF06g2haQdCuEhanwo8bQ06 6KWwpx948WfAwIQCh6A4yBlKJUfpVNzdfODsahr0OohgelmIwdGPVaToBY4xSybBr8niN4Kn0Ak OBChHRyJEKlDWE5U6slhYZ9WDNllPAurIDjB9Aegml7F3OYc21dSbUs0CGxUglTp6WKN9pjBSd/ 45IjwxJpi3fxfA5+bYFgIT2u5CmztdV5tqMj5g9aRVSk5ildy9fY8yYw+Jp75Yvpq4gbp96sZZY G14q8FZHYM2LN6lVC8Xem1i4SfGgLICM3FCQInMdQJUK7Q1JkxJ7H4sbrYYW+2xiQJvAm6LCbGo TY26fZqZGx3HOUD8p8CYZxtMJjNqZjWshi3MP5iwgUNtHDgkk099IVwMrCsAz1bEidgr2VOWK1w xmOk2hZb3SGJ73Q== X-Mailer: b4 0.13-dev-26615 Message-ID: <20240418-alice-mm-v6-0-cb8f3e5d688f@google.com> Subject: [PATCH v6 0/4] Memory management patches needed by Rust Binder From: Alice Ryhl <aliceryhl@google.com> To: Miguel Ojeda <ojeda@kernel.org>, Matthew Wilcox <willy@infradead.org>, Al Viro <viro@zeniv.linux.org.uk>, Andrew Morton <akpm@linux-foundation.org>, Kees Cook <keescook@chromium.org> Cc: Alex Gaynor <alex.gaynor@gmail.com>, Wedson Almeida Filho <wedsonaf@gmail.com>, Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, " =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= " <bjorn3_gh@protonmail.com>, Benno Lossin <benno.lossin@proton.me>, Andreas Hindborg <a.hindborg@samsung.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, " =?utf-8?q?Arve_Hj=C3=B8?= =?utf-8?q?nnev=C3=A5g?= " <arve@android.com>, Todd Kjos <tkjos@android.com>, Martijn Coenen <maco@android.com>, Joel Fernandes <joel@joelfernandes.org>, Carlos Llamas <cmllamas@google.com>, Suren Baghdasaryan <surenb@google.com>, Arnd Bergmann <arnd@arndb.de>, Trevor Gross <tmgross@umich.edu>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Alice Ryhl <aliceryhl@google.com>, Christian Brauner <brauner@kernel.org> Content-Type: text/plain; charset="utf-8" X-Rspamd-Queue-Id: 3B17540003 X-Stat-Signature: n3w6f1jpui31cn6m69z5k75dqm7whggg X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1713430771-285235 X-HE-Meta: U2FsdGVkX1+TYFokliP5JdfB5Wh0r2HvRLsXLig8q9jPelRbZwb64pQjOvezKIR2s3CMKZgx0mWz7RTlphhr5bGjBiU9TL0jmHm9nmaPL6P0VknCsCqR8h3dWH+FuauVJFgcDddZ2UAETuf2oM7DY4aPmwlps5dtuj5euYTUk9itRHIfNG5+iFtLftS9PENTj9ei/6RXNp4HEHBNsQtEsyrFw21FMjLLESmP/a2ihek+hriF2oLTqS5LR+D1Cx273G86PQMKlHOsx0Ut0DhS2fhJvpiwmO4AwwssXEk+OUIWS7rBJcDiULkx2LvqF+deiAkW93shq4ptcoY+8AT1ck7tYYi98eymfhS71s4xO5e0Y01xJHb9IeV9M4vOLpRBv4MYT23WVNKqKPYthWirs4jtu3qmZdKFksARpLgkeLzkXNCCz4XEI0EpnbN6EoCcYfhSuJkn4yqTBRRUzjwCIC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o579QV66JRDORK8tQnT3uqnpz3n6XjZocHz0jVvOJZtCcN2kp76+jZDx515/jUYJtFxZYEuYvLYb29Pc+hzLcTrTRYQIfiTchH6yUGRdllmLRqbyl4+9jlWLJxU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Memory management patches needed by Rust Binder
|
expand
|
This patchset contains some abstractions needed by the Rust implementation of the Binder driver for passing data between userspace, kernelspace, and directly into other processes. These abstractions do not exactly match what was included in the Rust Binder RFC - I have made various improvements and simplifications since then. Nonetheless, please see the Rust Binder RFC [1] to get an understanding for how this will be used: Users of "rust: add userspace pointers" and "rust: add typed accessors for userspace pointers": rust_binder: add binderfs support to Rust binder rust_binder: add threading support rust_binder: add nodes and context managers rust_binder: add oneway transactions rust_binder: add death notifications rust_binder: send nodes in transactions rust_binder: add BINDER_TYPE_PTR support rust_binder: add BINDER_TYPE_FDA support rust_binder: add process freezing Users of "rust: add abstraction for `struct page`": rust_binder: add oneway transactions rust_binder: add vma shrinker Links: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-0-08ba9197f637@google.com/ [1] Signed-off-by: Alice Ryhl <aliceryhl@google.com> --- Changes in v6: - Base on top of Wedson's Allocation APIs patchset. - Do not define my own gfp flags, instead use the ones that are now available in `kernel::alloc`. - Add gfp flags to `read_all` methods instead of always using GFP_KERNEL. - The __GFP_HIGHMEM flag is not provided by the Allocation APIs patchset, and I do not add it here. I will send a separate patchset for adding it. - Use usize instead of void pointer for userspace address. - Add _raw suffix to `fill_zero` and `copy_from_user_slice`. - Do not allow interior mutability in AsBytes/FromBytes. - Doc changes: - Mention that validity of user slices is checked at read/write time, not in the constructor of the user slice. - Mention that methods can also return EFAULT if a bounds check fails. - Mention that methods may have partially copied data even if they return EFAULT. - Add link from `read_raw` to `read_slice`. - Move comment about initialized memory on `read_raw` to `# Guarantees` section. - Add examples for `Page::alloc_page`. - A previous version renamed UserSlicePtr to UserSlice but forgot to update that in the commit message. Commit message fixed in this version. - Add Reviewed-by tags submitted on v5. - Link to v5: https://lore.kernel.org/rust-for-linux/20240415-alice-mm-v5-0-6f55e4d8ef51@google.com/ Changes in v5: - Fix casts in declarations of PAGE_* constants. - Fix formatting of PAGE_MASK. - Reformat comments at 100 line length. - Minor fixes to safety comments of `read_raw` and `write_slice`. - Link to v4: https://lore.kernel.org/rust-for-linux/20240404-alice-mm-v4-0-49a84242cf02@google.com/ Changes in v4: - Rephrase when we fail with EFAULT. - Remove `pub` from examples. - Use slices for raw uaccess methods. - Fix PAGE_MASK constant. - Rephrase most safety comments in Page abstraction. - Make with_pointer_into_page and with_page_mapped private. - Explain how raw pointers into pages are used correctly. - Other minor doc improvements. - Link to v3: https://lore.kernel.org/rust-for-linux/20240311-alice-mm-v3-0-cdf7b3a2049c@google.com/ Changes in v3: - Fix bug in read_all. - Add missing `#include <linux/nospec.h>`. - Mention that the second patch passes CONFIG_TEST_USER_COPY. - Add gfp flags for Page. - Minor documentation adjustments. - Link to v2: https://lore.kernel.org/rust-for-linux/20240208-alice-mm-v2-0-d821250204a6@google.com/ Changes in v2: - Rename user_ptr module to uaccess. - Use srctree-relative links. - Improve documentation. - Rename UserSlicePtr to UserSlice. - Make read_to_end append to the buffer. - Use named fields for uaccess types. - Add examples. - Use _copy_from/to_user to skip check_object_size. - Rename traits and move to kernel::types. - Remove PAGE_MASK constant. - Rename page methods to say _raw. - Link to v1: https://lore.kernel.org/rust-for-linux/20240124-alice-mm-v1-0-d1abcec83c44@google.com/ --- Alice Ryhl (2): rust: uaccess: add typed accessors for userspace pointers rust: add abstraction for `struct page` Arnd Bergmann (1): uaccess: always export _copy_[from|to]_user with CONFIG_RUST Wedson Almeida Filho (1): rust: uaccess: add userspace pointers include/linux/uaccess.h | 38 ++-- lib/usercopy.c | 30 +--- rust/bindings/bindings_helper.h | 1 + rust/helpers.c | 34 ++++ rust/kernel/alloc.rs | 7 + rust/kernel/lib.rs | 2 + rust/kernel/page.rs | 250 ++++++++++++++++++++++++++ rust/kernel/types.rs | 64 +++++++ rust/kernel/uaccess.rs | 388 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 774 insertions(+), 40 deletions(-) --- base-commit: 2c1092853f163762ef0aabc551a630ef233e1be3 change-id: 20231128-alice-mm-bc533456cee8 Best regards,