xref: /qemu/include/hw/i386/intel_iommu.h (revision 0e3327b690b76b7c3966b028110ee053cc16a385)
11da12ec4SLe Tan /*
21da12ec4SLe Tan  * QEMU emulation of an Intel IOMMU (VT-d)
31da12ec4SLe Tan  *   (DMA Remapping device)
41da12ec4SLe Tan  *
51da12ec4SLe Tan  * Copyright (C) 2013 Knut Omang, Oracle <knut.omang@oracle.com>
61da12ec4SLe Tan  * Copyright (C) 2014 Le Tan, <tamlokveer@gmail.com>
71da12ec4SLe Tan  *
81da12ec4SLe Tan  * This program is free software; you can redistribute it and/or modify
91da12ec4SLe Tan  * it under the terms of the GNU General Public License as published by
101da12ec4SLe Tan  * the Free Software Foundation; either version 2 of the License, or
111da12ec4SLe Tan  * (at your option) any later version.
121da12ec4SLe Tan 
131da12ec4SLe Tan  * This program is distributed in the hope that it will be useful,
141da12ec4SLe Tan  * but WITHOUT ANY WARRANTY; without even the implied warranty of
151da12ec4SLe Tan  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
161da12ec4SLe Tan  * GNU General Public License for more details.
171da12ec4SLe Tan 
181da12ec4SLe Tan  * You should have received a copy of the GNU General Public License along
191da12ec4SLe Tan  * with this program; if not, see <http://www.gnu.org/licenses/>.
201da12ec4SLe Tan  */
211da12ec4SLe Tan 
221da12ec4SLe Tan #ifndef INTEL_IOMMU_H
231da12ec4SLe Tan #define INTEL_IOMMU_H
24a27bd6c7SMarkus Armbruster 
251c7955c4SPeter Xu #include "hw/i386/x86-iommu.h"
2663b88968SPeter Xu #include "qemu/iova-tree.h"
27db1015e9SEduardo Habkost #include "qom/object.h"
281da12ec4SLe Tan 
291da12ec4SLe Tan #define TYPE_INTEL_IOMMU_DEVICE "intel-iommu"
308063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(IntelIOMMUState, INTEL_IOMMU_DEVICE)
311da12ec4SLe Tan 
321221a474SAlexey Kardashevskiy #define TYPE_INTEL_IOMMU_MEMORY_REGION "intel-iommu-iommu-memory-region"
331221a474SAlexey Kardashevskiy 
341da12ec4SLe Tan /* DMAR Hardware Unit Definition address (IOMMU unit) */
351da12ec4SLe Tan #define Q35_HOST_BRIDGE_IOMMU_ADDR  0xfed90000ULL
361da12ec4SLe Tan 
371da12ec4SLe Tan #define VTD_PCI_BUS_MAX             256
381da12ec4SLe Tan #define VTD_PCI_SLOT_MAX            32
391da12ec4SLe Tan #define VTD_PCI_FUNC_MAX            8
401da12ec4SLe Tan #define VTD_PCI_SLOT(devfn)         (((devfn) >> 3) & 0x1f)
411da12ec4SLe Tan #define VTD_PCI_FUNC(devfn)         ((devfn) & 0x07)
421e06f131SMichael S. Tsirkin #define VTD_SID_TO_BUS(sid)         (((sid) >> 8) & 0xff)
43d92fa2dcSLe Tan #define VTD_SID_TO_DEVFN(sid)       ((sid) & 0xff)
441da12ec4SLe Tan 
451da12ec4SLe Tan #define DMAR_REG_SIZE               0x230
4692e5d85eSPrasad Singamsetty #define VTD_HOST_AW_39BIT           39
4792e5d85eSPrasad Singamsetty #define VTD_HOST_AW_48BIT           48
48ddd84fd0SZhenzhong Duan #define VTD_HOST_ADDRESS_WIDTH      VTD_HOST_AW_48BIT
4992e5d85eSPrasad Singamsetty #define VTD_HAW_MASK(aw)            ((1ULL << (aw)) - 1)
50*2c746dfeSZhenzhong Duan #define VTD_MGAW_FROM_CAP(cap)      ((cap >> 16) & 0x3fULL)
511da12ec4SLe Tan 
52d46114f9SPeter Xu #define DMAR_REPORT_F_INTR          (1)
53d46114f9SPeter Xu 
54651e4cefSPeter Xu #define  VTD_MSI_ADDR_HI_MASK        (0xffffffff00000000ULL)
55651e4cefSPeter Xu #define  VTD_MSI_ADDR_HI_SHIFT       (32)
56651e4cefSPeter Xu #define  VTD_MSI_ADDR_LO_MASK        (0x00000000ffffffffULL)
57651e4cefSPeter Xu 
58d92fa2dcSLe Tan typedef struct VTDContextEntry VTDContextEntry;
59d92fa2dcSLe Tan typedef struct VTDContextCacheEntry VTDContextCacheEntry;
601da12ec4SLe Tan typedef struct VTDAddressSpace VTDAddressSpace;
61b5a280c0SLe Tan typedef struct VTDIOTLBEntry VTDIOTLBEntry;
62bc38ee10SMichael S. Tsirkin typedef union VTD_IR_TableEntry VTD_IR_TableEntry;
631f91aceeSPeter Xu typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress;
64fb43cf73SLiu, Yi L typedef struct VTDPASIDDirEntry VTDPASIDDirEntry;
65fb43cf73SLiu, Yi L typedef struct VTDPASIDEntry VTDPASIDEntry;
66d92fa2dcSLe Tan 
67d92fa2dcSLe Tan /* Context-Entry */
68d92fa2dcSLe Tan struct VTDContextEntry {
69fb43cf73SLiu, Yi L     union {
70fb43cf73SLiu, Yi L         struct {
71d92fa2dcSLe Tan             uint64_t lo;
72d92fa2dcSLe Tan             uint64_t hi;
73d92fa2dcSLe Tan         };
74fb43cf73SLiu, Yi L         struct {
75fb43cf73SLiu, Yi L             uint64_t val[4];
76fb43cf73SLiu, Yi L         };
77fb43cf73SLiu, Yi L     };
78fb43cf73SLiu, Yi L };
79d92fa2dcSLe Tan 
80d92fa2dcSLe Tan struct VTDContextCacheEntry {
81d92fa2dcSLe Tan     /* The cache entry is obsolete if
82d92fa2dcSLe Tan      * context_cache_gen!=IntelIOMMUState.context_cache_gen
83d92fa2dcSLe Tan      */
84d92fa2dcSLe Tan     uint32_t context_cache_gen;
85d92fa2dcSLe Tan     struct VTDContextEntry context_entry;
86d92fa2dcSLe Tan };
87d92fa2dcSLe Tan 
88fb43cf73SLiu, Yi L /* PASID Directory Entry */
89fb43cf73SLiu, Yi L struct VTDPASIDDirEntry {
90fb43cf73SLiu, Yi L     uint64_t val;
91fb43cf73SLiu, Yi L };
92fb43cf73SLiu, Yi L 
93fb43cf73SLiu, Yi L /* PASID Table Entry */
94fb43cf73SLiu, Yi L struct VTDPASIDEntry {
95fb43cf73SLiu, Yi L     uint64_t val[8];
96fb43cf73SLiu, Yi L };
97fb43cf73SLiu, Yi L 
981da12ec4SLe Tan struct VTDAddressSpace {
997df953bdSKnut Omang     PCIBus *bus;
1001da12ec4SLe Tan     uint8_t devfn;
1011b2b1237SJason Wang     uint32_t pasid;
1021da12ec4SLe Tan     AddressSpace as;
1033df9d748SAlexey Kardashevskiy     IOMMUMemoryRegion iommu;
1044b519ef1SPeter Xu     MemoryRegion root;          /* The root container of the device */
1054b519ef1SPeter Xu     MemoryRegion nodmar;        /* The alias of shared nodmar MR */
106651e4cefSPeter Xu     MemoryRegion iommu_ir;      /* Interrupt region: 0xfeeXXXXX */
1071b2b1237SJason Wang     MemoryRegion iommu_ir_fault; /* Interrupt region for catching fault */
1081da12ec4SLe Tan     IntelIOMMUState *iommu_state;
109d92fa2dcSLe Tan     VTDContextCacheEntry context_cache_entry;
110b4a4ba0dSPeter Xu     QLIST_ENTRY(VTDAddressSpace) next;
1114f8a62a9SPeter Xu     /* Superset of notifier flags that this address space has */
1124f8a62a9SPeter Xu     IOMMUNotifierFlag notifier_flags;
1138a7c6060SPeter Xu     /*
1148a7c6060SPeter Xu      * @iova_tree traces mapped IOVA ranges.
1158a7c6060SPeter Xu      *
1168a7c6060SPeter Xu      * The tree is not needed if no MAP notifier is registered with current
1178a7c6060SPeter Xu      * VTD address space, because all guest invalidate commands can be
1188a7c6060SPeter Xu      * directly passed to the IOMMU UNMAP notifiers without any further
1198a7c6060SPeter Xu      * reshuffling.
1208a7c6060SPeter Xu      *
1218a7c6060SPeter Xu      * The tree OTOH is required for MAP typed iommu notifiers for a few
1228a7c6060SPeter Xu      * reasons.
1238a7c6060SPeter Xu      *
1248a7c6060SPeter Xu      * Firstly, there's no way to identify whether an PSI (Page Selective
1258a7c6060SPeter Xu      * Invalidations) or DSI (Domain Selective Invalidations) event is an
1268a7c6060SPeter Xu      * MAP or UNMAP event within the message itself.  Without having prior
1278a7c6060SPeter Xu      * knowledge of existing state vIOMMU doesn't know whether it should
1288a7c6060SPeter Xu      * notify MAP or UNMAP for a PSI message it received when caching mode
1298a7c6060SPeter Xu      * is enabled (for MAP notifiers).
1308a7c6060SPeter Xu      *
1318a7c6060SPeter Xu      * Secondly, PSI messages received from guest driver can be enlarged in
1328a7c6060SPeter Xu      * range, covers but not limited to what the guest driver wanted to
1338a7c6060SPeter Xu      * invalidate.  When the range to invalidates gets bigger than the
1348a7c6060SPeter Xu      * limit of a PSI message, it can even become a DSI which will
1358a7c6060SPeter Xu      * invalidate the whole domain.  If the vIOMMU directly notifies the
1368a7c6060SPeter Xu      * registered device with the unmodified range, it may confuse the
1378a7c6060SPeter Xu      * registered drivers (e.g. vfio-pci) on either:
1388a7c6060SPeter Xu      *
1398a7c6060SPeter Xu      *   (1) Trying to map the same region more than once (for
1408a7c6060SPeter Xu      *       VFIO_IOMMU_MAP_DMA, -EEXIST will trigger), or,
1418a7c6060SPeter Xu      *
1428a7c6060SPeter Xu      *   (2) Trying to UNMAP a range that is still partially mapped.
1438a7c6060SPeter Xu      *
1448a7c6060SPeter Xu      * That accuracy is not required for UNMAP-only notifiers, but it is a
1458a7c6060SPeter Xu      * must-to-have for notifiers registered with MAP events, because the
1468a7c6060SPeter Xu      * vIOMMU needs to make sure the shadow page table is always in sync
1478a7c6060SPeter Xu      * with the guest IOMMU pgtables for a device.
1488a7c6060SPeter Xu      */
1498a7c6060SPeter Xu     IOVATree *iova_tree;
1501da12ec4SLe Tan };
1511da12ec4SLe Tan 
152b5a280c0SLe Tan struct VTDIOTLBEntry {
153b5a280c0SLe Tan     uint64_t gfn;
154b5a280c0SLe Tan     uint16_t domain_id;
1551b2b1237SJason Wang     uint32_t pasid;
156eda4c9b5SYi Liu     uint64_t pte;
157d66b969bSJason Wang     uint64_t mask;
15807f7b733SPeter Xu     uint8_t access_flags;
15916d4e418SZhenzhong Duan     uint8_t pgtt;
160b5a280c0SLe Tan };
161b5a280c0SLe Tan 
162ede9c94aSPeter Xu /* VT-d Source-ID Qualifier types */
163ede9c94aSPeter Xu enum {
164ede9c94aSPeter Xu     VTD_SQ_FULL = 0x00,     /* Full SID verification */
165ede9c94aSPeter Xu     VTD_SQ_IGN_3 = 0x01,    /* Ignore bit 3 */
166ede9c94aSPeter Xu     VTD_SQ_IGN_2_3 = 0x02,  /* Ignore bits 2 & 3 */
167ede9c94aSPeter Xu     VTD_SQ_IGN_1_3 = 0x03,  /* Ignore bits 1-3 */
168ede9c94aSPeter Xu     VTD_SQ_MAX,
169ede9c94aSPeter Xu };
170ede9c94aSPeter Xu 
171ede9c94aSPeter Xu /* VT-d Source Validation Types */
172ede9c94aSPeter Xu enum {
173ede9c94aSPeter Xu     VTD_SVT_NONE = 0x00,    /* No validation */
174ede9c94aSPeter Xu     VTD_SVT_ALL = 0x01,     /* Do full validation */
175ede9c94aSPeter Xu     VTD_SVT_BUS = 0x02,     /* Validate bus range */
176ede9c94aSPeter Xu     VTD_SVT_MAX,
177ede9c94aSPeter Xu };
178ede9c94aSPeter Xu 
1791f91aceeSPeter Xu /* Interrupt Remapping Table Entry Definition */
180bc38ee10SMichael S. Tsirkin union VTD_IR_TableEntry {
1811f91aceeSPeter Xu     struct {
182e03b5686SMarc-André Lureau #if HOST_BIG_ENDIAN
183642ba896SThomas Huth         uint64_t dest_id:32;         /* Destination ID */
184642ba896SThomas Huth         uint64_t __reserved_1:8;     /* Reserved 1 */
185642ba896SThomas Huth         uint64_t vector:8;           /* Interrupt Vector */
186642ba896SThomas Huth         uint64_t irte_mode:1;        /* IRTE Mode */
187642ba896SThomas Huth         uint64_t __reserved_0:3;     /* Reserved 0 */
188642ba896SThomas Huth         uint64_t __avail:4;          /* Available spaces for software */
189642ba896SThomas Huth         uint64_t delivery_mode:3;    /* Delivery Mode */
190642ba896SThomas Huth         uint64_t trigger_mode:1;     /* Trigger Mode */
191642ba896SThomas Huth         uint64_t redir_hint:1;       /* Redirection Hint */
192642ba896SThomas Huth         uint64_t dest_mode:1;        /* Destination Mode */
193642ba896SThomas Huth         uint64_t fault_disable:1;    /* Fault Processing Disable */
194642ba896SThomas Huth         uint64_t present:1;          /* Whether entry present/available */
1951f91aceeSPeter Xu #else
196642ba896SThomas Huth         uint64_t present:1;          /* Whether entry present/available */
197642ba896SThomas Huth         uint64_t fault_disable:1;    /* Fault Processing Disable */
198642ba896SThomas Huth         uint64_t dest_mode:1;        /* Destination Mode */
199642ba896SThomas Huth         uint64_t redir_hint:1;       /* Redirection Hint */
200642ba896SThomas Huth         uint64_t trigger_mode:1;     /* Trigger Mode */
201642ba896SThomas Huth         uint64_t delivery_mode:3;    /* Delivery Mode */
202642ba896SThomas Huth         uint64_t __avail:4;          /* Available spaces for software */
203642ba896SThomas Huth         uint64_t __reserved_0:3;     /* Reserved 0 */
204642ba896SThomas Huth         uint64_t irte_mode:1;        /* IRTE Mode */
205642ba896SThomas Huth         uint64_t vector:8;           /* Interrupt Vector */
206642ba896SThomas Huth         uint64_t __reserved_1:8;     /* Reserved 1 */
207642ba896SThomas Huth         uint64_t dest_id:32;         /* Destination ID */
2081f91aceeSPeter Xu #endif
209e03b5686SMarc-André Lureau #if HOST_BIG_ENDIAN
2101f91aceeSPeter Xu         uint64_t __reserved_2:44;    /* Reserved 2 */
2111f91aceeSPeter Xu         uint64_t sid_vtype:2;        /* Source-ID Validation Type */
2121f91aceeSPeter Xu         uint64_t sid_q:2;            /* Source-ID Qualifier */
213642ba896SThomas Huth         uint64_t source_id:16;       /* Source-ID */
2141f91aceeSPeter Xu #else
215642ba896SThomas Huth         uint64_t source_id:16;       /* Source-ID */
2161f91aceeSPeter Xu         uint64_t sid_q:2;            /* Source-ID Qualifier */
2171f91aceeSPeter Xu         uint64_t sid_vtype:2;        /* Source-ID Validation Type */
2181f91aceeSPeter Xu         uint64_t __reserved_2:44;    /* Reserved 2 */
2191f91aceeSPeter Xu #endif
220bc38ee10SMichael S. Tsirkin     } QEMU_PACKED irte;
2211f91aceeSPeter Xu     uint64_t data[2];
2221f91aceeSPeter Xu };
2231f91aceeSPeter Xu 
2241f91aceeSPeter Xu #define VTD_IR_INT_FORMAT_COMPAT     (0) /* Compatible Interrupt */
2251f91aceeSPeter Xu #define VTD_IR_INT_FORMAT_REMAP      (1) /* Remappable Interrupt */
2261f91aceeSPeter Xu 
2271f91aceeSPeter Xu /* Programming format for MSI/MSI-X addresses */
2281f91aceeSPeter Xu union VTD_IR_MSIAddress {
2291f91aceeSPeter Xu     struct {
230e03b5686SMarc-André Lureau #if HOST_BIG_ENDIAN
2311f91aceeSPeter Xu         uint32_t __head:12;          /* Should always be: 0x0fee */
2321f91aceeSPeter Xu         uint32_t index_l:15;         /* Interrupt index bit 14-0 */
2331f91aceeSPeter Xu         uint32_t int_mode:1;         /* Interrupt format */
2341f91aceeSPeter Xu         uint32_t sub_valid:1;        /* SHV: Sub-Handle Valid bit */
2351f91aceeSPeter Xu         uint32_t index_h:1;          /* Interrupt index bit 15 */
2361f91aceeSPeter Xu         uint32_t __not_care:2;
2371f91aceeSPeter Xu #else
2381f91aceeSPeter Xu         uint32_t __not_care:2;
2391f91aceeSPeter Xu         uint32_t index_h:1;          /* Interrupt index bit 15 */
2401f91aceeSPeter Xu         uint32_t sub_valid:1;        /* SHV: Sub-Handle Valid bit */
2411f91aceeSPeter Xu         uint32_t int_mode:1;         /* Interrupt format */
2421f91aceeSPeter Xu         uint32_t index_l:15;         /* Interrupt index bit 14-0 */
2431f91aceeSPeter Xu         uint32_t __head:12;          /* Should always be: 0x0fee */
2441f91aceeSPeter Xu #endif
245bc38ee10SMichael S. Tsirkin     } QEMU_PACKED addr;
2461f91aceeSPeter Xu     uint32_t data;
2471f91aceeSPeter Xu };
2481f91aceeSPeter Xu 
2491f91aceeSPeter Xu /* When IR is enabled, all MSI/MSI-X data bits should be zero */
2501f91aceeSPeter Xu #define VTD_IR_MSI_DATA          (0)
2511f91aceeSPeter Xu 
2521da12ec4SLe Tan /* The iommu (DMAR) device state struct */
2531da12ec4SLe Tan struct IntelIOMMUState {
2541c7955c4SPeter Xu     X86IOMMUState x86_iommu;
2551da12ec4SLe Tan     MemoryRegion csrmem;
2564b519ef1SPeter Xu     MemoryRegion mr_nodmar;
2574b519ef1SPeter Xu     MemoryRegion mr_ir;
2584b519ef1SPeter Xu     MemoryRegion mr_sys_alias;
2591da12ec4SLe Tan     uint8_t csr[DMAR_REG_SIZE];     /* register values */
2601da12ec4SLe Tan     uint8_t wmask[DMAR_REG_SIZE];   /* R/W bytes */
2611da12ec4SLe Tan     uint8_t w1cmask[DMAR_REG_SIZE]; /* RW1C(Write 1 to Clear) bytes */
2621da12ec4SLe Tan     uint8_t womask[DMAR_REG_SIZE];  /* WO (write only - read returns 0) */
2631da12ec4SLe Tan     uint32_t version;
2641da12ec4SLe Tan 
2653b40f0e5SAviv Ben-David     bool caching_mode;              /* RO - is cap CM enabled? */
2664a4f219eSYi Sun     bool scalable_mode;             /* RO - is Scalable Mode supported? */
267791346f9SZhenzhong Duan     bool flts;                      /* RO - is stage-1 translation supported? */
268b8ffd7d6SJason Wang     bool snoop_control;             /* RO - is SNP filed supported? */
2693b40f0e5SAviv Ben-David 
2701da12ec4SLe Tan     dma_addr_t root;                /* Current root table pointer */
271fb43cf73SLiu, Yi L     bool root_scalable;             /* Type of root table (scalable or not) */
2721da12ec4SLe Tan     bool dmar_enabled;              /* Set if DMA remapping is enabled */
2731da12ec4SLe Tan 
2741da12ec4SLe Tan     uint16_t iq_head;               /* Current invalidation queue head */
2751da12ec4SLe Tan     uint16_t iq_tail;               /* Current invalidation queue tail */
2761da12ec4SLe Tan     dma_addr_t iq;                  /* Current invalidation queue pointer */
2771da12ec4SLe Tan     uint16_t iq_size;               /* IQ Size in number of entries */
278c0c1d351SLiu, Yi L     bool iq_dw;                     /* IQ descriptor width 256bit or not */
2791da12ec4SLe Tan     bool qi_enabled;                /* Set if the QI is enabled */
2801da12ec4SLe Tan     uint8_t iq_last_desc_type;      /* The type of last completed descriptor */
2811da12ec4SLe Tan 
2821da12ec4SLe Tan     /* The index of the Fault Recording Register to be used next.
2831da12ec4SLe Tan      * Wraps around from N-1 to 0, where N is the number of FRCD_REG.
2841da12ec4SLe Tan      */
2851da12ec4SLe Tan     uint16_t next_frcd_reg;
2861da12ec4SLe Tan 
2871da12ec4SLe Tan     uint64_t cap;                   /* The value of capability reg */
2881da12ec4SLe Tan     uint64_t ecap;                  /* The value of extended capability reg */
2891da12ec4SLe Tan 
290d92fa2dcSLe Tan     uint32_t context_cache_gen;     /* Should be in [1,MAX] */
291b5a280c0SLe Tan     GHashTable *iotlb;              /* IOTLB */
292d92fa2dcSLe Tan 
293da8d439cSJason Wang     GHashTable *vtd_address_spaces;             /* VTD address spaces */
294da8d439cSJason Wang     VTDAddressSpace *vtd_as_cache[VTD_PCI_BUS_MAX]; /* VTD address space cache */
295dd4d607eSPeter Xu     /* list of registered notifiers */
296b4a4ba0dSPeter Xu     QLIST_HEAD(, VTDAddressSpace) vtd_as_with_notifiers;
297a5861439SPeter Xu 
298a20910caSYi Liu     GHashTable *vtd_host_iommu_dev;             /* HostIOMMUDevice */
299a20910caSYi Liu 
300a5861439SPeter Xu     /* interrupt remapping */
301a5861439SPeter Xu     bool intr_enabled;              /* Whether guest enabled IR */
302a5861439SPeter Xu     dma_addr_t intr_root;           /* Interrupt remapping table pointer */
303a5861439SPeter Xu     uint32_t intr_size;             /* Number of IR table entries */
30428589311SJan Kiszka     bool intr_eime;                 /* Extended interrupt mode enabled */
305e6b6af05SRadim Krčmář     OnOffAuto intr_eim;             /* Toggle for EIM cabability */
306fb506e70SRadim Krčmář     bool buggy_eim;                 /* Force buggy EIM unless eim=off */
30737f51384SPrasad Singamsetty     uint8_t aw_bits;                /* Host/IOVA address width (in bits) */
308ccc23bb0SPeter Xu     bool dma_drain;                 /* Whether DMA r/w draining enabled */
3098646d9c7SDavid Woodhouse     bool dma_translation;           /* Whether DMA translation supported */
3101b2b1237SJason Wang     bool pasid;                     /* Whether to support PASID */
311d9d32478SZhenzhong Duan     bool fs1gp;                     /* First Stage 1-GByte Page Support */
3121d9efa73SPeter Xu 
3136ce12bd2SZhenzhong Duan     /* Transient Mapping, Reserved(0) since VTD spec revision 3.2 */
3146ce12bd2SZhenzhong Duan     bool stale_tm;
3156ce12bd2SZhenzhong Duan 
3161d9efa73SPeter Xu     /*
3171d9efa73SPeter Xu      * Protects IOMMU states in general.  Currently it protects the
3181d9efa73SPeter Xu      * per-IOMMU IOTLB cache, and context entry cache in VTDAddressSpace.
3191d9efa73SPeter Xu      */
3201d9efa73SPeter Xu     QemuMutex iommu_lock;
3211da12ec4SLe Tan };
3221da12ec4SLe Tan 
3237df953bdSKnut Omang /* Find the VTD Address space associated with the given bus pointer,
3247df953bdSKnut Omang  * create a new one if none exists
3257df953bdSKnut Omang  */
3261b2b1237SJason Wang VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus,
3271b2b1237SJason Wang                                  int devfn, unsigned int pasid);
3287df953bdSKnut Omang 
3291da12ec4SLe Tan #endif
330