Sitemap
Wuyang Chung

Wuyang Chung

Capability-based IOMMU

4 min readDec 13, 2025

In previous post I mentioned that capability can be adopted by IOMMU in capability-based segmentation architecture and it can make the authorization of host memory access from I/O devices very simple. That method can also be used in non-segmentation architecture.

IOMMU is the MMU for DMA-capable I/O devices. It provides both translation and authorization of host memory access from I/O devices. Devices use IOVA to communicate with IOMMU the address of the host memroy it wants to access and IOMMU checks page tables to see if it can access that host memory and get the physical address of that memory. Several researches have pointed out that using virtual memory as a way to authorize I/O devices for host memory access is not a good idea. Virtual memory is better suited for long time static mapping and I/O devices usually use a DMA buffer for only a short period of time. The frequent map and unmap operations for the DMA buffer make IOMMU inefficient so hardware should use another method for the authorization of host memory access from I/O devices. In this paper I propose using capability for the authorization of host memory access so the system does not need to frequently map and unmap DMA buffers.

Get Wuyang Chung’s stories in your inbox

Join Medium for free to get updates from this writer.

Capability can be used to control the access of any objects in the system. Here we are only interested in DMA buffer access so the capability here is only used to control the access of DMA buffer. An I/O device can access a DMA buffer only if it has the capability to that DMA buffer. Before an I/O device can do DMA to host memory, its device driver must first allocate a DMA buffer from the system. In addition to returning a pointer of the DMA buffer to the driver, the system should also return a capability of that DMA buffer to the driver. Device driver then sends this capability to its I/O device. When I/O device wants to access the DMA buffer, its IOVA must contain a vaild capability to that DMA buffer in order to access it. Below is a more detail explanation of this method.

Press enter or click to view image in full size
Capability is a key number combined with an index to metadata table

As shown in the figure above, the system maintains a centralized DMA buffer metadata table where each entry stores metadata — specifically the base address, size, and access permissions — for an allocated DMA buffer. All DMA buffers in the system have an entry in this table. A Capability, by definition, is a unique ID. Since each DMA buffer has an entry in this metadata table, the entry index to this metadata table can be served as the unique ID for a DMA buffer. In order to prevent capability from being forged, there is a key number field in both the capability and the metadata. A capability is valid only when the key number in the capability (key_c) is equal to the key number in the corresponding metadata (key_m). When a DMA buffer is allocated, the OS finds a free entry in the metadata table, store the base address and size of the DMA buffer in that entry. OS will also store a random number in the key field of that entry. OS then combines that key number and the entry index together as the capability for this DMA buffer and returns it to the device driver. Device driver then sends this capability to I/O device. Below is the flowchart of the authorization steps for host memory access from I/O devices.

Press enter or click to view image in full size
The authorization steps

As illustrated in the figure above, the IOVA encodes the process ID (PID), a capability descriptor, and an intra-buffer offset. The PID selects the target page table for translation, while the capability comprises a key value (key_c) and an index referencing an entry in the DMA metadata table. A capability is considered valid if and only if its key matches the key (key_m) stored in the corresponding DMA buffer metadata. Furthermore, the sum of the IOVA offset and the transfer length must not exceed the total buffer size. Once the IOVA satisfies both key validation and bounds checking, the hardware computes the target virtual address by adding the IOVA offset to the DMA buffer’s base address.

When the driver frees a DMA buffer, the system does not need to unmap the DMA buffer. It only needs to change the key number (key_m) in the metadata. As shown in the figure below once the key number in the metadata is changed, the capability that points to this DMA buffer is invalidated and the hardware device can no longer access this DMA buffer.

Press enter or click to view image in full size
Invalid capability since key_c != key_m.

--

--