Changeset 83968 in vbox for trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
- Timestamp:
- Apr 24, 2020 2:55:49 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r83959 r83968 416 416 } while (0) 417 417 418 /** 419 * Gets the device table size given the size field. 420 */ 421 #define IOMMU_GET_DEV_TAB_SIZE(a_uSize) (((a_uSize) + 1) << X86_PAGE_4K_SHIFT) 418 422 419 423 /********************************************************************************************************************************* … … 1063 1067 struct 1064 1068 { 1065 RT_GCC_EXTENSION uint64_t u9Size : 9; 1066 RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; 1067 RT_GCC_EXTENSION uint64_t u40 DevTabBase : 40;/**< Bits 51:12 - DevTabBase: Device table base address. */1068 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; 1069 RT_GCC_EXTENSION uint64_t u9Size : 9; /**< Bits 8:0 - Size: Size of the device table. */ 1070 RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 11:9 - Reserved. */ 1071 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - DevTabBase: Device table base address. */ 1072 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */ 1069 1073 } n; 1070 1074 /** The 64-bit unsigned integer view. */ … … 1083 1087 { 1084 1088 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */ 1085 RT_GCC_EXTENSION uint64_t u40 CmdBase : 40;/**< Bits 51:12 - ComBase: Command buffer base address. */1089 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - ComBase: Command buffer base address. */ 1086 1090 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */ 1087 RT_GCC_EXTENSION uint64_t u4 CmdLen : 4;/**< Bits 59:56 - ComLen: Command buffer length. */1091 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - ComLen: Command buffer length. */ 1088 1092 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */ 1089 1093 } n; … … 1103 1107 { 1104 1108 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */ 1105 RT_GCC_EXTENSION uint64_t u40 EvtBase : 40;/**< Bits 51:12 - EventBase: Event log base address. */1109 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - EventBase: Event log base address. */ 1106 1110 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */ 1107 RT_GCC_EXTENSION uint64_t u4 EvtLen : 4;/**< Bits 59:56 - EventLen: Event log length. */1111 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - EventLen: Event log length. */ 1108 1112 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */ 1109 1113 } n; … … 1272 1276 { 1273 1277 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */ 1274 RT_GCC_EXTENSION uint64_t u40 PprLogBase : 40;/**< Bits 51:12 - PPRLogBase: Peripheral Page Request Log Base Address. */1278 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - PPRLogBase: Peripheral Page Request Log Base Address. */ 1275 1279 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */ 1276 RT_GCC_EXTENSION uint64_t u4 PprLogLen : 4;/**< Bits 59:56 - PPRLogLen: Peripheral Page Request Log Length. */1280 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - PPRLogLen: Peripheral Page Request Log Length. */ 1277 1281 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */ 1278 1282 } n; … … 1332 1336 struct 1333 1337 { 1334 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; 1335 RT_GCC_EXTENSION uint64_t u40 GALogBase : 40;/**< Bits 51:12 - GALogBase: Guest Virtual-APIC Log Base Address. */1336 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; 1337 RT_GCC_EXTENSION uint64_t u4 GALogLen : 4;/**< Bits 59:56 - GALogLen: Guest Virtual-APIC Log Length. */1338 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; 1338 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */ 1339 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - GALogBase: Guest Virtual-APIC Log Base Address. */ 1340 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */ 1341 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - GALogLen: Guest Virtual-APIC Log Length. */ 1342 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */ 1339 1343 } n; 1340 1344 /** The 64-bit unsigned integer view. */ … … 1382 1386 struct 1383 1387 { 1384 RT_GCC_EXTENSION uint64_t u8Size : 8; 1385 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; 1386 RT_GCC_EXTENSION uint64_t u40 DevTabBase : 40;/**< Bits 51:12 - DevTabBase: Device Table Segment Base Address. */1387 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; 1388 RT_GCC_EXTENSION uint64_t u8Size : 8; /**< Bits 7:0 - Size: Size of the Device Table segment. */ 1389 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 11:8 - Reserved. */ 1390 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - DevTabBase: Device Table Segment Base Address. */ 1391 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */ 1388 1392 } n; 1389 1393 /** The 64-bit unsigned integer view. */ … … 2108 2112 * Indexed by u2DevTabSegSup. 2109 2113 */ 2110 static uint8_t const g_a DevTabSegments[] = { 0, 2, 4, 8 };2114 static uint8_t const g_acDevTabSegs[] = { 0, 2, 4, 8 }; 2111 2115 2112 2116 /** … … 2114 2118 * Indexed by the device table segment index. 2115 2119 */ 2116 static uint16_t const g_a DevTabSegmentSizes[] = { 0x1ff, 0xff, 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x3f };2120 static uint16_t const g_auDevTabSegSizes[] = { 0x1ff, 0xff, 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x3f }; 2117 2121 2118 2122 … … 2158 2162 2159 2163 2160 /** 2161 * Logs if the buffer length is invalid. 2162 * 2163 * @param uEncodedLen The length to decode. 2164 * @param pszFunc Name of the calling function for logging purposes. 2165 */ 2166 DECLINLINE(void) iommuAmdCheckBufferLength(uint8_t uEncodedLen, const char *pszFunc) 2167 { 2168 #ifdef VBOX_STRICT 2169 uint32_t cEntries; 2170 iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, NULL /* pcbBuffer */); 2171 if (!cEntries) 2172 Log((IOMMU_LOG_PFX ": %s: Invalid length %#x\n", pszFunc, uEncodedLen)); 2173 #else 2174 RT_NOREF(uEncodedLen, pszFunc); 2175 #endif 2164 DECL_FORCE_INLINE(IOMMU_CTRL_T) iommuAmdGetCtrl(PCIOMMU pThis) 2165 { 2166 IOMMU_CTRL_T Ctrl; 2167 Ctrl.u64 = ASMAtomicReadU64((volatile uint64_t *)&pThis->Ctrl.u64); 2168 return Ctrl; 2176 2169 } 2177 2170 … … 2194 2187 { 2195 2188 RT_NOREF(pDevIns, iReg); 2196 pThis->DevTabBaseAddr.u64 = u64Value & IOMMU_DEV_TAB_BAR_VALID_MASK; 2189 2190 /* Mask out all unrecognized bits. */ 2191 u64Value &= IOMMU_DEV_TAB_BAR_VALID_MASK; 2192 DEV_TAB_BAR_T DevTabBaseAddr; 2193 DevTabBaseAddr.u64 = u64Value; 2194 2195 /* Validate the base address. */ 2196 RTGCPHYS const GCPhysDevTab = DevTabBaseAddr.n.u40Base; 2197 if (!(GCPhysDevTab & X86_PAGE_4K_OFFSET_MASK)) 2198 pThis->DevTabBaseAddr.u64 = DevTabBaseAddr.u64; 2199 else 2200 Log((IOMMU_LOG_PFX ": Device table base address (%#RX64) misaligned -> Ignored\n", GCPhysDevTab)); 2197 2201 return VINF_SUCCESS; 2198 2202 } … … 2205 2209 { 2206 2210 RT_NOREF(pDevIns, iReg); 2207 pThis->CmdBufBaseAddr.u64 = u64Value & IOMMU_CMD_BUF_BAR_VALID_MASK;2208 iommuAmdCheckBufferLength(pThis->CmdBufBaseAddr.n.u4CmdLen, __PRETTY_FUNCTION__);2209 2211 2210 2212 /* … … 2220 2222 } 2221 2223 2224 /* Mask out all unrecognized bits. */ 2225 CMD_BUF_BAR_T CmdBufBaseAddr; 2226 CmdBufBaseAddr.u64 = u64Value & IOMMU_CMD_BUF_BAR_VALID_MASK; 2227 2228 /* Validate the base address. */ 2229 RTGCPHYS const GCPhysCmdBuf = CmdBufBaseAddr.n.u40Base; 2230 if (!(GCPhysCmdBuf & X86_PAGE_4K_OFFSET_MASK)) 2231 { 2232 /* Validate the length. */ 2233 if (CmdBufBaseAddr.n.u4Len >= 8) 2234 pThis->CmdBufBaseAddr.u64 = CmdBufBaseAddr.u64; 2235 else 2236 Log((IOMMU_LOG_PFX ": Command buffer length (%#x) invalid -> Ignored\n", CmdBufBaseAddr.n.u4Len)); 2237 } 2238 else 2239 Log((IOMMU_LOG_PFX ": Command buffer base address (%#RX64) misaligned -> Ignored\n", CmdBufBaseAddr.n.u40Base)); 2240 2222 2241 /* 2223 2242 * Writing the command log base address, clears the command buffer head and tail pointers. … … 2250 2269 } 2251 2270 2252 pThis->EvtLogBaseAddr.u64 = u64Value & IOMMU_EVT_LOG_BAR_VALID_MASK; 2253 iommuAmdCheckBufferLength(pThis->EvtLogBaseAddr.n.u4EvtLen, __PRETTY_FUNCTION__); 2271 /* Mask out all unrecognized bits. */ 2272 u64Value &= IOMMU_EVT_LOG_BAR_VALID_MASK; 2273 EVT_LOG_BAR_T EvtLogBaseAddr; 2274 EvtLogBaseAddr.u64 = u64Value; 2275 2276 /* Validate the base address. */ 2277 RTGCPHYS const GCPhysEvtLog = EvtLogBaseAddr.n.u40Base; 2278 if (!(GCPhysEvtLog & X86_PAGE_4K_OFFSET_MASK)) 2279 { 2280 /* Validate the length. */ 2281 if (EvtLogBaseAddr.n.u4Len >= 8) 2282 pThis->EvtLogBaseAddr.u64 = EvtLogBaseAddr.u64; 2283 else 2284 Log((IOMMU_LOG_PFX ": Event log length (%#x) invalid -> Ignored\n", EvtLogBaseAddr.n.u4Len)); 2285 } 2286 else 2287 Log((IOMMU_LOG_PFX ": Event log base address (%#RX64) misaligned -> Ignored\n", EvtLogBaseAddr.n.u40Base)); 2254 2288 2255 2289 /* … … 2292 2326 { 2293 2327 RT_NOREF(pDevIns, iReg); 2294 pThis->PprLogBaseAddr.u64 = u64Value & IOMMU_PPR_LOG_BAR_VALID_MASK; 2295 iommuAmdCheckBufferLength(pThis->PprLogBaseAddr.n.u4PprLogLen, __PRETTY_FUNCTION__); 2328 2329 /* 2330 * IOMMU behavior is undefined when software writes this register when PPR logging is running. 2331 * In our emulation, we ignore the write entirely. 2332 * See AMD IOMMU spec. 3.3.2 "PPR Log Registers". 2333 */ 2334 IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis); 2335 if (Status.n.u1PprLogRunning) 2336 { 2337 Log((IOMMU_LOG_PFX ": Setting PprLogBar (%#RX64) when PPR logging is running -> Ignored\n", u64Value)); 2338 return VINF_SUCCESS; 2339 } 2340 2341 /* Mask out all unrecognized bits. */ 2342 u64Value &= IOMMU_PPR_LOG_BAR_VALID_MASK; 2343 PPR_LOG_BAR_T PprLogBaseAddr; 2344 PprLogBaseAddr.u64 = u64Value; 2345 2346 /* Validate the base address. */ 2347 RTGCPHYS const GCPhysPprLog = PprLogBaseAddr.n.u40Base; 2348 if (!(GCPhysPprLog & X86_PAGE_4K_OFFSET_MASK)) 2349 { 2350 /* Validate the length. */ 2351 if (PprLogBaseAddr.n.u4Len >= 8) 2352 pThis->PprLogBaseAddr.u64 = PprLogBaseAddr.u64; 2353 else 2354 Log((IOMMU_LOG_PFX ": PPR log length (%#x) invalid -> Ignored\n", PprLogBaseAddr.n.u4Len)); 2355 } 2356 else 2357 Log((IOMMU_LOG_PFX ": PPR log base address (%#RX64) misaligned -> Ignored\n", PprLogBaseAddr.n.u40Base)); 2358 2359 /* 2360 * Writing the event log base address, clears the PPR log head and tail pointers. 2361 * See AMD spec. 2.6 "Peripheral Page Request (PPR) Logging" 2362 */ 2363 pThis->PprLogHeadPtr.u64 = 0; 2364 pThis->PprLogTailPtr.u64 = 0; 2365 2296 2366 return VINF_SUCCESS; 2297 2367 } … … 2360 2430 /* Figure out which segment is being written. */ 2361 2431 uint8_t const idxDevTabSeg = (iReg - IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST) >> 3; 2432 uint8_t const idxSegment = idxDevTabSeg + 1; 2362 2433 Assert(idxDevTabSeg < RT_ELEMENTS(pThis->DevTabSeg)); 2363 2434 2364 2435 /* Mask out all unrecognized bits. */ 2365 2436 u64Value &= IOMMU_DEV_TAB_SEG_BAR_VALID_MASK; 2366 uint8_t const cbSegSize = u64Value & UINT64_C(0xff); 2367 2368 /* Validate the size and write the register. */ 2369 uint8_t const idxSegment = idxDevTabSeg + 1; 2370 uint16_t const cbMaxSegSize = g_aDevTabSegmentSizes[idxSegment]; 2371 if (cbSegSize <= cbMaxSegSize) 2372 pThis->DevTabSeg[idxDevTabSeg].u64 = u64Value; 2437 DEV_TAB_SEG_BAR_T DevTabSegBar; 2438 DevTabSegBar.u64 = u64Value; 2439 2440 /* Validate the base address. */ 2441 RTGCPHYS const GCPhysDevTab = DevTabSegBar.n.u40Base; 2442 if (!(GCPhysDevTab & X86_PAGE_4K_OFFSET_MASK)) 2443 { 2444 /* Validate the size. */ 2445 uint16_t const uSegSize = DevTabSegBar.n.u8Size; 2446 uint16_t const uMaxSegSize = g_auDevTabSegSizes[idxSegment]; 2447 if (uSegSize <= uMaxSegSize) 2448 { 2449 /* Finally, update the segment register. */ 2450 pThis->DevTabSeg[idxDevTabSeg].u64 = u64Value; 2451 } 2452 else 2453 Log((IOMMU_LOG_PFX ": Device table segment (%u) size invalid (%#RX32) -> Ignored\n", idxSegment, uSegSize)); 2454 } 2373 2455 else 2374 Log((IOMMU_LOG_PFX ": Setting device table segment %u with invalid size (%#RX32) -> Ignored\n", idxSegment, cbSegSize));2456 Log((IOMMU_LOG_PFX ": Device table segment (%u) address misaligned (%#RX64) -> Ignored\n", idxSegment, GCPhysDevTab)); 2375 2457 2376 2458 return VINF_SUCCESS; … … 2445 2527 CMD_BUF_BAR_T const CmdBufBar = pThis->CmdBufBaseAddr; 2446 2528 uint32_t cbBuf; 2447 iommuAmdGetBaseBufferLength(CmdBufBar.n.u4 CmdLen, NULL, &cbBuf);2529 iommuAmdGetBaseBufferLength(CmdBufBar.n.u4Len, NULL, &cbBuf); 2448 2530 if (offBuf >= cbBuf) 2449 2531 { … … 2524 2606 static DECLCALLBACK(int) iommuAmdR3CmdThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread) 2525 2607 { 2526 NOREF(pThread);2608 RT_NOREF(pThread); 2527 2609 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2528 2610 return PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread); … … 2563 2645 2564 2646 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2565 Assert(pThis);2566 2567 2647 switch (off) 2568 2648 { … … 2704 2784 Assert(!(off & 7) || !(off & 3)); 2705 2785 2786 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2706 2787 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0]; 2707 2788 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev); 2708 2709 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);2710 Assert(pThis);2711 2789 2712 2790 /** @todo IOMMU: fine-grained locking? */ … … 2859 2937 * @param pvBuf Where to store the device table segment. 2860 2938 * @param cbBuf The size of the buffer in bytes. 2939 * 2940 * @thread Any. 2861 2941 */ 2862 2942 static int iommuAmdReadDeviceTableSegment(PPDMDEVINS pDevIns, uint8_t idxSeg, void *pvBuf, uint32_t cbBuf) 2863 2943 { 2864 2944 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2865 Assert(pThis);2866 2945 2867 2946 /* Validate. */ … … 2869 2948 Assert(cbBuf <= _2M); 2870 2949 Assert(!idxSeg || pThis->ExtFeat.n.u2DevTabSegSup); 2871 Assert(!idxSeg || idxSeg < g_a DevTabSegments[pThis->ExtFeat.n.u2DevTabSegSup]);2950 Assert(!idxSeg || idxSeg < g_acDevTabSegs[pThis->ExtFeat.n.u2DevTabSegSup]); 2872 2951 2873 2952 /* Get the base address and size of the segment. */ … … 2876 2955 if (!idxSeg) 2877 2956 { 2878 GCPhysDevTab = pThis->DevTabBaseAddr.n.u40 DevTabBase;2879 cbDevTab = pThis->DevTabBaseAddr.n.u9Size;2957 GCPhysDevTab = pThis->DevTabBaseAddr.n.u40Base; 2958 cbDevTab = IOMMU_GET_DEV_TAB_SIZE(pThis->DevTabBaseAddr.n.u9Size); 2880 2959 } 2881 2960 else 2882 2961 { 2883 GCPhysDevTab = pThis->DevTabSeg[idxSeg].n.u40 DevTabBase;2884 cbDevTab = pThis->DevTabSeg[idxSeg].n.u8Size;2962 GCPhysDevTab = pThis->DevTabSeg[idxSeg].n.u40Base; 2963 cbDevTab = IOMMU_GET_DEV_TAB_SIZE(pThis->DevTabSeg[idxSeg].n.u8Size); 2885 2964 } 2886 2965 … … 2901 2980 2902 2981 /** 2903 * Memory read transaction from a downstream device. 2982 * Calculates and returns the total size of the device table. 2983 * This includes device table segments if they are used. 2984 * 2985 * @returns The size of the device table in bytes. 2986 * @param pDevIns The IOMMU device instance. 2987 * 2988 * @thread Any. 2989 */ 2990 static uint32_t iommuAmdCalcTotalDevTabSize(PPDMDEVINS pDevIns) 2991 { 2992 PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2993 IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis); 2994 2995 /* The base address register always exists. */ 2996 uint32_t cbDevTabSize = IOMMU_GET_DEV_TAB_SIZE(pThis->DevTabBaseAddr.n.u9Size); 2997 2998 /* If segmentation is enabled, add the size of each segments. */ 2999 uint8_t const uSegmentsEnabled = Ctrl.n.u3DevTabSegEn; 3000 if (uSegmentsEnabled) 3001 { 3002 Assert(uSegmentsEnabled < RT_ELEMENTS(g_acDevTabSegs)); 3003 uint8_t const cSegments = g_acDevTabSegs[uSegmentsEnabled] - 1; 3004 for (uint8_t idxSegment = 0; idxSegment < cSegments - 1; idxSegment++) 3005 cbDevTabSize += IOMMU_GET_DEV_TAB_SIZE(pThis->DevTabSeg[idxSegment].n.u8Size); 3006 } 3007 3008 return cbDevTabSize; 3009 } 3010 3011 3012 /** 3013 * Memory read transaction from a device. 2904 3014 * 2905 3015 * @returns VBox status code. … … 2920 3030 2921 3031 /** 2922 * Memory write transaction from a d ownstream device.3032 * Memory write transaction from a device. 2923 3033 * 2924 3034 * @returns VBox status code. … … 2994 3104 { 2995 3105 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2996 Assert(pThis);2997 3106 2998 3107 /* … … 3076 3185 static DECLCALLBACK(void) iommuAmdR3DbgInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 3077 3186 { 3187 PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 3078 3188 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0]; 3079 3189 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev); 3080 3081 PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);3082 Assert(pThis);3083 3190 3084 3191 LogFlow((IOMMU_LOG_PFX ": %s: pThis=%p pszArgs=%s\n", __PRETTY_FUNCTION__, pThis, pszArgs)); … … 3092 3199 if (fVerbose) 3093 3200 { 3094 pHlp->pfnPrintf(pHlp, " Size = % u(%u bytes)\n", DevTabBar.n.u9Size,3095 (DevTabBar.n.u9Size + 1) * _4K);3096 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", DevTabBar.n.u40 DevTabBase);3201 pHlp->pfnPrintf(pHlp, " Size = %#x (%u bytes)\n", DevTabBar.n.u9Size, 3202 IOMMU_GET_DEV_TAB_SIZE(DevTabBar.n.u9Size)); 3203 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", DevTabBar.n.u40Base); 3097 3204 } 3098 3205 } … … 3102 3209 uint32_t cEntries; 3103 3210 uint32_t cbBuffer; 3104 uint8_t const uEncodedLen = CmdBufBar.n.u4 CmdLen;3211 uint8_t const uEncodedLen = CmdBufBar.n.u4Len; 3105 3212 iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer); 3106 3213 pHlp->pfnPrintf(pHlp, " Command buffer BAR = %#RX64\n", CmdBufBar.u64); 3107 3214 if (fVerbose) 3108 3215 { 3109 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", CmdBufBar.n.u40 CmdBase);3216 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", CmdBufBar.n.u40Base); 3110 3217 pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen, 3111 3218 cEntries, cbBuffer); … … 3117 3224 uint32_t cEntries; 3118 3225 uint32_t cbBuffer; 3119 uint8_t const uEncodedLen = EvtLogBar.n.u4 EvtLen;3226 uint8_t const uEncodedLen = EvtLogBar.n.u4Len; 3120 3227 iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer); 3121 3228 pHlp->pfnPrintf(pHlp, " Event log BAR = %#RX64\n", EvtLogBar.u64); 3122 3229 if (fVerbose) 3123 3230 { 3124 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", EvtLogBar.n.u40 EvtBase);3231 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", EvtLogBar.n.u40Base); 3125 3232 pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen, 3126 3233 cEntries, cbBuffer); … … 3217 3324 pHlp->pfnPrintf(pHlp, " User/supervisor page protection support = %RTbool\n", ExtFeat.n.u1UserSupervisorSup); 3218 3325 pHlp->pfnPrintf(pHlp, " Device table segments supported = %#x (%u)\n", ExtFeat.n.u2DevTabSegSup, 3219 g_a DevTabSegments[ExtFeat.n.u2DevTabSegSup]);3326 g_acDevTabSegs[ExtFeat.n.u2DevTabSegSup]); 3220 3327 pHlp->pfnPrintf(pHlp, " PPR log overflow early warning support = %RTbool\n", ExtFeat.n.u1PprLogOverflowWarn); 3221 3328 pHlp->pfnPrintf(pHlp, " PPR auto response support = %RTbool\n", ExtFeat.n.u1PprAutoRespSup); … … 3239 3346 uint32_t cEntries; 3240 3347 uint32_t cbBuffer; 3241 uint8_t const uEncodedLen = PprLogBar.n.u4 PprLogLen;3348 uint8_t const uEncodedLen = PprLogBar.n.u4Len; 3242 3349 iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer); 3243 3350 pHlp->pfnPrintf(pHlp, " PPR Log BAR = %#RX64\n", PprLogBar.u64); 3244 3351 if (fVerbose) 3245 3352 { 3246 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", PprLogBar.n.u40 PprLogBase);3353 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", PprLogBar.n.u40Base); 3247 3354 pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen, 3248 3355 cEntries, cbBuffer); … … 3276 3383 uint32_t cEntries; 3277 3384 uint32_t cbBuffer; 3278 uint8_t const uEncodedLen = GALogBar.n.u4 GALogLen;3385 uint8_t const uEncodedLen = GALogBar.n.u4Len; 3279 3386 iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer); 3280 3387 pHlp->pfnPrintf(pHlp, " Guest Log BAR = %#RX64\n", GALogBar.u64); 3281 3388 if (fVerbose) 3282 3389 { 3283 pHlp->pfnPrintf(pHlp, " Base address = %RTbool\n", GALogBar.n.u40 GALogBase);3390 pHlp->pfnPrintf(pHlp, " Base address = %RTbool\n", GALogBar.n.u40Base); 3284 3391 pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen, 3285 3392 cEntries, cbBuffer); … … 3298 3405 uint32_t cEntries; 3299 3406 uint32_t cbBuffer; 3300 uint8_t const uEncodedLen = PprLogBBar.n.u4 PprLogLen;3407 uint8_t const uEncodedLen = PprLogBBar.n.u4Len; 3301 3408 iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer); 3302 3409 pHlp->pfnPrintf(pHlp, " PPR Log B BAR = %#RX64\n", PprLogBBar.u64); 3303 3410 if (fVerbose) 3304 3411 { 3305 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", PprLogBBar.n.u40 PprLogBase);3412 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", PprLogBBar.n.u40Base); 3306 3413 pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen, 3307 3414 cEntries, cbBuffer); … … 3313 3420 uint32_t cEntries; 3314 3421 uint32_t cbBuffer; 3315 uint8_t const uEncodedLen = EvtLogBBar.n.u4 EvtLen;3422 uint8_t const uEncodedLen = EvtLogBBar.n.u4Len; 3316 3423 iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer); 3317 3424 pHlp->pfnPrintf(pHlp, " Event Log B BAR = %#RX64\n", EvtLogBBar.u64); 3318 3425 if (fVerbose) 3319 3426 { 3320 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", EvtLogBBar.n.u40 EvtBase);3427 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", EvtLogBBar.n.u40Base); 3321 3428 pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen, 3322 3429 cEntries, cbBuffer); … … 3330 3437 if (fVerbose) 3331 3438 { 3332 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", DevTabSeg.n.u40 DevTabBase);3439 pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", DevTabSeg.n.u40Base); 3333 3440 pHlp->pfnPrintf(pHlp, " Size = %#x (%u bytes)\n", DevTabSeg.n.u8Size, 3334 (DevTabSeg.n.u8Size + 1) << X86_PAGE_4K_SHIFT);3441 IOMMU_GET_DEV_TAB_SIZE(DevTabSeg.n.u8Size)); 3335 3442 } 3336 3443 } … … 3663 3770 * device construction and remain read-only through the lifetime of the VM. 3664 3771 */ 3665 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 3666 Assert(pThis); 3667 3772 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 3668 3773 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0]; 3669 3774 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev); 3670 3775 3671 pThis->DevTabBaseAddr.u64 = 0; 3672 pThis->CmdBufBaseAddr.u64 = 0; 3673 pThis->EvtLogBaseAddr.u64 = 0; 3674 pThis->Ctrl.u64 = 0; 3675 pThis->ExclRangeBaseAddr.u64 = 0; 3676 pThis->ExclRangeLimit.u64 = 0; 3776 pThis->DevTabBaseAddr.u64 = 0; 3777 3778 pThis->CmdBufBaseAddr.u64 = 0; 3779 pThis->CmdBufBaseAddr.n.u4Len = 8; 3780 3781 pThis->EvtLogBaseAddr.u64 = 0; 3782 pThis->EvtLogBaseAddr.n.u4Len = 8; 3783 3784 pThis->Ctrl.u64 = 0; 3785 3786 pThis->ExclRangeBaseAddr.u64 = 0; 3787 pThis->ExclRangeLimit.u64 = 0; 3788 3677 3789 pThis->ExtFeat.n.u1PrefetchSup = 0; 3678 3790 pThis->ExtFeat.n.u1PprSup = 0; … … 3694 3806 pThis->ExtFeat.n.u5MaxPasidSup = 0; /* Requires GstTranslateSup. */ 3695 3807 pThis->ExtFeat.n.u1UserSupervisorSup = 0; 3696 AssertCompile(IOMMU_MAX_DEV_TAB_SEGMENTS < RT_ELEMENTS(g_a DevTabSegments));3808 AssertCompile(IOMMU_MAX_DEV_TAB_SEGMENTS < RT_ELEMENTS(g_acDevTabSegs)); 3697 3809 pThis->ExtFeat.n.u2DevTabSegSup = IOMMU_MAX_DEV_TAB_SEGMENTS; 3698 3810 pThis->ExtFeat.n.u1PprLogOverflowWarn = 0; … … 3710 3822 pThis->ExtFeat.n.u1GstUpdateDisSup = 0; 3711 3823 pThis->ExtFeat.n.u1ForcePhysDstSup = 0; 3712 pThis->PprLogBaseAddr.u64 = 0; 3713 pThis->HwEvtHi.u64 = 0; 3714 pThis->HwEvtLo = 0; 3715 pThis->HwEvtStatus.u64 = 0; 3716 pThis->GALogBaseAddr.n.u40GALogBase = 0; 3717 pThis->GALogBaseAddr.n.u4GALogLen = 8; 3718 pThis->GALogTailAddr.u64 = 0; 3719 pThis->PprLogBBaseAddr.n.u40PprLogBase = 0; 3720 pThis->PprLogBBaseAddr.n.u4PprLogLen = 8; 3721 pThis->EvtLogBBaseAddr.n.u40EvtBase = 0; 3722 pThis->EvtLogBBaseAddr.n.u4EvtLen = 8; 3824 3825 pThis->PprLogBaseAddr.u64 = 0; 3826 pThis->PprLogBaseAddr.n.u4Len = 8; 3827 3828 pThis->HwEvtHi.u64 = 0; 3829 pThis->HwEvtLo = 0; 3830 pThis->HwEvtStatus.u64 = 0; 3831 3832 pThis->GALogBaseAddr.n.u40Base = 0; 3833 pThis->GALogBaseAddr.n.u4Len = 8; 3834 pThis->GALogTailAddr.u64 = 0; 3835 3836 pThis->PprLogBBaseAddr.n.u40Base = 0; 3837 pThis->PprLogBBaseAddr.n.u4Len = 8; 3838 pThis->EvtLogBBaseAddr.n.u40Base = 0; 3839 pThis->EvtLogBBaseAddr.n.u4Len = 8; 3840 3723 3841 memset(&pThis->DevTabSeg[0], 0, sizeof(pThis->DevTabSeg)); 3724 pThis->DevSpecificFeat.u64 = 0; 3725 pThis->DevSpecificCtrl.u64 = 0; 3726 pThis->DevSpecificStatus.u64 = 0; 3727 pThis->MsiMiscInfo.u64 = 0; 3728 pThis->PerfOptCtrl.u32 = 0; 3729 pThis->XtGenIntrCtrl.u64 = 0; 3730 pThis->XtPprIntrCtrl.u64 = 0; 3731 pThis->XtGALogIntrCtrl.u64 = 0; 3842 3843 pThis->DevSpecificFeat.u64 = 0; 3844 pThis->DevSpecificCtrl.u64 = 0; 3845 pThis->DevSpecificStatus.u64 = 0; 3846 3847 pThis->MsiMiscInfo.u64 = 0; 3848 pThis->PerfOptCtrl.u32 = 0; 3849 3850 pThis->XtGenIntrCtrl.u64 = 0; 3851 pThis->XtPprIntrCtrl.u64 = 0; 3852 pThis->XtGALogIntrCtrl.u64 = 0; 3853 3732 3854 memset(&pThis->aMarcApers[0], 0, sizeof(pThis->aMarcApers)); 3733 pThis->RsvdReg = 0; 3734 pThis->CmdBufHeadPtr.u64 = 0; 3735 pThis->CmdBufTailPtr.u64 = 0; 3736 pThis->EvtLogHeadPtr.u64 = 0; 3737 pThis->EvtLogTailPtr.u64 = 0; 3738 pThis->Status.u64 = 0; 3739 pThis->PprLogHeadPtr.u64 = 0; 3740 pThis->PprLogTailPtr.u64 = 0; 3741 pThis->GALogHeadPtr.u64 = 0; 3742 pThis->GALogTailPtr.u64 = 0; 3743 pThis->PprLogBHeadPtr.u64 = 0; 3744 pThis->PprLogBTailPtr.u64 = 0; 3745 pThis->EvtLogBHeadPtr.u64 = 0; 3746 pThis->EvtLogBTailPtr.u64 = 0; 3747 pThis->PprLogAutoResp.u64 = 0; 3748 pThis->PprLogOverflowEarly.u64 = 0; 3749 pThis->PprLogBOverflowEarly.u64 = 0; 3855 3856 pThis->RsvdReg = 0; 3857 3858 pThis->CmdBufHeadPtr.u64 = 0; 3859 pThis->CmdBufTailPtr.u64 = 0; 3860 pThis->EvtLogHeadPtr.u64 = 0; 3861 pThis->EvtLogTailPtr.u64 = 0; 3862 3863 pThis->Status.u64 = 0; 3864 3865 pThis->PprLogHeadPtr.u64 = 0; 3866 pThis->PprLogTailPtr.u64 = 0; 3867 3868 pThis->GALogHeadPtr.u64 = 0; 3869 pThis->GALogTailPtr.u64 = 0; 3870 3871 pThis->PprLogBHeadPtr.u64 = 0; 3872 pThis->PprLogBTailPtr.u64 = 0; 3873 3874 pThis->EvtLogBHeadPtr.u64 = 0; 3875 pThis->EvtLogBTailPtr.u64 = 0; 3876 3877 pThis->PprLogAutoResp.u64 = 0; 3878 pThis->PprLogOverflowEarly.u64 = 0; 3879 pThis->PprLogBOverflowEarly.u64 = 0; 3750 3880 3751 3881 PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_BASE_ADDR_REG_LO, 0);
Note:
See TracChangeset
for help on using the changeset viewer.