History

Merge tag 'iommu-updates-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull iommu updates from Joerg Roedel: - Make the dma-iommu code more generic so that it can be used outside of the ARM context with other IOMMU drivers. Goal is to make use of it on x86 too. - Generic IOMMU domain support for the Intel VT-d driver. This driver now makes more use of common IOMMU code to allocate default domains for the devices it handles. - An IOMMU fault reporting API to userspace. With that the IOMMU fault handling can be done in user-space, for example to forward the faults to a VM. - Better handling for reserved regions requested by the firmware. These can be 'relaxed' now, meaning that those don't prevent a device being attached to a VM. - Suspend/Resume support for the Renesas IOMMU driver. - Added support for dumping SVA related fields of the DMAR table in the Intel VT-d driver via debugfs. - A pile of smaller fixes and cleanups. * tag 'iommu-updates-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (90 commits) iommu/omap: No need to check return value of debugfs_create functions iommu/arm-smmu-v3: Invalidate ATC when detaching a device iommu/arm-smmu-v3: Fix compilation when CONFIG_CMA=n iommu/vt-d: Cleanup unused variable iommu/amd: Flush not present cache in iommu_map_page iommu/amd: Only free resources once on init error iommu/amd: Move gart fallback to amd_iommu_init iommu/amd: Make iommu_disable safer iommu/io-pgtable: Support non-coherent page tables iommu/io-pgtable: Replace IO_PGTABLE_QUIRK_NO_DMA with specific flag iommu/io-pgtable-arm: Add support to use system cache iommu/arm-smmu-v3: Increase maximum size of queues iommu/vt-d: Silence a variable set but not used iommu/vt-d: Remove an unused variable "length" iommu: Fix integer truncation iommu: Add padding to struct iommu_fault iommu/vt-d: Consolidate domain_init() to avoid duplication iommu/vt-d: Cleanup after delegating DMA domain to generic iommu iommu/vt-d: Fix suspicious RCU usage in probe_acpi_namespace_devices() iommu/vt-d: Allow DMA domain attaching to rmrr locked device ...

Linus Torvalds committed 7 years ago

Commit 6b040142 parents c6b6ceb d95c38826 files · +1772 −1301Browse files

Showing the changes to include/uapi/linux (1 of 26 files). Show all

Unified · Split

include/uapi/linux/iommu.h+155−0
@@ -0,0 +1,155 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+/*
3+ * IOMMU user API definitions
4+ */
5+
6+#ifndef _UAPI_IOMMU_H
7+#define _UAPI_IOMMU_H
8+
9+#include <linux/types.h>
10+
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 */
15+
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 */
20+};
21+
22+enum iommu_fault_reason {
23+ IOMMU_FAULT_REASON_UNKNOWN = 0,
24+
25+ /* Could not access the PASID table (fetch caused external abort) */
26+ IOMMU_FAULT_REASON_PASID_FETCH,
27+
28+ /* PASID entry is invalid or has configuration errors */
29+ IOMMU_FAULT_REASON_BAD_PASID_ENTRY,
30+
31+ /*
32+ * PASID is out of range (e.g. exceeds the maximum PASID
33+ * supported by the IOMMU) or disabled.
34+ */
35+ IOMMU_FAULT_REASON_PASID_INVALID,
36+
37+ /*
38+ * An external abort occurred fetching (or updating) a translation
39+ * table descriptor
40+ */
41+ IOMMU_FAULT_REASON_WALK_EABT,
42+
43+ /*
44+ * Could not access the page table entry (Bad address),
45+ * actual translation fault
46+ */
47+ IOMMU_FAULT_REASON_PTE_FETCH,
48+
49+ /* Protection flag check failed */
50+ IOMMU_FAULT_REASON_PERMISSION,
51+
52+ /* access flag check failed */
53+ IOMMU_FAULT_REASON_ACCESS,
54+
55+ /* Output address of a translation stage caused Address Size fault */
56+ IOMMU_FAULT_REASON_OOR_ADDRESS,
57+};
58+
59+/**
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
68+ */
69+struct iommu_fault_unrecoverable {
70+ __u32 reason;
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)
74+ __u32 flags;
75+ __u32 pasid;
76+ __u32 perm;
77+ __u64 addr;
78+ __u64 fetch_addr;
79+};
80+
81+/**
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+ * @pasid: Process Address Space ID
86+ * @grpid: Page Request Group Index
87+ * @perm: requested page permissions (IOMMU_FAULT_PERM_* values)
88+ * @addr: page address
89+ * @private_data: device-specific private information
90+ */
91+struct iommu_fault_page_request {
92+#define IOMMU_FAULT_PAGE_REQUEST_PASID_VALID (1 << 0)
93+#define IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE (1 << 1)
94+#define IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA (1 << 2)
95+ __u32 flags;
96+ __u32 pasid;
97+ __u32 grpid;
98+ __u32 perm;
99+ __u64 addr;
100+ __u64 private_data[2];
101+};
102+
103+/**
104+ * struct iommu_fault - Generic fault data
105+ * @type: fault type from &enum iommu_fault_type
106+ * @padding: reserved for future use (should be zero)
107+ * @event: fault event, when @type is %IOMMU_FAULT_DMA_UNRECOV
108+ * @prm: Page Request message, when @type is %IOMMU_FAULT_PAGE_REQ
109+ * @padding2: sets the fault size to allow for future extensions
110+ */
111+struct iommu_fault {
112+ __u32 type;
113+ __u32 padding;
114+ union {
115+ struct iommu_fault_unrecoverable event;
116+ struct iommu_fault_page_request prm;
117+ __u8 padding2[56];
118+ };
119+};
120+
121+/**
122+ * enum iommu_page_response_code - Return status of fault handlers
123+ * @IOMMU_PAGE_RESP_SUCCESS: Fault has been handled and the page tables
124+ * populated, retry the access. This is "Success" in PCI PRI.
125+ * @IOMMU_PAGE_RESP_FAILURE: General error. Drop all subsequent faults from
126+ * this device if possible. This is "Response Failure" in PCI PRI.
127+ * @IOMMU_PAGE_RESP_INVALID: Could not handle this fault, don't retry the
128+ * access. This is "Invalid Request" in PCI PRI.
129+ */
130+enum iommu_page_response_code {
131+ IOMMU_PAGE_RESP_SUCCESS = 0,
132+ IOMMU_PAGE_RESP_INVALID,
133+ IOMMU_PAGE_RESP_FAILURE,
134+};
135+
136+/**
137+ * struct iommu_page_response - Generic page response information
138+ * @version: API version of this structure
139+ * @flags: encodes whether the corresponding fields are valid
140+ * (IOMMU_FAULT_PAGE_RESPONSE_* values)
141+ * @pasid: Process Address Space ID
142+ * @grpid: Page Request Group Index
143+ * @code: response code from &enum iommu_page_response_code
144+ */
145+struct iommu_page_response {
146+#define IOMMU_PAGE_RESP_VERSION_1 1
147+ __u32 version;
148+#define IOMMU_PAGE_RESP_PASID_VALID (1 << 0)
149+ __u32 flags;
150+ __u32 pasid;
151+ __u32 grpid;
152+ __u32 code;
153+};
154+
155+#endif /* _UAPI_IOMMU_H */