1 /* SPDX-License-Identifier: BSD-3-Clause */
3 * Virtio-iommu definition v0.9
5 * Copyright (C) 2018 Arm Ltd.
7 #ifndef _UAPI_LINUX_VIRTIO_IOMMU_H
8 #define _UAPI_LINUX_VIRTIO_IOMMU_H
10 #include <linux/types.h>
13 #define VIRTIO_IOMMU_F_INPUT_RANGE 0
14 #define VIRTIO_IOMMU_F_DOMAIN_BITS 1
15 #define VIRTIO_IOMMU_F_MAP_UNMAP 2
16 #define VIRTIO_IOMMU_F_BYPASS 3
17 #define VIRTIO_IOMMU_F_PROBE 4
19 struct virtio_iommu_range {
24 struct virtio_iommu_config {
25 /* Supported page sizes */
27 /* Supported IOVA range */
28 struct virtio_iommu_range input_range;
29 /* Max domain ID size */
32 /* Probe buffer size */
37 #define VIRTIO_IOMMU_T_ATTACH 0x01
38 #define VIRTIO_IOMMU_T_DETACH 0x02
39 #define VIRTIO_IOMMU_T_MAP 0x03
40 #define VIRTIO_IOMMU_T_UNMAP 0x04
41 #define VIRTIO_IOMMU_T_PROBE 0x05
44 #define VIRTIO_IOMMU_S_OK 0x00
45 #define VIRTIO_IOMMU_S_IOERR 0x01
46 #define VIRTIO_IOMMU_S_UNSUPP 0x02
47 #define VIRTIO_IOMMU_S_DEVERR 0x03
48 #define VIRTIO_IOMMU_S_INVAL 0x04
49 #define VIRTIO_IOMMU_S_RANGE 0x05
50 #define VIRTIO_IOMMU_S_NOENT 0x06
51 #define VIRTIO_IOMMU_S_FAULT 0x07
53 struct virtio_iommu_req_head {
58 struct virtio_iommu_req_tail {
63 struct virtio_iommu_req_attach {
64 struct virtio_iommu_req_head head;
68 struct virtio_iommu_req_tail tail;
71 struct virtio_iommu_req_detach {
72 struct virtio_iommu_req_head head;
76 struct virtio_iommu_req_tail tail;
79 #define VIRTIO_IOMMU_MAP_F_READ (1 << 0)
80 #define VIRTIO_IOMMU_MAP_F_WRITE (1 << 1)
81 #define VIRTIO_IOMMU_MAP_F_EXEC (1 << 2)
82 #define VIRTIO_IOMMU_MAP_F_MMIO (1 << 3)
84 #define VIRTIO_IOMMU_MAP_F_MASK (VIRTIO_IOMMU_MAP_F_READ | \
85 VIRTIO_IOMMU_MAP_F_WRITE | \
86 VIRTIO_IOMMU_MAP_F_EXEC | \
87 VIRTIO_IOMMU_MAP_F_MMIO)
89 struct virtio_iommu_req_map {
90 struct virtio_iommu_req_head head;
96 struct virtio_iommu_req_tail tail;
99 struct virtio_iommu_req_unmap {
100 struct virtio_iommu_req_head head;
105 struct virtio_iommu_req_tail tail;
108 #define VIRTIO_IOMMU_PROBE_T_NONE 0
109 #define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1
111 #define VIRTIO_IOMMU_PROBE_T_MASK 0xfff
113 struct virtio_iommu_probe_property {
118 #define VIRTIO_IOMMU_RESV_MEM_T_RESERVED 0
119 #define VIRTIO_IOMMU_RESV_MEM_T_MSI 1
121 struct virtio_iommu_probe_resv_mem {
122 struct virtio_iommu_probe_property head;
129 struct virtio_iommu_req_probe {
130 struct virtio_iommu_req_head head;
137 * Tail follows the variable-length properties array. No padding,
138 * property lengths are all aligned on 8 bytes.
143 #define VIRTIO_IOMMU_FAULT_R_UNKNOWN 0
144 #define VIRTIO_IOMMU_FAULT_R_DOMAIN 1
145 #define VIRTIO_IOMMU_FAULT_R_MAPPING 2
147 #define VIRTIO_IOMMU_FAULT_F_READ (1 << 0)
148 #define VIRTIO_IOMMU_FAULT_F_WRITE (1 << 1)
149 #define VIRTIO_IOMMU_FAULT_F_EXEC (1 << 2)
150 #define VIRTIO_IOMMU_FAULT_F_ADDRESS (1 << 8)
152 struct virtio_iommu_fault {