Skip to contentSkip to conversation

rust: io_pgtable: Add io_pgtable abstraction

PATCH New Daniel Almeida 2 participants 2 messages Jun 23, 2025 – Jun 29, 2025 Rust

lore
Share & tools
lore

Daniel Almeida

author reviewer
#0 lore raw

PATCH v2 1/1 rust: io_pgtable: Add io_pgtable abstraction

From: Asahi Lina <[email protected]>

The io_pgtable subsystem implements page table management for various IOMMU page table formats. This abstraction provides a bare minimum feature-set, enough to map and unmap pages as needed.

This abstraction will be used by some upcoming GPU drivers in order to map and unmap iova ranges, which in turn is used by a lot of other GPU operations.

---
Changes in v2:
- Rebase on rust-next
- Use Opaque<T> where applicable
- Use .cast() as applicable
- Slightly reword commit message
- cc more people
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 rust/bindings/bindings_helper.h |   4 +-
 rust/kernel/io_pgtable.rs       | 389 ++++++++++++++++++++++++++++++++++++++++
 rust/kernel/lib.rs              |   1 +
 3 files changed, 393 insertions(+), 1 deletion(-)
rust/bindings/bindings_helper.h +3 -1
index 8cbb660e2ec218021d16e6e0144acf6f4d7cca13..2b8cde31fb4401a4522c1c25ccf5a3bbbab3a1ff 100644
@@ -52,6 +52,7 @@
 #include <linux/file.h>
 #include <linux/firmware.h>
 #include <linux/fs.h>
+#include <linux/io-pgtable.h>
 #include <linux/jiffies.h>
 #include <linux/jump_label.h>
 #include <linux/mdio.h>
@@ -89,7 +90,8 @@ const gfp_t RUST_CONST_HELPER_GFP_NOWAIT = GFP_NOWAIT;
 const gfp_t RUST_CONST_HELPER___GFP_ZERO = __GFP_ZERO;
 const gfp_t RUST_CONST_HELPER___GFP_HIGHMEM = ___GFP_HIGHMEM;
 const gfp_t RUST_CONST_HELPER___GFP_NOWARN = ___GFP_NOWARN;
-const blk_features_t RUST_CONST_HELPER_BLK_FEAT_ROTATIONAL = BLK_FEAT_ROTATIONAL;
+const blk_features_t RUST_CONST_HELPER_BLK_FEAT_ROTATIONAL =
+	BLK_FEAT_ROTATIONAL;
 const fop_flags_t RUST_CONST_HELPER_FOP_UNSIGNED_OFFSET = FOP_UNSIGNED_OFFSET;
 
 const xa_mark_t RUST_CONST_HELPER_XA_PRESENT = XA_PRESENT;
rust/kernel/io_pgtable.rs new file +389 -0

389 lines not on this page · raw message

rust/kernel/lib.rs +1 -0
index 6b4774b2b1c37f4da1866e993be6230bc6715841..fcd1a97b32e9d8db92300ff6925a97cbeb0ffada 100644
@@ -80,6 +80,7 @@
 pub mod fs;
 pub mod init;
 pub mod io;
+pub mod io_pgtable;
 pub mod ioctl;
 pub mod jump_label;
 #[cfg(CONFIG_KUNIT)]

---
base-commit: dc35ddcf97e99b18559d0855071030e664aae44d
change-id: 20250324-io_pgtable-edd25c1ec062

Best regards,

Signature · 1 line
Daniel Almeida <[email protected]>
#1 lore raw
kernel test robot noticed the following build warnings:

Hi Daniel,

kernel test robot noticed the following build warnings:

[auto build test WARNING on dc35ddcf97e99b18559d0855071030e664aae44d]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniel-Almeida/rust-io_pgtable-Add-io_pgtable-abstraction/20250624-053329
base:   dc35ddcf97e99b18559d0855071030e664aae44d
patch link:    https://lore.kernel.org/r/20250623-io_pgtable-v2-1-fd72daac75f1%40collabora.com
patch subject: [PATCH v2] rust: io_pgtable: Add io_pgtable abstraction
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20250630/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
rustc: rustc 1.78.0 (9b00956e5 2024-04-29)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250630/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> warning: unresolved link to `IOPagetable`

--> rust/kernel/io_pgtable.rs:55:44
|
55 | /// User-specified type owned by the [IOPagetable] that will be passed to TLB
| ^^^^^^^^^^^ no item named IOPagetable in scope
|
= help: to escape [ and ] characters, add '' before them like [ or ] = note: #[warn(rustdoc::broken_intra_doc_links)] on by default

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki