public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] rust: add pointer projection infrastructure and convert DMA
@ 2026-03-02 16:42 Gary Guo
  2026-03-02 16:42 ` [PATCH v4 1/3] rust: ptr: add `KnownSize` trait to support DST size info extraction Gary Guo
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Gary Guo @ 2026-03-02 16:42 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: rust-for-linux

From: Gary Guo <gary@garyguo.net>

This adds a general pointer projection infrastructure which is intended to
serve as the basis for generic I/O projections. The idea is that we will
have a unified way of reading/writing MMIO or DMA allocation, creating
typed subviews into them, and able to read/write subfields safely.

This is the first step towards that direction, where an infra for
projecting arbitrary pointers are added. This takes care to not assume
pointers are part of a valid allocation, so it can be used to project I/O
pointers, too. `dma_read!` and `dma_write!` is converted to use this infra,
as they currently have soundness issues [1] and users have already
encountered limitation of it [2].

Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Soundness.20of.20.60dma_read!.28.29.60/with/573645610 [1]
Link: https://lore.kernel.org/rust-for-linux/DGE9DBH7X8CO.2EES6EX8UA5ZF@kernel.org/T/#mc17b9c0309ac10346b3d6c6bd8461488e7c73161 [2]

---
Changes since v3:
- Add `KnownSize` trait for documenting safety requirement of
  `ProjectIndex` and updated safety comments accordingly (Benno)
- Some comment rewording (Benno)
- Move code to be under `ptr` module.
- Link to v3: https://lore.kernel.org/rust-for-linux/20260302130223.134058-1-gary@kernel.org/

Changes since v2:
- Fix off-by-one issue (Aditya)
- Fix comment (Aditya)
- Link to v2: https://lore.kernel.org/rust-for-linux/20260226154656.3241736-1-gary@kernel.org/

Changes since v1:
- Squashed patch 2,3,4 so that all users are converted in single commit
  (Danilo)
- I discovered an additional soundness bug in dma_read/write macros
  where it can create misaligned access. This is addressed in this new
  version.
- Updated sample driver to have a function that does check instead use a
  budget-try block (Benno)
- Improved diagnostics when index projection is used on types that are
  not slices.
- Link to v1: https://lore.kernel.org/rust-for-linux/20260214053344.1994776-1-gary@garyguo.net/

---
Gary Guo (3):
  rust: ptr: add `KnownSize` trait to support DST size info extraction
  rust: ptr: add projection infrastructure
  rust: dma: use pointer projection infra for `dma_{read,write}` macro

 drivers/gpu/nova-core/gsp.rs      |  14 +-
 drivers/gpu/nova-core/gsp/boot.rs |   2 +-
 drivers/gpu/nova-core/gsp/cmdq.rs |  10 +-
 rust/kernel/dma.rs                | 114 +++++-------
 rust/kernel/lib.rs                |   4 +
 rust/kernel/ptr.rs                |  30 ++-
 rust/kernel/ptr/projection.rs     | 294 ++++++++++++++++++++++++++++++
 samples/rust/rust_dma.rs          |  30 +--
 scripts/Makefile.build            |   4 +-
 9 files changed, 411 insertions(+), 91 deletions(-)
 create mode 100644 rust/kernel/ptr/projection.rs


base-commit: 877552aa875839314afad7154b5a561889e87ea9
-- 
2.51.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-07 22:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02 16:42 [PATCH v4 0/3] rust: add pointer projection infrastructure and convert DMA Gary Guo
2026-03-02 16:42 ` [PATCH v4 1/3] rust: ptr: add `KnownSize` trait to support DST size info extraction Gary Guo
2026-03-02 18:56   ` Benno Lossin
2026-03-02 18:57   ` Benno Lossin
2026-03-02 19:42     ` Gary Guo
2026-03-02 21:52       ` Benno Lossin
2026-03-02 16:42 ` [PATCH v4 2/3] rust: ptr: add projection infrastructure Gary Guo
2026-03-02 19:02   ` Benno Lossin
2026-03-03 21:11   ` Miguel Ojeda
2026-03-02 16:42 ` [PATCH v4 3/3] rust: dma: use pointer projection infra for `dma_{read,write}` macro Gary Guo
2026-03-03 21:13 ` [PATCH v4 0/3] rust: add pointer projection infrastructure and convert DMA Miguel Ojeda
2026-03-07 22:29 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox