1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * IOMMU user API definitions
9 #include <linux/types.h>
11 #define IOMMU_FAULT_PERM_READ (1 << 0) /* read */
12 #define IOMMU_FAULT_PERM_WRITE (1 << 1) /* write */
13 #define IOMMU_FAULT_PERM_EXEC (1 << 2) /* exec */
14 #define IOMMU_FAULT_PERM_PRIV (1 << 3) /* privileged */
16 /* Generic fault types, can be expanded IRQ remapping fault */
17 enum iommu_fault_type {
18 IOMMU_FAULT_DMA_UNRECOV = 1, /* unrecoverable fault */
19 IOMMU_FAULT_PAGE_REQ, /* page request fault */
22 enum iommu_fault_reason {
23 IOMMU_FAULT_REASON_UNKNOWN = 0,
25 /* Could not access the PASID table (fetch caused external abort) */
26 IOMMU_FAULT_REASON_PASID_FETCH,
28 /* PASID entry is invalid or has configuration errors */
29 IOMMU_FAULT_REASON_BAD_PASID_ENTRY,
32 * PASID is out of range (e.g. exceeds the maximum PASID
33 * supported by the IOMMU) or disabled.
35 IOMMU_FAULT_REASON_PASID_INVALID,
38 * An external abort occurred fetching (or updating) a translation
41 IOMMU_FAULT_REASON_WALK_EABT,
44 * Could not access the page table entry (Bad address),
45 * actual translation fault
47 IOMMU_FAULT_REASON_PTE_FETCH,
49 /* Protection flag check failed */
50 IOMMU_FAULT_REASON_PERMISSION,
52 /* access flag check failed */
53 IOMMU_FAULT_REASON_ACCESS,
55 /* Output address of a translation stage caused Address Size fault */
56 IOMMU_FAULT_REASON_OOR_ADDRESS,
60 * struct iommu_fault_unrecoverable - Unrecoverable fault data
61 * @reason: reason of the fault, from &enum iommu_fault_reason
62 * @flags: parameters of this fault (IOMMU_FAULT_UNRECOV_* values)
63 * @pasid: Process Address Space ID
64 * @perm: requested permission access using by the incoming transaction
65 * (IOMMU_FAULT_PERM_* values)
66 * @addr: offending page address
67 * @fetch_addr: address that caused a fetch abort, if any
69 struct iommu_fault_unrecoverable {
71 #define IOMMU_FAULT_UNRECOV_PASID_VALID (1 << 0)
72 #define IOMMU_FAULT_UNRECOV_ADDR_VALID (1 << 1)
73 #define IOMMU_FAULT_UNRECOV_FETCH_ADDR_VALID (1 << 2)
82 * struct iommu_fault_page_request - Page Request data
83 * @flags: encodes whether the corresponding fields are valid and whether this
84 * is the last page in group (IOMMU_FAULT_PAGE_REQUEST_* values).
85 * When IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID is set, the page response
86 * must have the same PASID value as the page request. When it is clear,
87 * the page response should not have a PASID.
88 * @pasid: Process Address Space ID
89 * @grpid: Page Request Group Index
90 * @perm: requested page permissions (IOMMU_FAULT_PERM_* values)
92 * @private_data: device-specific private information
94 struct iommu_fault_page_request {
95 #define IOMMU_FAULT_PAGE_REQUEST_PASID_VALID (1 << 0)
96 #define IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE (1 << 1)
97 #define IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA (1 << 2)
98 #define IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID (1 << 3)
104 __u64 private_data[2];
108 * struct iommu_fault - Generic fault data
109 * @type: fault type from &enum iommu_fault_type
110 * @padding: reserved for future use (should be zero)
111 * @event: fault event, when @type is %IOMMU_FAULT_DMA_UNRECOV
112 * @prm: Page Request message, when @type is %IOMMU_FAULT_PAGE_REQ
113 * @padding2: sets the fault size to allow for future extensions
119 struct iommu_fault_unrecoverable event;
120 struct iommu_fault_page_request prm;
126 * enum iommu_page_response_code - Return status of fault handlers
127 * @IOMMU_PAGE_RESP_SUCCESS: Fault has been handled and the page tables
128 * populated, retry the access. This is "Success" in PCI PRI.
129 * @IOMMU_PAGE_RESP_FAILURE: General error. Drop all subsequent faults from
130 * this device if possible. This is "Response Failure" in PCI PRI.
131 * @IOMMU_PAGE_RESP_INVALID: Could not handle this fault, don't retry the
132 * access. This is "Invalid Request" in PCI PRI.
134 enum iommu_page_response_code {
135 IOMMU_PAGE_RESP_SUCCESS = 0,
136 IOMMU_PAGE_RESP_INVALID,
137 IOMMU_PAGE_RESP_FAILURE,
141 * struct iommu_page_response - Generic page response information
142 * @argsz: User filled size of this data
143 * @version: API version of this structure
144 * @flags: encodes whether the corresponding fields are valid
145 * (IOMMU_FAULT_PAGE_RESPONSE_* values)
146 * @pasid: Process Address Space ID
147 * @grpid: Page Request Group Index
148 * @code: response code from &enum iommu_page_response_code
150 struct iommu_page_response {
152 #define IOMMU_PAGE_RESP_VERSION_1 1
154 #define IOMMU_PAGE_RESP_PASID_VALID (1 << 0)
161 #endif /* _UAPI_IOMMU_H */