From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F21A36AEF for ; Mon, 11 Mar 2024 10:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710154043; cv=none; b=Jb+QV7M6KxwUzelgUXbqViczGXy/S1zAmeWAzPNT5k1e/d+d4xFYX+Tb4oUMzWUsAKIMNjZyE3t7//runQOxYZs2CzImFJOltBYvdUaf5xyYkzfcATC9kH9G1gaxPrcvIuEk+nFlC3o7jHbbHVimHsYtDCss4CSJVeYosk6pA7M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710154043; c=relaxed/simple; bh=eFO8v8hNbjIyLu0r8FdBf9oSrloJURleePlt88en+Ow=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=YnPRdhQWNL0WL7B4EGwawBKQM0/mHtEn0KV92AvCZ2VgUpUHPARzpheFxzxo+C1I68lFjzuMm8TSn58Vi6yB4qMs1n930c0lmZzXSRrpCUmfre0e9VRnx2ytZSvzf4ZxRrXwvZEL0QMWeuAHEXNwMoGOaRSZ5qsj1aD6MxNjYEM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Sfkt/N98; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sfkt/N98" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5f38d676cecso64333677b3.0 for ; Mon, 11 Mar 2024 03:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710154040; x=1710758840; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=OL5M0QWyifHNNdL2G7ppAclszTpwZdkP49JBOmqQfUg=; b=Sfkt/N98IbV0lZ6+5kuYDhjUzjN3znJSGoTELPLw7SRBfLTorLlXa6scD3wDtU8ULu H7rbEKET8r7RJ7ONTUv7pkMMxHp0XAUtC+5Bj/7w9e51cryGG/oOZwfPr2Utdwk+h3l1 TgN0Vp4i5dTVplaGHfjsdxZPLnZNhBudnGxTypULRcjoUIUpLtrfASv6LlN+AgADzJTi uuToAh/mbTuerMeTAPMkghmEOwt9WNLBC4FP+E/wPZQPvn04O2FL1b+uJ/tOGDhCHidu Ts5WEbRRlXLTkEfODfc9NFWaz23L9yYsR3fgkIF1wV3ZvvPHvvE5Gh5TbyJ49PES8OeA /vWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710154040; x=1710758840; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OL5M0QWyifHNNdL2G7ppAclszTpwZdkP49JBOmqQfUg=; b=l9WwhHAE8QlPF5FE4+Xnu3s3xi2FE/wKyFbkCDRFAwwj588dHXpJD4si41zboGzbUx pS/dPXbA298UO2GAvt6LuRwFBbSDFJSEg4Yc7QC3LuJnxfahCu2iokfxqJYs3FgVJ3Fl zQ0aUyugoD9CMIqeLROtL3dg0daZKHwmSpftTU5+JIQ9dZxe4ktFfgZQoyy4XnGwhl+O lAs1HxqVTHTarVgPbNjPdZwjeiK6Wr/0AMY1hoCf55hBzi14odQ0iskBlgMYUz8mpm2i /JW/iEOcJqFuBdJRDu52LyRTa9ZrNW4KqELnRT9d9fo3ygG0nzXryqXyf5spELBTn7z3 it+Q== X-Forwarded-Encrypted: i=1; AJvYcCVqDb6cnWa9G9R1mmyxk214b71r2Dog5f4V7r97OckgES20JnDBEHEpzVbdLcLVZfCMl6efEt9zANdtSGVp+1hHBELw1Jn8QCHJx11aTPg= X-Gm-Message-State: AOJu0YyQdn0qCHECiwo41i4lunttOnTiSKqiAVTfjSTAFmXCxsmENZ1O BFEZlohbmY/LVEcuz+pWPTB6UC9q2azy9hwmEJIA7/l6UpFa3Gz6lDzvejn9BGZcHRwybX/wSAg Qd0sgkFOR1hhIgg== X-Google-Smtp-Source: AGHT+IE1ncu/WTcNjGAnRJ10XRaL7XtUuCqTkHwslE1ImUHNhjgR1ywcm4zJ24S5Uy+4a8JfkWXzPThuHXDDTec= X-Received: from aliceryhl2.c.googlers.com ([fda3:e722:ac3:cc00:68:949d:c0a8:572]) (user=aliceryhl job=sendgmr) by 2002:a25:aa14:0:b0:dcc:5463:49a8 with SMTP id s20-20020a25aa14000000b00dcc546349a8mr1576787ybi.6.1710154040582; Mon, 11 Mar 2024 03:47:20 -0700 (PDT) Date: Mon, 11 Mar 2024 10:47:12 +0000 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIADHh7mUC/1WNwQ7CIAxAf2XhLAYKLMST/2E8sK5uJNswYIhm2 b8Lu0yPr+17XVmi6CmxS7OySNknH5YC6tQwHN0yEPd9YQYClJRguZs8Ep9n3qFRSpsWiSwr589 ID//eU7d74dGnV4ifvZxlndaIFhL0EcmSC95L1yGhVaj1dQhhmOiMYWa1kuEwQfy8z1BNCxJMW WjX/pnbtn0BsZxJJdsAAAA= X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=2955; i=aliceryhl@google.com; h=from:subject:message-id; bh=eFO8v8hNbjIyLu0r8FdBf9oSrloJURleePlt88en+Ow=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBl7uEzbZWmf9BCRypJrSQseEDCZlk4xAlqYenD3 TaITrik6PKJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZe7hMwAKCRAEWL7uWMY5 Rn+BD/0YENdgVIyHtyKKIzmevaWvjv1Bz4CRTnVr6yyDiHjOQ6jb4fmjM1f3PPhdrXpe35T+TwH H5xuahzp3T7osiXs7jAbHzmIUzXei3YH9zY+gxGE/fLxRMSYFzD6FgXyGexkgyIbn1DY8XrmpEl 4vGAoxJD3Lq/vsB8Y8LhmGBRXtEcUJE6pfB9AySb/YhEA1Kn+mhr7JM5EIpZxml71jA9oDvA5zY 50xSALmT51CD31w7V/mSxvUkVX0zIdM5l2r9utasvXSA7f9gQbW0+Jtc2GFukHIAOzVKxaQ0NAx LA9tLpadDKRhtS20aJusKewF2yF7hFS4qk5CrDVKAu6GtwlEScBhfP0GA3PSWAdCg5/FruKhX02 pS1XI4SdicSrkAIN289GK/forO9U7CcpAB/pmpaF2+i3D7xyrItmjPMFXMH5zYBREyTgrz72ck+ vozSQZTVmQOjsU4L1nI6Qj9olliNU1eK3v3oCZ7fOEDkVTOVqhtUiYgYW112DjQL2P3yzRH01cy h8dzbbAIvuigCzK29AkXE9/6bUujoFFV5GaZRXlfo0c0pjpl4z0duf/yjun894N4XnjdXI/R++I +qiEFJCRPMsGysfiOCcELFNGCqFEUWrutdJpNqBQu2BEpHqNnLydAruOIyJ3Wsfgv8mOHwAsKEe wptsYX5Lzhg7jWg== X-Mailer: b4 0.13-dev-26615 Message-ID: <20240311-alice-mm-v3-0-cdf7b3a2049c@google.com> Subject: [PATCH v3 0/4] Memory management patches needed by Rust Binder From: Alice Ryhl To: Miguel Ojeda , Matthew Wilcox , Al Viro , Andrew Morton , Kees Cook Cc: Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Greg Kroah-Hartman , "=?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?=" , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Arnd Bergmann , linux-mm@kvack.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Alice Ryhl , Christian Brauner Content-Type: text/plain; charset="utf-8" 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 --- Changes in v3: - Fix bug in read_all. - Add missing `#include `. - 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 | 3 + rust/helpers.c | 34 ++++ rust/kernel/lib.rs | 2 + rust/kernel/page.rs | 223 +++++++++++++++++++++++ rust/kernel/types.rs | 67 +++++++ rust/kernel/uaccess.rs | 388 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 745 insertions(+), 40 deletions(-) --- base-commit: 768409cff6cc89fe1194da880537a09857b6e4db change-id: 20231128-alice-mm-bc533456cee8 Best regards, -- Alice Ryhl