Changeset 80201 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Aug 8, 2019 5:36:15 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp
r80194 r80201 67 67 * 68 68 * @param member - Member of VIRTIO_PCI_COMMON_CFG_T 69 * @param uOffset - Implied parameter: Offset into VIRTIO_PCI_COMMON_CFG_T70 * @param cb - Implied parameter: Number of bytes to access71 69 * @result - true or false 72 70 */ 73 71 #define MATCH_SCSI_CONFIG(member) \ 74 (RT_SIZEOFMEMB(VIRTIO_SCSI_CONFIG_T, member) == 64\72 (RT_SIZEOFMEMB(VIRTIO_SCSI_CONFIG_T, member) == 8 \ 75 73 && ( uOffset == RT_OFFSETOF(VIRTIO_SCSI_CONFIG_T, member) \ 76 74 || uOffset == RT_OFFSETOF(VIRTIO_SCSI_CONFIG_T, member) + sizeof(uint32_t)) \ -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp
r80194 r80201 771 771 else 772 772 { 773 LogFunc(("Bad access by guest to virtio_pci_common_cfg: uOffset=%d, cb=%d\n", uOffset, cb)); 773 LogFunc(("Bad guest %s access to virtio_pci_common_cfg: uOffset=%d, cb=%d\n", 774 fWrite ? "write" : "read ", uOffset, cb)); 774 775 rc = VERR_ACCESS_DENIED; 775 776 } … … 1209 1210 1210 1211 PVIRTIO_PCI_CAP_T pCfg; 1211 1212 /* Common capability (VirtIO 1.0 spec) */ 1212 uint32_t cbRegion = 0; 1213 1214 /* Common capability (VirtIO 1.0 spec, section 4.1.4.3) */ 1213 1215 pCfg = (PVIRTIO_PCI_CAP_T)&pVirtio->dev.abConfig[0x40]; 1214 1216 pCfg->uCfgType = VIRTIO_PCI_CAP_COMMON_CFG; … … 1219 1221 pCfg->uOffset = 0; 1220 1222 pCfg->uLength = sizeof(VIRTIO_PCI_COMMON_CFG_T); 1223 cbRegion += pCfg->uLength; 1221 1224 pVirtio->pCommonCfgCap = pCfg; 1222 1225 1223 /* Notify capability (VirtIO 1.0 spec) */ 1226 /* Notify capability (VirtIO 1.0 spec, section 4.1.4.4). Note: uLength is based on assumption 1227 * that each queue's uQueueNotifyOff is set equal to uQueueSelect's ordinal 1228 * value of the queue */ 1224 1229 pCfg = (PVIRTIO_PCI_CAP_T)&pVirtio->dev.abConfig[pCfg->uCapNext]; 1225 1230 pCfg->uCfgType = VIRTIO_PCI_CAP_NOTIFY_CFG; … … 1229 1234 pCfg->uBar = uVirtioCapBar; 1230 1235 pCfg->uOffset = pVirtio->pCommonCfgCap->uOffset + pVirtio->pCommonCfgCap->uLength; 1231 pCfg->uLength = 4; /* This needs to be calculated differently */ 1236 pCfg->uLength = VIRTIO_MAX_QUEUES * uNotifyOffMultiplier + 2; /* will change in VirtIO 1.1 */ 1237 cbRegion += pCfg->uLength; 1232 1238 pVirtio->pNotifyCap = (PVIRTIO_PCI_NOTIFY_CAP_T)pCfg; 1233 1239 pVirtio->pNotifyCap->uNotifyOffMultiplier = uNotifyOffMultiplier; 1234 1240 1235 /* ISR capability (VirtIO 1.0 spec ) */1241 /* ISR capability (VirtIO 1.0 spec, section 4.1.4.5) */ 1236 1242 pCfg = (PVIRTIO_PCI_CAP_T)&pVirtio->dev.abConfig[pCfg->uCapNext]; 1237 1243 pCfg->uCfgType = VIRTIO_PCI_CAP_ISR_CFG; … … 1242 1248 pCfg->uOffset = pVirtio->pNotifyCap->pciCap.uOffset + pVirtio->pNotifyCap->pciCap.uLength; 1243 1249 pCfg->uLength = sizeof(uint32_t); 1250 cbRegion += pCfg->uLength; 1244 1251 pVirtio->pIsrCap = pCfg; 1245 1252 1246 /* PCI Cfg capability (VirtIO 1.0 spec ) */1253 /* PCI Cfg capability (VirtIO 1.0 spec, section 4.1.4.7) */ 1247 1254 pCfg = (PVIRTIO_PCI_CAP_T)&pVirtio->dev.abConfig[pCfg->uCapNext]; 1248 1255 pCfg->uCfgType = VIRTIO_PCI_CAP_PCI_CFG; … … 1253 1260 pCfg->uOffset = pVirtio->pIsrCap->uOffset + pVirtio->pIsrCap->uLength; 1254 1261 pCfg->uLength = 4; /* Initialize a non-zero 4-byte aligned so Linux virtio_pci module recognizes this cap */ 1262 cbRegion += pCfg->uLength; 1255 1263 pVirtio->pPciCfgCap = (PVIRTIO_PCI_CFG_CAP_T)pCfg; 1256 1264 1257 1265 if (pVirtio->pDevSpecificCap) 1258 1266 { 1259 /* Following capability mapped via VirtIO 1.0: struct virtio_pci_dev_cap (VIRTIODEVCAP)*/ 1267 /* Following capability (via VirtIO 1.0, section 4.1.4.6). Client defines the 1268 * device specific configuration struct and passes its params to this constructor */ 1260 1269 pCfg = (PVIRTIO_PCI_CAP_T)&pVirtio->dev.abConfig[pCfg->uCapNext]; 1261 1270 pCfg->uCfgType = VIRTIO_PCI_CAP_DEVICE_CFG; … … 1266 1275 pCfg->uOffset = pVirtio->pIsrCap->uOffset + pVirtio->pIsrCap->uLength; 1267 1276 pCfg->uLength = cbDevSpecificCap; 1277 cbRegion += pCfg->uLength; 1268 1278 pVirtio->pDeviceCap = pCfg; 1269 1279 } … … 1287 1297 } 1288 1298 1289 rc = PDMDevHlpPCIIORegionRegister(pDevIns, uVirtioCapBar, 4096, 1299 Log(("cbRegion = %d (0x%x)\n", cbRegion, cbRegion)); 1300 rc = PDMDevHlpPCIIORegionRegister(pDevIns, uVirtioCapBar, cbRegion, 1290 1301 PCI_ADDRESS_SPACE_MEM, virtioR3Map); 1291 1302 if (RT_FAILURE(rc)) -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0_impl.h
r80194 r80201 269 269 */ 270 270 #define COMMON_CFG(member) \ 271 (RT_SIZEOFMEMB(VIRTIO_PCI_COMMON_CFG_T, member) == 64\271 (RT_SIZEOFMEMB(VIRTIO_PCI_COMMON_CFG_T, member) == 8 \ 272 272 && ( uOffset == RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member) \ 273 273 || uOffset == RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member) + sizeof(uint32_t)) \ … … 286 286 uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \ 287 287 if (fWrite) \ 288 memcpy(((char *)&pVirtio->member) + u Offset, (const char *)pv, cb); \288 memcpy(((char *)&pVirtio->member) + uIntraOff, (const char *)pv, cb); \ 289 289 else \ 290 memcpy((char *)pv, (const char *)(((char *)&pVirtio->member) + u Offset), cb); \290 memcpy((char *)pv, (const char *)(((char *)&pVirtio->member) + uIntraOff), cb); \ 291 291 LOG_ACCESSOR(member); \ 292 292 } … … 296 296 uint32_t uIntraOff = uOffset - RT_OFFSETOF(VIRTIO_PCI_COMMON_CFG_T, member); \ 297 297 if (fWrite) \ 298 memcpy(((char *)(pVirtio->member + idx)) + u Offset, (const char *)pv, cb); \298 memcpy(((char *)(pVirtio->member + idx)) + uIntraOff, (const char *)pv, cb); \ 299 299 else \ 300 memcpy((char *)pv, (const char *)(((char *)(pVirtio->member + idx)) + u Offset), cb); \300 memcpy((char *)pv, (const char *)(((char *)(pVirtio->member + idx)) + uIntraOff), cb); \ 301 301 LOG_INDEXED_ACCESSOR(member, idx); \ 302 302 } … … 309 309 else \ 310 310 { \ 311 memcpy((char *)pv, (const char *)(((char *)&pVirtio->member) + u Offset), cb); \311 memcpy((char *)pv, (const char *)(((char *)&pVirtio->member) + uIntraOff), cb); \ 312 312 LOG_ACCESSOR(member); \ 313 313 } \ … … 351 351 if (status & VIRTIO_STATUS_DRIVER) 352 352 Log(("%sDRIVER", primed++ ? " | " : "")); 353 if (status & VIRTIO_STATUS_FEATURES_OK) 354 Log(("%sFEATURES_OK", primed++ ? " | " : "")); 353 355 if (status & VIRTIO_STATUS_DRIVER_OK) 354 356 Log(("%sDRIVER_OK", primed++ ? " | " : "")); 355 if (status & VIRTIO_STATUS_FEATURES_OK)356 Log(("%sFEATURES_OK", primed++ ? " | " : ""));357 357 if (status & VIRTIO_STATUS_FAILED) 358 358 Log(("%sFAILED", primed++ ? " | " : ""));
Note:
See TracChangeset
for help on using the changeset viewer.