Skip to content

rust: add pointer projection infrastructure and convert DMA

Gary Guo dri-devel driver-core linux-kbuild lkml nouveau rust-for-linux 3 versions – Applied

Status from this message: Applied to drm-rust-fixes, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 8 repliesApplied
  2. v32 patches 13 repliesSuperseded
  3. v22 patches 3 repliesSuperseded

Changes in v4 from the cover letter

- 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/[email protected]/

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/3rust: ptr: add `KnownSize` trait to support DST size info extractionrust/kernel/lib.rs rust/kernel/ptr.rs+27 -14 replies
2/3rust: ptr: add projection infrastructurerust/kernel/lib.rs rust/kernel/ptr.rs rust/kernel/ptr/projection.rs +1 more+303 -12 replies
3/3rust: dma: use pointer projection infra for `dma_{read,write}` macrodrivers/gpu/nova-core/gsp.rs drivers/gpu/nova-core/gsp/boot.rs drivers/gpu/nova-core/gsp/cmdq.rs +2 more+81 -890 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchBenno LossinMiguel Ojeda
SeriesA-b
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/3] rust: add pointer projection infrastructure and convert DMA

From: Gary Guo <[email protected]>

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].

---
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/[email protected]/

Changes since v2:
- Fix off-by-one issue (Aditya)
- Fix comment (Aditya)
- Link to v2: https://lore.kernel.org/rust-for-linux/[email protected]/

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/[email protected]/

---
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

Signature · 1 line
2.51.2