Skip to main content

6 Memory-mapped register interface

The IOMMU provides a memory-mapped programming interface. The memory-mapped registers of each IOMMU are located within a naturally aligned 4-KiB region (a page) of physical address space.

The IOMMU behavior for register accesses where the address is not aligned to the size of the access, or if the access spans multiple registers, or if the size of the access is not 4 bytes or 8 bytes, is UNSPECIFIED. A 4 byte access to an IOMMU register must be single-copy atomic. Whether an 8 byte access to an IOMMU register is single-copy atomic is UNSPECIFIED, and such an access may appear, internally to the IOMMU, as if two separate 4 byte accesses — first to the high half and second to the low half — were performed.

note

The 8-byte IOMMU registers are defined in such a way that software can perform two individual 4-byte accesses, or hardware can perform two independent 4-byte transactions resulting from an 8-byte access, to the high and low halves of the register, in that order, as long as the register semantics, with regard to side-effects, are respected between the two software accesses, or two hardware transactions, respectively.

The IOMMU registers have little-endian byte order, even for systems where all harts are big-endian-only.

note

Big-endian-configured harts that make use of an IOMMU are expected to implement the REV8 byte-reversal instruction defined by the Zbb extension. If REV8 is not implemented, then endianness conversion may be implemented using a sequence of instructions.

If a register is optional, as determined by the corresponding capabilities register bit being 0, then a read from the memory-mapped register offset of the register returns 0 and writes to that offset are ignored.

Registers and register fields designated for future standard use must be read-only zero. For forward compatibility, registers and register fields designated for custom use should be implemented as read-only zero if the implementation does not define a custom use for them.

6.1 Register layout

Table 15. IOMMU Memory-mapped register layout

OffsetNameSizeDescriptionIs Optional?
0capabilities8Capabilities of the IOMMUNo
8fctl4Features controlNo
12custom4Designated For custom use
16ddtp8Device directory table pointerNo
24cqb8Command-queue baseNo
32cqh4Command-queue headNo
36cqt4Command-queue tailNo
40fqb8Fault-queue baseNo
48fqh4Fault-queue headNo
52fqt4Fault-queue tailNo
56pqb8Page-request-queue baseif capabilities.ATS==0
64pqh4Page-request-queue headif capabilities.ATS==0
68pqt4Page-request-queue tailif capabilities.ATS==0
72cqcsr4Command-queue CSRNo
76fqcsr4Fault-queue CSRNo
80pqcsr4Page-request-queue CSR if capabilities.ATS==0
84ipsr4Interrupt pending status registerNo
88iocountovf4HPM counter overflowsif capabilities.HPM==0
92iocountinh4HPM counter inhibitsif capabilities.HPM==0
96iohpmcycles8HPM cycles counterif capabilities.HPM==0
104iohpmctr1-31248HPM event countersif capabilities.HPM==0
352iohpmevt1-31248HPM event selectorif capabilities.HPM==0
600tr_req_iova8Translation-request IOVAif capabilities.DBG==0
608tr_req_ctl8Translation-request controlif capabilities.DBG==0
616tr_response8Translation-request responseif capabilities.DBG==0
624iommu_qosid4IOMMU QoS ID if capabilities.QOSID==0
628Reserved60Reserved for future use (WPRI)
688custom72Designated for custom use (WARL)
760icvec8Interrupt cause to vector registerNo
768msi_cfg_tbl256MSI Configuration Tableif capabilities.IGS==WSI
1024Reserved3072Reserved for standard use

6.2 Reset behavior

The reset value is 0 for the following registers fields.

  • cqcsr - cqen, cqie, cqon, and busy
  • fqcsr - fqen, fqie, fqon, and busy
  • pqcsr - pqen, pqie, pqon, and busy
  • tr_req_ctl.Go/Busy
  • ddtp.busy

The reset value is 0 for the following registers.

  • ipsr

Reset value for ddtp.iommu_mode field must be either Off or Bare.

After a reset the caches (Section 3.8) must have no valid entries.

note

The reset value for the iommu_mode is recommended to be Off.

The reset value is UNSPECIFIED for all other registers and/or fields.

6.3 IOMMU capabilities (capabilities)

The capabilities register is a read-only register reporting features supported by the IOMMU. Each field if not clear indicates the presence of that feature in the IOMMU. At reset, the register shall contain the IOMMU supported features.

c3779ca7ab1f572a000ba8d4f77809d6

BitsFieldAttributeDescription
7:0versionROThe version field holds the version of the specification implemented by the IOMMU. The low nibble is used to hold the minor version of the specification and the upper nibble is used to hold the major version of the specification. For example, an implementation that supports version 1.0 of the specification reports 0x10.
8Sv32ROPage-based 32-bit virtual addressing is supported.
9Sv39ROPage-based 39-bit virtual addressing is supported.
10Sv48ROWhen Sv48 is set, Sv39 must be set.
11Sv57ROWhen Sv57 is set, Sv48 must be set.
13:12reservedROReserved for standard use.
14Svrsw60t59bROPTE Reserved-for-Software Bits 60-59.
15SvpbmtROPage-based memory types.
16Sv32x4ROPage-based 34-bit virtual addressing for second-stage address translation is supported.
17Sv39x4ROPage-based 41-bit virtual addressing for second-stage address translation is supported.
18Sv48x4ROPage-based 50-bit virtual addressing for second-stage address translation is supported.
19Sv57x4ROPage-based 59-bit virtual addressing for second-stage address translation is supported.
20reservedROReserved for standard use.
21AMO_MRIFROAtomic updates to MRIF is supported.
22MSI_FLATROMSI address translation using Pass-through mode MSI PTE is supported.
23MSI_MRIFROMSI address translation using MRIF mode MSI PTE is supported.
24AMO_HWADROAtomic updates to PTE accessed (A) and dirty (D) bit is supported.
25ATSROPCIe Address Translation Services (ATS) and page-request interface (PRI) [5] is supported.
26T2GPAROReturning guest-physical-address in ATS translation completions is supported.
27ENDROWhen 0, IOMMU supports one endianness (either little or big). When 1, IOMMU supports both endianness. The endianness is defined in the fctl register.
29:28IGSROIOMMU interrupt generation support. | Value | Name | Description | | --- | --- | --- | | 0 | MSI | IOMMU supports only message- signaled-interrupt generation. | | 1 | WSI | IOMMU supports only wire- signaled-interrupt generation. | | 2 | BOTH | IOMMU supports both MSI and WSI generation. The interrupt generation method must be defined in the fctl register. | | 3 | 0 | Reserved for standard use |
30HPMROIOMMU implements a hardware performance monitor.
31DBGROIOMMU supports the translation-request interface
37:32PASROPhysical Address Size supported by the IOMMU.
38PD8ROOne level PDT with 8-bit process_id supported.
39PD17ROTwo level PDT with 17-bit process_id supported.
40PD20ROThree level PDT with 20-bit process_id supported.
41QOSIDROAssociating QoS IDs with requests is supported.
42NLRONon-leaf PTE invalidation extension is supported.
43SROAddress range invalidation extension is supported.
55:44reservedROReserved for standard use.
63:56customRODesignated for custom use.

When HPM is 1, the iohpmcycles and the iohpmctr1 registers must be present and be at least 32-bits wide.

At least one method, MSI or WSI, of generating interrupts from the IOMMU must be supported.

IOMMU implementations must support the Svnapot standard extension for NAPOT Translation Contiguity.

The physical address space addressable by the IOMMU ranges from 0 to 2{capabilities.PAS}12^\{capabilities.PAS\} - 1.

note

Hypervisor may provide an SW emulated IOMMU to allow the guest to manage the first-stage page tables for fine grained control on memory accessed by guest controlled devices.

A hypervisor that provides such an emulated IOMMU to the guest may retain control of the second-stage address translation and clear the SvNx4 fields of the emulated capabilities register.

A hypervisor that provides such an emulated IOMMU to the guest may retain control of the MSI page tables used to direct MSIs to guest interrupt files in an IMSIC or to a memory-resident-interrupt-file and clear the MSI_FLAT and MSI_MRIF fields of the emulated capabilities register.

note

The AMO_HWAD/AMO_MRIF bits do not indicate support for device-initiated atomic memory operations. Support for device-initiated atomic memory operations must be discovered through other means.

note

The IOMMU is designed to provide a highly modular and extensible set of capabilities allowing implementations to include only the exact set of capabilities required for an application. In addition, implementations may add their own custom extensions to the IOMMU.

The IOMMU must support all the virtual memory extensions that are supported by any of the harts in the system.

RISC-V platform specifications may mandate a set of IOMMU capabilities that must be provided by an implementation to be compliant to those specifications.

6.4 Features-control register (fctl)

This register must be readable in any implementation. An implementation may allow one or more fields in the register to be writable to support enabling or disabling the feature controlled by that field.

If software enables or disables a feature when the IOMMU is not OFF (i.e. when ddtp.iommu_mode != Off) then the IOMMU behavior is UNSPECIFIED.

If software enables or disables a feature when the IOMMU in-memory queues are enabled (i.e. cqcsr.cqon/cqen == 1, fqcsr.fqon/fqen == 1, or pqcsr.pqon/pqen == 1) then the IOMMU behavior is UNSPECIFIED.

829e85c39607796909922539dada9238

BitsFieldAttributeDescription
0BEWARLWhen 0, IOMMU accesses to memory resident data structures, as specified in Table 9, accesses made by the IOMMU during command processing or for MSI generation, and accesses to in-memory queues are performed as little-endian accesses and when 1 as big-endian accesses.
1WSIWARLWhen 1, IOMMU interrupts are signaled as wire-signaled-interrupts else they are signaled as message-signaled-interrupts.
2GXLWARLControls the address-translation schemes that may be used for guest physical addresses as defined in Table 2 and Table 3.
15:3reservedWPRIReserved for standard use.
31:16customWPRIDesignated for custom use.

6.5 Device-directory-table pointer (ddtp)

b8854727ea89c7531f71f38e32d45965

BitsFieldAttributeDescription
3:0iommu_modeWARLThe IOMMU may be configured to be in the following modes: | Value | Name | Description | | --- | --- | --- | | 0 | Off | No inbound memory transactions are allowed by the IOMMU. | | 1 | Bare | No translation or protection. All inbound memory accesses are passed through. | | 2 | 1LVL | One-level device-directory-table | | 3 | 2LVL | Two-level device-directory-table | | 4 | 3LVL | Three-level device-directory-table | | 5-13 | reserved | Reserved for standard use. | | 14-15 | custom | Designated for custom use. |
4busyROA write to ddtp.iommu_mode may require the IOMMU to perform many operations that may not occur synchronously to the write. When a write is observed by the ddtp.iommu_mode, the busy bit is set to 1. When the busy bit is 1, behavior of additional writes to the ddtp is UNSPECIFIED. Some implementations may ignore the second write and others may perform the actions determined by the second write. Software must verify that the busy If the busy bit reads 0 then the IOMMU has completed the operations associated with the An IOMMU that can complete these operations synchronously may hard-wire this bit to 0.
9:5reservedWPRIReserved for standard use
53:10PPNWARLHolds the PPN of the root page of the device-directory-table.
63:54reservedWPRIReserved for standard use

The device-context is 64-bytes in size if capabilities.MSI_FLAT is 1 else it is 32-bytes.

When the iommu_mode is Bare or Off, the PPN field is don’t-care. When in Bare mode only Untranslated requests are allowed. Translated requests, Translation request, and PCIe message transactions are unsupported.

All IOMMUs must support Off and Bare mode. An IOMMU is allowed to support a subset of directory-table levels and device-context widths. At a minimum one of the modes must be supported.

When the iommu_mode field value is changed to Off the IOMMU guarantees that in-flight transactions, observed at the time of the write to this field, from devices connected to the IOMMU will either be processed with the configurations applicable to the old value of the iommu_mode field or be aborted (Section 8.3). It also ensures that all transactions and previous requests from devices that have already been processed by the IOMMU are committed to a global ordering point such that they can be observed by all RISC-V harts, devices, and IOMMUs in the platform. Software must not change the PPN field value when transitioning the iommu_mode to Off.

The IOMMU behavior of writing iommu_mode to 1LVL, 2LVL, or 3LVL, when the previous value of the iommu_mode is not Off or Bare is UNSPECIFIED. To change DDT levels, the IOMMU must first be transitioned to Bare or Off state. The behavior resulting from changing the iommu_mode to Bare when the previous value of the iommu_mode was not Off is UNSPECIFIED.

When an IOMMU is transitioned to Bare or Off state, the IOMMU may retain information cached from in-memory data structures such as page tables, DDT, PDT, etc. Software must use suitable invalidation commands to invalidate cached entries.

note

In RV32, only the low order 32-bits of the register (22-bit PPN and 4-bit iommu_mode) need to be written.

6.6 Command-queue base (cqb)

This 64-bit register (RW) holds the PPN of the root page of the command-queue and number of entries in the queue. Each command is 16 bytes.

The IOMMU behavior on writing cqb when cqcsr.busy or cqon bits are 1 is UNSPECIFIED. The software recommended sequence to change cqb is to first disable the command-queue by clearing cqen and wait for both cqcsr.busy and cqon to be 0 before changing the cqb. The status of bits 31:cqb.LOG2SZ in cqt following a write to cqb is 0 and the bits cqb.LOG2SZ-1:0 in cqt assume a valid but otherwise UNSPECIFIED value.

5fbe42e80418efa9583930a01ba7bd11

BitsFieldAttributeDescription
4:0LOG2SZ-1WARLThe LOG2SZ-1 field holds the number of entries in command-queue as a log to base 2 minus 1. A value of 0 indicates a queue of 2 entries. Each IOMMU command is 16-bytes. If the command-queue has 256 or fewer entries then the base address of the queue is always aligned to 4-KiB. If the command-queue has more than 256 entries then the command-queue base address must be naturally aligned to 2<sup>LOG2SZ</sup> x 16.
9:5reservedWPRIReserved for standard use
53:10PPNWARLHolds the PPN of the root page of the in-memory command-queue used by software to queue commands to the IOMMU. If the base address as determined by PPN is not aligned as required, all entries in the queue appear to an IOMMU as UNSPECIFIED and any address an IOMMU may compute and use for accessing an entry in the queue is also UNSPECIFIED.
63:54reservedWPRIReserved for standard use
note

In RV32, only the low order 32-bits of the register (22-bit PPN and 5-bit LOG2SZ-1) need to be written.

6.7 Command-queue head (cqh)

This 32-bit register (RO) holds the index into the command-queue where the IOMMU will fetch the next command.

54b95e98b1b2f46335651db557a19a2b

BitsFieldAttributeDescription
31:0indexROHolds the index into the command-queue from where the next command will be fetched by the IOMMU.

6.8 Command-queue tail (cqt)

This 32-bit register (RW) holds the index into the command-queue where the software queues the next command for the IOMMU.

54b95e98b1b2f46335651db557a19a2b

BitsFieldAttributeDescription
31:0indexWARLHolds the index into the command-queue where software queues the next command for IOMMU. Only LOG2SZ-1:0 bits are writable.

6.9 Fault queue base (fqb)

This 64-bit register (RW) holds the PPN of the root page of the fault-queue and number of entries in the queue. Each fault record is 32 bytes.

The IOMMU behavior on writing fqb when fqcsr.busy or fqon bits are 1 is UNSPECIFIED. The software recommended sequence to change fqb is to first disable the fault-queue by clearing fqen and wait for both fqcsr.busy and fqon to be 0 before changing the fqb. The status of bits 31:fqb.LOG2SZ in fqh following a write to fqb is 0 and the bits fqb.LOG2SZ-1:0 in fqh assume a valid but otherwise UNSPECIFIED value.

172518ac097a22ac97755f5183f2d136

BitsFieldAttributeDescription
4:0LOG2SZ-1WARLThe LOG2SZ-1 field holds the number of entries in the fault-queue as a log-to-base-2 minus 1. A value of 0 indicates a queue of 2 entries. Each fault record is 32-bytes. If the fault-queue has 128 or fewer entries then the base address of the queue is always aligned to 4-KiB. If the fault-queue has more than 128 entries then the fault-queue base address must be naturally aligned to 2<sup>LOG2SZ</sup> x 32.
9:5reservedWPRIReserved for standard use
53:10PPNWARLHolds the PPN of the root page of the in-memory fault-queue used by IOMMU to queue fault record. If the base address as determined by PPN is not aligned as required, all entries in the queue appear to an IOMMU as UNSPECIFIED and any address an IOMMU may compute and use for accessing an entry in the queue is also UNSPECIFIED.
63:54reservedWPRIReserved for standard use
note

In RV32, only the low order 32-bits of the register (22-bit PPN and 5-bit LOG2SZ-1) need to be written.

6.10 Fault queue head (fqh)

This 32-bit register (RW) holds the index into the fault-queue where the software will fetch the next fault record.

54b95e98b1b2f46335651db557a19a2b

BitsFieldAttributeDescription
31:0indexWARLHolds the index into the fault-queue from which software reads the next fault record. Only LOG2SZ-1:0 bits are writable.

6.11 Fault queue tail (fqt)

This 32-bit register (RO) holds the index into the fault-queue where the IOMMU queues the next fault record.

54b95e98b1b2f46335651db557a19a2b

BitsFieldAttributeDescription
31:0indexROHolds the index into the fault-queue where IOMMU writes the next fault record.

6.12 Page-request-queue base (pqb)

This 64-bit register (WARL) holds the PPN of the root page of the page-request-queue and number of entries in the queue. Each "Page Request" message is 16 bytes.

The IOMMU behavior on writing pqb when pqcsr.busy or pqon bits are 1 is UNSPECIFIED. The software recommended sequence to change pqb is to first disable the page-request-queue by clearing pqen and wait for both pqcsr.busy and pqon to be 0 before changing the pqb. The status of bits 31:pqb.LOG2SZ in pqh following a write to pqb is 0 and the bits pqb.LOG2SZ-1:0 in pqh assume a valid but otherwise UNSPECIFIED value.

533f5975ffc00e00cc2b6127abf0c559

BitsFieldAttributeDescription
4:0LOG2SZ-1WARLThe LOG2SZ-1 field holds the number of entries in the page-request-queue as a log-to-base-2 minus 1. A value of 0 indicates a queue of 2 entries. Each page-request is 16-bytes. If the page-request-queue has 256 or fewer entries then the base address of the queue is always aligned to 4-KiB. If the page-request-queue has more than 256 entries then the page-request-queue base address must be naturally aligned to 2<sup>LOG2SZ</sup> x 16.
9:5reservedWPRIReserved for standard use
53:10PPNWARLHolds the PPN of the root page of the in-memory page-request-queue used by IOMMU to queue "Page Request" messages. If the base address as determined by PPN is not aligned as required, all entries in the queue appear to an IOMMU as UNSPECIFIED and any address an IOMMU may compute and use for accessing an entry in the queue is also UNSPECIFIED.
63:54reservedWPRIReserved for standard use
note

In RV32, only the low order 32-bits of the register (22-bit PPN and 5-bit LOG2SZ-1) need to be written.

6.13 Page-request-queue head (pqh)

This 32-bit register (RW) holds the index into the page-request-queue where software will fetch the next page-request.

54b95e98b1b2f46335651db557a19a2b

BitsFieldAttributeDescription
31:0indexWARLHolds the index into the page-request-queue from which software reads the next "Page Request" message. Only LOG2SZ-1:0 bits are writable.

6.14 Page-request-queue tail (pqt)

This 32-bit register (RO) holds the index into the page-request-queue where the IOMMU writes the next page-request.

54b95e98b1b2f46335651db557a19a2b

BitsFieldAttributeDescription
31:0indexROHolds the index into the page-request-queue where IOMMU writes the next "Page Request" message.

6.15 Command-queue CSR (cqcsr)

This 32-bit register (RW) is used to control the operations and report the status of the command-queue.

f01a626bafcbcf74f0c84f5b37aeb654

BitsFieldAttributeDescription
0cqenRWThe command-queue-enable bit enables the command- Changing cqen from 0 to 1 sets the cqh register and the cqcsr bits cmd_ill,cmd_to, cqmf, fence_w_ip to 0. The command-queue may take some time to be active following setting the cqen to 1. During this delay the busy bit is 1. When the command queue is active, the cqon bit When cqen is changed from 1 to 0, the command queue may stay active (with busy asserted) until the commands already fetched from the command-queue are being processed and/or there are outstanding implicit loads from the command-queue. When the command-queue turns off the cqon bit reads 0. When the cqon bit reads 0, the IOMMU guarantees that no implicit memory accesses to the command queue are in-flight and the command-queue will not generate new implicit loads to the queue memory.
1cieRWCommand-queue-interrupt-enable bit enables generation of interrupts from command-queue when set to 1.
7:2reservedWPRIReserved for standard use
8cqmfRW1CIf command-queue access to fetch a command or a memory access made by a command leads to a memory fault, then the command-queue-memory-fault bit is set to 1, and the command-queue stalls until this bit is cleared. To re-enable command processing, software should clear this bit by writing 1.
9cmd_toRW1CIf the execution of a command leads to a timeout (e.g. a command to invalidate device ATC may timeout waiting for a completion), then the command-queue sets the cmd_to bit and stops processing from the command-queue. To re-enable command processing, software should clear this bit by writing 1.
10cmd_illRW1CIf an illegal or unsupported command is fetched and decoded by the command-queue then the command-queue sets the cmd_ill bit and stops processing from the command-queue. To re-enable command processing software should clear this bit by writing 1.
11fence_w_ipRW1CAn IOMMU that supports wire-signaled-interrupts sets the fence_w_ip bit to indicate completion of an IOFENCE.C command. To re-enable interrupts on IOFENCE.C completion, software should clear this bit by writing 1. This bit is reserved if the IOMMU does not support wire-signaled-interrupts or wire-signaled-interrupts are not enabled (i.e., fctl.WSI == 0).
15:12reservedWPRIReserved for standard use
16cqonROThe command-queue is active if cqon is 1.
17busyROA write to cqcsr may require the IOMMU to perform many operations that may not occur synchronously to the write. When a write is observed by the When the busy bit is 1, behavior of additional writes to the cqcsr is UNSPECIFIED. Some implementations may ignore the second write and others may perform the actions determined by the Software must verify that the busy bit is 0 before An IOMMU that can complete these operations synchronously may hard-wire this bit to 0.
27:18reservedWPRIReserved for standard use.
31:28customWPRIDesignated for custom use.

When cmd_ill or cqmf is 1 in cqcsr, the cqh references the command in the CQ that caused the error. Previous commands may have completed, timed out, or their execution aborted by the IOMMU.

note

If software makes the CQ operational again after a cmd_ill or cqmf error, then software should resubmit the commands submitted since the last IOFENCE.C that successfully completed.

The cmd_to bit is set when a IOFENCE.C command detects that one or more previous commands that are specified to have timeouts have timed out but all other commands previous to the IOFENCE.C have completed. When cmd_to is 1, cqh references the IOFENCE.C command that detected the timeout.

note

Command-queue being empty does not imply that all commands fetched from the command-queue have been completed. When the command-queue is requested to be disabled, an implementation may either complete the already fetched commands or abort execution of those commands. Software must use an IOFENCE.C command to wait for all previous commands to be committed, if so desired, before turning off the command-queue.

6.16 Fault queue CSR (fqcsr)

This 32-bit register (RW) is used to control the operations and report the status of the fault-queue.

1bfbda5afaa95a2c25ef9aefba64553b

BitsFieldAttributeDescription
0fqenRWThe fault-queue enable bit enables the fault-queue Changing fqen from 0 to 1 sets the fqt register and the fqcsr bits fqof and fqmf to 0. The fault-queue may take some time to be active following setting the fqen to 1. During this delay the busy bit is 1. When the fault queue is active, When fqen is changed from 1 to 0, the fault-queue may stay active (with busy asserted) until in-flight fault-recording is completed. When the fault-queue is off the fqon bit reads 0. When fqon reads 0, the IOMMU guarantees that there are no in-flight implicit writes to the fault-queue in progress and that no new fault records will be written to the fault-queue.
1fieRWFault queue interrupt enable bit enables generation of interrupts from fault-queue when set to 1.
7:2reservedWPRIReserved for standard use
8fqmfRW1CThe fqmf bit is set to 1 if the IOMMU encounters an access fault when storing a fault record to the fault queue. The fault-record that was attempted to be written is discarded and no more fault records are generated until software clears the fqmf bit by writing 1 to the bit.
9fqofRW1CThe fault-queue-overflow bit is set to 1 if the IOMMU needs to queue a fault record but the The fault-record is discarded and no more fault records are generated until software clears fqof by writing 1 to the bit.
15:10reservedWPRIReserved for standard use
16fqonROThe fault-queue is active if fqon reads 1.
17busyROWrite to fqcsr may require the IOMMU to perform many operations that may not occur synchronously to the write. When a write is observed by the fqcsr, the busy bit is set to 1. When the busy bit is 1, behavior of additional writes to the fqcsr are UNSPECIFIED. Some implementations may ignore the second write and others may perform the Software should ensure that the busy bit is 0 An IOMMU that can complete controls synchronously may hard-wire this bit to 0.
27:18reservedWPRIReserved for standard use.
31:28customWPRIDesignated for custom use.

6.17 Page-request-queue CSR (pqcsr)

This 32-bit register (RW) is used to control the operations and report the status of the page-request-queue.

f8045a496f01bc57852aa83a611350b4

BitsFieldAttributeDescription
0pqenRWThe page-request-enable bit enables the Changing pqen from 0 to 1, sets the pqt register and the pqcsr bits pqmf and pqof to 0. The page-request-queue may take some time to be active following setting the pqen to 1. During this delay the busy bit is 1. When the page-request-queue is active, the pqon bit When pqen is changed from 1 to 0, the page-request-queue may stay active (with busy asserted) until in-flight page-request writes are completed. When the page-request-queue turns off, When pqon reads 0, the IOMMU guarantees that there are no older in-flight implicit writes to the queue memory and no further implicit writes The IOMMU may respond to “Page Request” messages received when page-request-queue is off or in the process of being turned off, as specified in Section 3.7.
1pieRWThe page-request-queue-interrupt-enable bit when set to 1, enables generation of interrupts from page-request-queue.
7:2reservedWPRIReserved for standard use
8pqmfRW1CThe pqmf bit is set to 1 if the IOMMU encounters an access fault when storing a The "Page Request" message that caused the pqmf or pqof error and all subsequent "Page Request" messages are discarded until software clears the The IOMMU may respond to “Page Request” messages that caused the pqof or pqmf bit to be set and all subsequent “Page Request” messages received while these bits are 1 as specified in Section 3.7.
9pqofRW1CThe page-request-queue-overflow bit is set to 1 if the page-request queue overflows i.e. IOMMU needs to queue a "Page Request" message but the page-request queue is full The "Page Request" message that caused the pqmf or pqof error and all subsequent "Page Request" messages are discarded until software clears the The IOMMU may respond to “Page Request” messages that caused the pqof or pqmf bit to be set and all subsequent “Page Request” messages received while these bits are 1 as specified in Section 3.7.
15:10reservedWPRIReserved for standard use
16pqonRO
17busyROA write to pqcsr may require the IOMMU to perform many operations that may not occur synchronously to the write. When a write is observed by the pqcsr, the busy bit is set When the busy bit is 1, behavior of additional writes to the pqcsr are UNSPECIFIED. Some implementations may ignore the second write and others may perform the actions determined by the second write. Software should ensure that the An IOMMU that can complete controls synchronously may hard-wire this bit to 0
27:18reservedWPRIReserved for standard use
31:28customWPRIDesignated for custom use.

6.18 Interrupt pending status register (ipsr)

This 32-bit register (RW1C) reports the pending interrupts which require software service. Each interrupt-pending bit in the register corresponds to a interrupt source in the IOMMU. The interrupt-pending bit in the register once set to 1 stays 1 till software clears that interrupt-pending bit by writing 1 to clear it.

When fctl.WSI is 1, the interrupt-pending bit drives the wire selected by the corresponding icvec field to signal an interrupt.

When fctl.WSI is 0, the IOMMU signals interrupts using messages. MSI have edge semantics and an interrupt message is generated when an interrupt-pending bit transitions from 0 to 1. The address and data for the message are obtained from the msi_cfg_tbl entry selected by the icvec field corresponding to the interrupt-pending bit.

f7c97a67dfeade3cebeaf68495d6b7de

Table 16. Interrupt pending status register fields

BitsFieldAttributeDescription
0cipRW1CThe command-queue-interrupt-pending bit is set to 1 if cqcsr.cie is 1 and any of the following are true: - cqcsr.fence_w_ip is 1. - cqcsr.cmd_ill is 1. - cqcsr.cmd_to is 1. - cqcsr.cqmf is 1.
1fipRW1CThe fault-queue-interrupt-pending bit is set to 1 if fqcsr.fie is 1 and any of the following are true: - fqcsr.fqof is 1. - fqcsr.fqmf is 1. - A new record is produced in the FQ.
2pmipRW1CThe performance-monitoring-interrupt-pending bit is set to 1 when the OF bit in iohpmcycles or in any of the iohpmevt1-31 registers transitions from 0 to 1 due to a counter overflow.
3pipRW1CThe page-request-queue-interrupt-pending is set to 1 if pqcsr.pie is 1 and any of the following are true: - pqcsr.pqof is 1. - pqcsr.pqmf is 1. - A new message is produced in the PQ.
7:4reservedWPRIReserved for standard use.
15:8customWPRIDesignated for custom use.
31:16reservedWPRIReserved for standard use

If a bit in ipsr is 1 then a write of 1 to the bit transitions the bit from 1→0. If the conditions to set that bit are still present (See Table 16) or if they occur after the bit is cleared then that bit transitions again from 0→1.

6.19 Performance-monitoring counter overflow status (iocountovf)

The performance-monitoring counter overflow status is a 32-bit read-only register that contains shadow copies of the OF bits in the iohpmevt1-31 registers - where iocountovf bit X corresponds to iohpmevtX and bit 0 corresponds to the OF bit of iohpmcycles.

This register enables overflow interrupt handler software to quickly and easily determine which counter(s) have overflowed.

f3929075110bcb162c559480323b31d4

BitsFieldAttributeDescription
0CYROShadow of iohpmcycles.OF
31:1HPMROShadow of iohpmevt[1-31].OF

6.20 Performance-monitoring counter inhibits (iocountinh)

The performance-monitoring counter inhibits is a 32-bit WARL register that contains bits to inhibit the corresponding counters from counting. Bit X when set inhibits counting in iohpmctrX and bit 0 inhibits counting in iohpmcycles.

f3929075110bcb162c559480323b31d4

BitsFieldAttributeDescription
0CYRWWhen set, iohpmcycles counter is inhibited from counting.
31:1HPMWARLWhen bit X is set, then counting of events in iohpmctrX is inhibited.
note

When the iohpmcycles counter is not needed, it is desirable to conditionally inhibit it to reduce energy consumption. Providing a single register to inhibit all counters allows a) one or more counters to be atomically programmed with events to count b) one or more counters to be sampled atomically.

To initialize an event counter or the cycles counter to a desired value, it should be first inhibited if it is enabled to count. This measure ensures that it does not count during the update process. The inhibition should be removed after the register has been programmed with the desired value.

6.21 Performance-monitoring cycles counter (iohpmcycles)

This 64-bit register is a free running clock cycle counter. There is no associated iohpmevt0.

2203a18bdedd45a3fba28b95e3e9569f

BitsFieldAttributeDescription
62:0counterWARLCycles counter value.
63OFRWOverflow

The OF bit is set when the iohpmcycles counter overflows, and remains set until cleared by software. Since iohpmcycles value is an unsigned value, overflow is defined as unsigned overflow. Note that there is no loss of information after an overflow since the counter wraps around and keeps counting while the sticky OF bit remains set.

If the iohpmcycles counter overflows when the OF bit is zero, then a HPM Counter Overflow interrupt is generated by setting ipsr.pmip bit to 1. If the OF bit is already one, then no interrupt request is generated. Consequently the OF bit also functions as a count overflow interrupt disable for the iohpmcycles.

6.22 Performance-monitoring event counters (iohpmctr1-31)

These registers are 64-bit WARL counter registers.

54c89e56982ca5469d0473d14ae57365

BitsFieldAttributeDescription
63:0counterWARLEvent counter value.

6.23 Performance-monitoring event selectors (iohpmevt1-31)

These performance-monitoring event registers are 64-bit RW registers. When a transaction processed by the IOMMU causes an event that is programmed to count in a counter then the counter is incremented. In addition to matching events, the event selector may be programmed with additional filters based on device_id, process_id, GSCID, and PSCID such that the counter is incremented conditionally based on the transaction matching these additional filters. When such device_id based filtering is used, the match may be configured to be a precise match or a partial match. A partial match allows transactions with a range of IDs to be counted by the counter.

13835a9c0de1e8e98dd4c1d3a9d3b30f

BitsFieldAttributeDescription
14:0eventIDWARLIndicates the event to count. A value of 0 Encodings 1 to 16383 are reserved for standard Encodings 16384 to 32767 are for designated for When eventID is changed, including to 0, the counter retains its value.
15DMASKRWWhen set to 1, partial matching of the DID_GSCID is performed for the transaction. The lower bits of the DID_GSCID all the way to the first low order 0 bit (including the 0 bit position itself) are masked.
35:16PID_PSCIDRWprocess_id if IDT is 0, PSCID if IDT is 1
59:36DID_GSCIDRWdevice_id if IDT is 0, GSCID if IDT is 1.
60PV_PSCVRWIf set, only transactions with matching process_id or PSCID (based on the Filter ID Type) are counted.
61DV_GSCVRWIf set, only transactions with matching device_id or GSCID (based on the Filter ID Type) are counted.
62IDTRWFilter ID Type: This field indicates the type of ID to filter on. When 0, the DID_GSCID field holds a device_id and the PID_PSCID field holds a process_id. When 1, the DID_GSCID field holds a GSCID and PID_PSCID field holds a PSCID.
63OFRWOverflow status or Interrupt disable

The table below summarizes the filtering option for events that support filtering by IDs.

Table 17. filtering options

IDTDV_GSCVPV_PSCVOperation
0/100Counter increments. No ID based filtering.
001If the transaction has a valid process_id, counter increments if process_id matches PID_PSCID.
010Counter increments if device_id matches DID_GSCID.
011If the transaction has a valid process_id, counter increments if device_id matches DID_GSCID and process_id matches PID_PSCID.
101If the transaction has a valid PSCID, counter increments if the PSCID of that process matches PID_PSCID.
110Counter increments if GSCID is valid and matches DID_GSCID.
111Counter increments if GSCID is valid and matches DID_GSCID and if PSCID is valid and matches PID_PSCID.

When filtering by device_id or GSCID is selected and the event supports ID based filtering, the DMASK field can be used to configure a partial match. When DMASK is set to 1, partial matching of the DID_GSCID is performed for the transaction. The lower bits of the DID_GSCID all the way to the first low order 0 bit (including the 0 bit position itself) are masked.

The following example illustrates the use of DMASK and filtering by device_id.

Table 18. DMASK with IDT set to device_id based filtering

DMASKDID_GSCIDComment
0yyyyyyyy yyyyyyyy yyyyyyyyOne specific seg🚌dev:func
1yyyyyyyy yyyyyyyy yyyyy011seg:bus:dev - any func
1yyyyyyyy yyyyyyyy 01111111seg:bus - any dev:func
1yyyyyyyy 01111111 11111111seg - any bus:dev:func

The following table lists the standard events that can be counted:

Table 19. Standard Events list

eventIDEvent countedIDT settings supported
0Do not count
1Untranslated requests0
2Translated requests0
3ATS Translation requests0
4TLB miss0/1
5Device Directory Walks0
6Process Directory Walks0
7First-stage Page Table Walks0/1
8Second-stage Page Table Walks0/1
9 - 16383reserved for future standard-

When the programmed IDT setting is not supported for an event then the associated counter does not increment.

The OF bit is set when the corresponding iohpmctr1-31 counter overflows, and remains set until cleared by software. Since iohpmctr1-31 values are unsigned values, overflow is defined as unsigned overflow. Note that there is no loss of information after an overflow since the counter wraps around and keeps counting while the sticky OF bit remains set.

If a iohpmctr1-31 counter overflows when the associated OF bit is zero, then a HPM Counter Overflow interrupt is generated by setting ipsr.pmip bit to 1. If the OF bit is already one, then no interrupt request is generated. Consequently the OF bit also functions as a count overflow interrupt disable for the associated iohpmctr1-31.

note

There are not separate overflow status and overflow interrupt enable bits. In practice, enabling overflow interrupt generation (by clearing the OF bit) is done in conjunction with initializing the counter to a starting value. Once a counter has overflowed, it and the OF bit must be reinitialized before another overflow interrupt can be generated.

note

In RV32, memory-mapped writes to iohpmevt1-31 modify only one 32-bit part of the register. The following sequence may be used to update the register without counting events spuriously due to the intermediate value of the register:

  • Write the low order 32-bits to set eventID to 0.
  • Write the high order 32-bits with the new desired values.
  • Write the low order 32-bits the new desired values, including that of the eventID field.

Alternatively, the counter may first be inhibited such that no events count during the update and the inhibit removed after the register has been programmed with the desired value.

note

If capabilities.HPM is 1 then a minimum of one programmable event counter besides the cycles counter is required to comply with this specification. One counter may be used in a time multiplexed manner to sample events but such analysis may take longer to complete. The IOMMU, unlike the CPU MMU, services multiple streams of IO and the HPM may be used by a performance analyst to analyze one or more of those streams concurrently. Typically, a performance analyst may require four programmable counters to count events for an IO stream. To support concurrent analysis of at least two streams of IO it is recommended to support seven programmable counters.

6.24 Translation-request IOVA (tr_req_iova)

The tr_req_iova is a 64-bit register used to implement a translation-request interface for debug. This register is present when capabilities.DBG == 1.

99452e80b760b3f94420a67fb2d98123

BitsFieldAttributeDescription
11:0reservedWPRIReserved for standard use
63:12vpnWARLThe IOVA virtual page number

6.25 Translation-request control (tr_req_ctl)

The tr_req_ctl is a 64-bit WARL register used to implement a translation-request interface for debug. This register is present when capabilities.DBG == 1.

1c3675573f4d5e11622a4d68ae1cbc79

BitsFieldAttributeDescription
0Go/BusyRW1SThis bit is set to indicate a valid request has been setup in the tr_req_iova/tr_req_ctl registers The IOMMU indicates completion of the requested translation by clearing this bit to 0. On completion, the results of the translation are in the tr_response register.
1PrivWARLIf set to 1, Privileged Mode access is requested; otherwise, Privileged Mode access is not requested. When PV is 0, this field is ignored and no Privileged Mode access is requested.
2ExeWARLIf set to 1, execute permission is requested else execute permission is not requested. If Exe is set to 1, then NW must be also be set to 1; otherwise the behavior is UNSPECIFIED.
3NWWARLIf set to 1, read permission is requested. If set to 0, both read and write permissions are requested.
11:4reservedWPRIReserved for standard use
31:12PIDWARLIf PV is 1, this field provides the process_id input for this translation request. If PV is 0 then this field is not used.
32PVWARLIf set to 1, the PID field of the register is valid and provides the process_id for this translation request. If set to 0 then the PID field is not used and a process_id is not valid for this translation request.
35:33reservedWPRIReserved for standard use.
39:36customWPRIDesignated for custom use.
63:40DIDWARLThis field provides the device_id for this translation request.
note

In RV32, the high half of the register should be written first, followed by the low half, which includes the Go/Busy bit, to initiate a translation.

6.26 Translation-response (tr_response)

The tr_response is a 64-bit RO register used to hold the results of a translation requested using the translation-request interface. This register is present when capabilities.DBG == 1.

b30f6c8feab1bfad6888c38e8812f544

BitsFieldAttributeDescription
0faultROIf the process to translate the IOVA detects a fault then the fault field is set to 1. The detected fault may be reported through the fault-queue.
6:1reservedROReserved for standard use
8:7PBMTROMemory type determined for the translation using the PBMT fields in the first-stage and/or the second-stage page tables used for the translation. This value of this field is UNSPECIFIED if the fault field is 1.
9SROTranslation range size field, when set to 1 indicates that the translation applies to a range that is larger than 4 KiB and the size of the translation range is encoded in the PPN field. The value of this field is UNSPECIFIED if the fault field is 1.
53:10PPNROIf the fault bit is 0, then this field provides the PPN determined as a result of If the fault bit is 1, then the value of If the S bit is 0, then the size of the If the S bit is 1, then the translation resulted in a superpage, and the size of the superpage is encoded in the PPN itself. If scanning from bit position 0 to bit position 43, the first bit with a value of 0 at position X, then the superpage size is If X is not 0, then all bits at position 0 through X-1 are each encoded with a value of 1.

Table 20. Example of encoding of super page size in PPN

| PPN | S | Size | | --- | --- | --- | | yyyy&#8230;&#8203;.yyyy yyyy yyyy | 0 | 4 KiB | | yyyy&#8230;&#8203;.yyyy yyyy 0111 | 1 | 64 KiB | | yyyy&#8230;&#8203;.yyy0 1111 1111 | 1 | 2 MiB | | yyyy&#8230;&#8203;.yy01 1111 1111 | 1 | 4 MiB |
59:54reservedROReserved for standard use.
63:60customRODesignated for custom use.
note

An IOMMU implementation is not required to report a superpage translation or support reporting all possible superpage sizes. An implementation is allowed to report a 4 KiB translation corresponding to the requested vpn or report a translation size that is smaller than the superpage size configured in the page tables.

6.27 IOMMU QoS ID (iommu_qosid)

The iommu_qosid register fields are defined as follows:

e114dfdf984d642b5acf809878606597

BitsFieldAttributeDescription
11:0RCIDWARLRCID for IOMMU-initiated requests.
15:12reservedWPRIReserved for standard use.
27:16MCIDWARLMCID for IOMMU-initiated requests.
31:28reservedWPRIReserved for standard use.

IOMMU-initiated requests for accessing the following data structures use the value programmed in the RCID and MCID fields of the iommu_qosid register.

  • Device directory table (DDT)
  • Fault queue (FQ)
  • Command queue (CQ)
  • Page-request queue (PQ)
  • IOMMU-initiated MSI (Message-signaled interrupts)

When ddtp.iommu_mode == Bare, all device-originated requests are associated with the QoS IDs configured in the iommu_qosid register.

6.28 Interrupt-cause-to-vector register (icvec)

Interrupt-cause-to-vector register maps a cause to a vector. All causes can be mapped to the same vector or a cause can be given a unique vector.

The vector is used:

  1. By an IOMMU that generates interrupts as MSIs, to index into MSI configuration table (msi_cfg_tbl) to determine the MSI to generate. An IOMMU is capable of generating interrupts as a MSI if capabilities.IGS==MSI or if capabilities.IGS==BOTH. When capabilities.IGS==BOTH the IOMMU may be configured to generate interrupts as MSI by setting fctl.WSI to 0.
  2. By an IOMMU that generates WSI, to determine the wire to signal the interrupt. An IOMMU is capable of generating wire-signaled- interrupts if capabilities.IGS==WSI or if capabilities.IGS==BOTH. When capabilities.IGS==BOTH the IOMMU may be configured to generate wire-signaled- interrupts by setting fctl.WSI to 1.

If an implementation only supports a single vector then all bits of this register may be hardwired to 0 (WARL). Likewise if only two vectors are supported then only bit 0 for each cause could be writable.

b9cae9a70bf12969e73456c1b4c62757

BitsFieldAttributeDescription
3:0civWARLThe command-queue-interrupt-vector (civ) is the vector number assigned to the command-queue-interrupt.
7:4fivWARLThe fault-queue-interrupt-vector (fiv) is the vector number assigned to the fault-queue-interrupt.
11:8pmivWARLThe performance-monitoring-interrupt-vector (pmiv) is the vector number assigned to the performance-monitoring-interrupt.
15:12pivWARLThe page-request-queue-interrupt-vector (piv) is the vector number assigned to the page-request-queue-interrupt.
31:16reservedWPRIReserved for standard use.
63:32customWPRIDesignated for custom use.

6.29 MSI configuration table (msi_cfg_tbl)

An IOMMU that supports generating IOMMU-originated interrupts (i.e., capabilities.IGS == MSI or capabilities.IGS == BOTH) as MSIs implements a MSI configuration table that is indexed by the vector from icvec to determine a MSI table entry. Each MSI table entry for interrupt vector x has three registers msi_addr_x, msi_data_x, and msi_vec_ctl_x. These registers are hardwired to 0 if capabilities.IGS == WSI.

If an access fault is detected on a MSI write using msi_addr_x, then the IOMMU reports a "IOMMU MSI write access fault" (cause 273) fault, with TTYP set to 0 and iotval set to the value of msi_addr_x.

Table 21. MSI configuration table structure

bit 63bit 0Byte Offset
Entry 0: Message address+000h
Entry 0: Vector ControlEntry 0: Message Data+008h
Entry 1: Message address+010h
Entry 1: Vector ControlEntry 1: Message Data+018h
…​+020h

253e683a4c34638e1d68a7153766610e

BitsFieldAttributeDescription
1:00ROFixed to 0
55:2ADDRWARLHolds the 4-byte aligned MSI address.
63:56reservedWPRIReserved for standard use.

c1b5e5967d8c43dbc6a83af2c45aea8e

BitsFieldAttributeDescription
31:0dataWARLHolds the MSI data

d685b3e639b844a62c78b0c780644df0

BitsFieldAttributeDescription
0MRWWhen the mask bit M is 1, the corresponding interrupt vector is masked and the IOMMU is prohibited from sending the associated message. Pending messages for that vector are later generated if the corresponding mask bit is cleared to 0.
31:1reservedWPRIReserved for standard use.