- Timestamp:
- Mar 19, 2021 8:03:46 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143365
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuIntel.cpp
r88192 r88201 24 24 #include <VBox/iommu-intel.h> 25 25 26 #include <iprt/assertcompile.h> 26 27 #include <iprt/string.h> 27 28 … … 32 33 * Defined Constants And Macros * 33 34 *********************************************************************************************************************************/ 35 /** @def VTD_LO_U32 36 * Gets the low uint32_t of a uint64_t or something equivalent. 37 * 38 * This is suitable for casting constants outside code (since RT_LO_U32 can't be 39 * used as it asserts for correctness when compiling on certain compilers). */ 40 #define VTD_LO_U32(a) (uint32_t)(UINT32_MAX & (a)) 41 42 /** @def VTD_HI_U32 43 * Gets the high uint32_t of a uint64_t or something equivalent. 44 * 45 * This is suitable for casting constants outside code (since RT_HI_U32 can't be 46 * used as it asserts for correctness when compiling on certain compilers). */ 47 #define VTD_HI_U32(a) (uint32_t)((a) >> 32) 48 34 49 /** Release log prefix string. */ 35 50 #define IOMMU_LOG_PFX "Intel-IOMMU" 51 36 52 /** The current saved state version. */ 37 53 #define IOMMU_SAVED_STATE_VERSION 1 38 54 39 55 56 /********************************************************************************************************************************* 57 * Structures and Typedefs * 58 *********************************************************************************************************************************/ 40 59 /** 41 60 * The shared IOMMU device state. … … 111 130 typedef CTX_SUFF(PIOMMU) PIOMMUCC; 112 131 113 /** 114 * IOMMU register attributes. 115 */ 116 typedef struct IOMMUREGATTR 117 { 118 /** Name of the register. */ 119 const char *pszName; 120 /** RW: Read/write mask. */ 121 uint64_t fRwMask; 122 /** RO: Read-only mask. */ 123 uint64_t fRoMask; 124 /** WO: Write-only mask. */ 125 uint64_t fWoMask; 126 /** RW1C: Read-only Status, Write-1-to-clear mask. */ 127 uint64_t fRw1cMask; 128 } IOMMUREGATTR; 129 /** Pointer to an IOMMU register attributes struct. */ 130 typedef IOMMUREGATTR *PIOMMUREGATTR; 131 /** Pointer to a const IOMMU register attributes struct. */ 132 typedef IOMMUREGATTR const *PCIOMMUREGATTR; 132 133 /********************************************************************************************************************************* 134 * Global Variables * 135 *********************************************************************************************************************************/ 136 /** 137 * Read-write masks for IOMMU registers (group 0). 138 */ 139 static const uint32_t g_aRwMasks0[] = 140 { 141 /* Offset Register Low High */ 142 /* 0x000 VER_REG */ VTD_VER_REG_RW_MASK, 143 /* 0x004 Reserved */ 0, 144 /* 0x008 CAP_REG */ VTD_LO_U32(VTD_CAP_REG_RW_MASK), VTD_HI_U32(VTD_CAP_REG_RW_MASK), 145 /* 0x010 ECAP_REG */ VTD_LO_U32(VTD_ECAP_REG_RW_MASK), VTD_HI_U32(VTD_ECAP_REG_RW_MASK), 146 /* 0x018 GCMD_REG */ VTD_GCMD_REG_RW_MASK, 147 /* 0x01c GSTS_REG */ VTD_GSTS_REG_RW_MASK, 148 /* 0x020 RTADDR_REG */ VTD_LO_U32(VTD_RTADDR_REG_RW_MASK), VTD_HI_U32(VTD_RTADDR_REG_RW_MASK), 149 /* 0x028 CCMD_REG */ VTD_LO_U32(VTD_CCMD_REG_RW_MASK), VTD_HI_U32(VTD_CCMD_REG_RW_MASK), 150 /* 0x030 Reserved */ 0, 151 /* 0x034 FSTS_REG */ VTD_FSTS_REG_RW_MASK, 152 /* 0x038 FECTL_REG */ VTD_FECTL_REG_RW_MASK, 153 /* 0x03c FEDATA_REG */ VTD_FEDATA_REG_RW_MASK, 154 /* 0x040 FEADDR_REG */ VTD_FEADDR_REG_RW_MASK, 155 /* 0x044 FEUADDR_REG */ VTD_FEUADDR_REG_RW_MASK, 156 /* 0x048 Reserved */ 0, 0, 157 /* 0x050 Reserved */ 0, 0, 158 /* 0x058 AFLOG_REG */ VTD_LO_U32(VTD_AFLOG_REG_RW_MASK), VTD_HI_U32(VTD_AFLOG_REG_RW_MASK), 159 /* 0x060 Reserved */ 0, 160 /* 0x064 PMEN_REG */ 0, /* RO as we don't support PLMR and PHMR. */ 161 /* 0x068 PLMBASE_REG */ 0, /* RO as we don't support PLMR. */ 162 /* 0x06c PLMLIMIT_REG */ 0, /* RO as we don't support PLMR. */ 163 /* 0x070 PHMBASE_REG */ 0, 0, /* RO as we don't support PHMR. */ 164 /* 0x078 PHMLIMIT_REG */ 0, 0, /* RO as we don't support PHMR. */ 165 /* 0x080 IQH_REG */ VTD_LO_U32(VTD_IQH_REG_RW_MASK), VTD_HI_U32(VTD_IQH_REG_RW_MASK), 166 /* 0x088 IQT_REG */ VTD_LO_U32(VTD_IQT_REG_RW_MASK), VTD_HI_U32(VTD_IQT_REG_RW_MASK), 167 /* 0x090 IQA_REG */ VTD_LO_U32(VTD_IQA_REG_RW_MASK), VTD_HI_U32(VTD_IQA_REG_RW_MASK), 168 /* 0x098 Reserved */ 0, 169 /* 0x09c ICS_REG */ VTD_ICS_REG_RW_MASK, 170 /* 0x0a0 IECTL_REG */ VTD_IECTL_REG_RW_MASK, 171 /* 0x0a4 IEDATA_REG */ VTD_IEDATA_REG_RW_MASK, 172 /* 0x0a8 IEADDR_REG */ VTD_IEADDR_REG_RW_MASK, 173 /* 0x0ac IEUADDR_REG */ VTD_IEUADDR_REG_RW_MASK, 174 /* 0x0b0 IQERCD_REG */ VTD_LO_U32(VTD_IQERCD_REG_RW_MASK), VTD_HI_U32(VTD_IQERCD_REG_RW_MASK), 175 /* 0x0b8 IRTA_REG */ VTD_LO_U32(VTD_IRTA_REG_RW_MASK), VTD_HI_U32(VTD_IRTA_REG_RW_MASK), 176 /* 0x0c0 PQH_REG */ VTD_LO_U32(VTD_PQH_REG_RW_MASK), VTD_HI_U32(VTD_PQH_REG_RW_MASK), 177 /* 0x0c8 PQT_REG */ VTD_LO_U32(VTD_PQT_REG_RW_MASK), VTD_HI_U32(VTD_PQT_REG_RW_MASK), 178 /* 0x0d0 PQA_REG */ VTD_LO_U32(VTD_PQA_REG_RW_MASK), VTD_HI_U32(VTD_PQA_REG_RW_MASK), 179 /* 0x0d8 Reserved */ 0, 180 /* 0x0dc PRS_REG */ VTD_PRS_REG_RW_MASK, 181 /* 0x0e0 PECTL_REG */ VTD_PECTL_REG_RW_MASK, 182 /* 0x0e4 PEDATA_REG */ VTD_PEDATA_REG_RW_MASK, 183 /* 0x0e8 PEADDR_REG */ VTD_PEADDR_REG_RW_MASK, 184 /* 0x0ec PEUADDR_REG */ VTD_PEUADDR_REG_RW_MASK, 185 /* 0x0f0 Reserved */ 0, 0, 186 /* 0x0f8 Reserved */ 0, 0, 187 /* 0x100 MTRRCAP_REG */ VTD_LO_U32(VTD_MTRRCAP_REG_RW_MASK), VTD_HI_U32(VTD_MTRRCAP_REG_RW_MASK), 188 /* 0x108 MTRRDEF_REG */ 0, 0, /* RO as we don't support MTS. */ 189 /* 0x110 Reserved */ 0, 0, 190 /* 0x118 Reserved */ 0, 0, 191 /* 0x120 MTRR_FIX64_00000_REG */ 0, 0, /* RO as we don't support MTS. */ 192 /* 0x128 MTRR_FIX16K_80000_REG */ 0, 0, 193 /* 0x130 MTRR_FIX16K_A0000_REG */ 0, 0, 194 /* 0x138 MTRR_FIX4K_C0000_REG */ 0, 0, 195 /* 0x140 MTRR_FIX4K_C8000_REG */ 0, 0, 196 /* 0x148 MTRR_FIX4K_D0000_REG */ 0, 0, 197 /* 0x150 MTRR_FIX4K_D8000_REG */ 0, 0, 198 /* 0x158 MTRR_FIX4K_E0000_REG */ 0, 0, 199 /* 0x160 MTRR_FIX4K_E8000_REG */ 0, 0, 200 /* 0x168 MTRR_FIX4K_F0000_REG */ 0, 0, 201 /* 0x170 MTRR_FIX4K_F8000_REG */ 0, 0, 202 /* 0x178 Reserved */ 0, 0, 203 /* 0x180 MTRR_PHYSBASE0_REG */ 0, 0, /* RO as we don't support MTS. */ 204 /* 0x188 MTRR_PHYSMASK0_REG */ 0, 0, 205 /* 0x190 MTRR_PHYSBASE1_REG */ 0, 0, 206 /* 0x198 MTRR_PHYSMASK1_REG */ 0, 0, 207 /* 0x1a0 MTRR_PHYSBASE2_REG */ 0, 0, 208 /* 0x1a8 MTRR_PHYSMASK2_REG */ 0, 0, 209 /* 0x1b0 MTRR_PHYSBASE3_REG */ 0, 0, 210 /* 0x1b8 MTRR_PHYSMASK3_REG */ 0, 0, 211 /* 0x1c0 MTRR_PHYSBASE4_REG */ 0, 0, 212 /* 0x1c8 MTRR_PHYSMASK4_REG */ 0, 0, 213 /* 0x1d0 MTRR_PHYSBASE5_REG */ 0, 0, 214 /* 0x1d8 MTRR_PHYSMASK5_REG */ 0, 0, 215 /* 0x1e0 MTRR_PHYSBASE6_REG */ 0, 0, 216 /* 0x1e8 MTRR_PHYSMASK6_REG */ 0, 0, 217 /* 0x1f0 MTRR_PHYSBASE7_REG */ 0, 0, 218 /* 0x1f8 MTRR_PHYSMASK7_REG */ 0, 0, 219 /* 0x200 MTRR_PHYSBASE8_REG */ 0, 0, 220 /* 0x208 MTRR_PHYSMASK8_REG */ 0, 0, 221 /* 0x210 MTRR_PHYSBASE9_REG */ 0, 0, 222 /* 0x218 MTRR_PHYSMASK9_REG */ 0, 0, 223 }; 224 AssertCompile(sizeof(g_aRwMasks0) == VTD_MMIO_GROUP_0_SIZE); 225 226 /** 227 * Read-write masks for IOMMU registers (group 1). 228 */ 229 static const uint32_t g_aRwMasks1[] = 230 { 231 /* Offset Register Low High */ 232 /* 0xe00 VCCAP_REG */ VTD_LO_U32(VTD_VCCAP_REG_RW_MASK), VTD_HI_U32(VTD_VCCAP_REG_RW_MASK), 233 /* 0xe08 Reserved */ 0, 0, 234 /* 0xe10 VCMD_REG */ 0, 0, /* RO as we don't support VCS. */ 235 /* 0xe18 Reserved */ 0, 0, 236 /* 0xe20 VCRSP_REG */ 0, 0, /* RO as we don't support VCS. */ 237 }; 238 AssertCompile(sizeof(g_aRwMasks1) == VTD_MMIO_GROUP_1_SIZE); 133 239 134 240 … … 276 382 AssertRCReturn(rc, rc); 277 383 278 /*279 * Initialize read-only PCI configuration space.280 */281 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];282 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);283 284 /** @todo Figure out the PCI vendor/product and other stuff. Can't seem to find285 * this yet. Maybe dump info from real hw. */286 384 287 385 return VERR_NOT_IMPLEMENTED;
Note:
See TracChangeset
for help on using the changeset viewer.