Changeset 84317 in vbox
- Timestamp:
- May 15, 2020 9:40:53 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
include/VBox/err.h (modified) (1 diff)
-
src/VBox/Devices/Bus/DevIommuAmd.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/err.h
r84227 r84317 2981 2981 /** Access denied for the address. */ 2982 2982 #define VERR_IOMMU_ADDR_ACCESS_DENIED (-7205) 2983 /** Internal error - Command not supported. */ 2984 #define VERR_IOMMU_CMD_NOT_SUPPORTED (-7206) 2985 /** Internal error - Command format (or reserved bits) invalid. */ 2986 #define VERR_IOMMU_CMD_INVALID_FORMAT (-7207) 2987 /** Internal error - Command hardware failure. */ 2988 #define VERR_IOMMU_CMD_HW_ERROR (-7208) 2983 2989 /** @} */ 2984 2990 -
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r84315 r84317 2183 2183 2184 2184 /** 2185 * ILLEGAL_COMMAND_ERROR Event Types.2186 * In accordance with the AMD spec.2187 */2188 typedef enum EVT_ILLEGAL_CMD_ERR_TYPE_T2189 {2190 kIllegalCmdErrType_RsvdNotZero = 0,2191 kIllegalCmdErrType_CmdNotSupported,2192 kIllegalCmdErrType_IotlbNotSupported2193 } EVT_ILLEGAL_CMD_ERR_TYPE_T;2194 /** Pointer to an illegal command error event type. */2195 typedef EVT_ILLEGAL_CMD_ERR_TYPE_T *PEVT_ILLEGAL_CMD_ERR_TYPE_T;2196 2197 /**2198 2185 * IOTLB_INV_TIMEOUT Event Types. 2199 2186 * In accordance with the AMD spec. … … 3346 3333 Assert(!(off & 7) || !(off & 3)); 3347 3334 3348 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);3349 P PDMPCIDEV pPciDev = pDevIns->apPciDevs[0];3335 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 3336 PCPDMPCIDEV pPciDev = pDevIns->apPciDevs[0]; 3350 3337 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev); 3351 3338 … … 3784 3771 * @param pDevIns The IOMMU device instance. 3785 3772 * @param pEvtIllegalCmd The illegal command error event. 3786 * @param enmEvtType The illegal command error event type. 3787 */ 3788 static void iommuAmdRaiseIllegalCmdEvent(PPDMDEVINS pDevIns, PCEVT_ILLEGAL_CMD_ERR_T pEvtIllegalCmd, 3789 EVT_ILLEGAL_CMD_ERR_TYPE_T enmEvtType) 3773 */ 3774 static void iommuAmdRaiseIllegalCmdEvent(PPDMDEVINS pDevIns, PCEVT_ILLEGAL_CMD_ERR_T pEvtIllegalCmd) 3790 3775 { 3791 3776 AssertCompile(sizeof(EVT_GENERIC_T) == sizeof(EVT_ILLEGAL_DTE_T)); … … 3800 3785 IOMMU_UNLOCK(pDevIns); 3801 3786 3802 Log((IOMMU_LOG_PFX ": Raised ILLEGAL_COMMAND_ERROR. GCPhysCmd=%#RGp enmType=%u\n", pEvtIllegalCmd->n.u64Addr, enmEvtType)); 3803 NOREF(enmEvtType); 3787 Log((IOMMU_LOG_PFX ": Raised ILLEGAL_COMMAND_ERROR. Addr=%#RGp\n", pEvtIllegalCmd->n.u64Addr)); 3804 3788 } 3805 3789 … … 4609 4593 * @returns VBox status code. 4610 4594 * @param pDevIns The IOMMU device instance. 4595 * @param pCmd The command to process. 4611 4596 * @param GCPhysCmd The system physical address of the command. 4612 * @param p Cmd The command to process.4597 * @param pEvtError Where to store the error event in case of failures. 4613 4598 * 4614 4599 * @thread Command thread. 4615 4600 */ 4616 static int iommuAmdR3ProcessCmd(PPDMDEVINS pDevIns, RTGCPHYS GCPhysCmd, PCCMD_GENERIC_T pCmd)4601 static int iommuAmdR3ProcessCmd(PPDMDEVINS pDevIns, PCCMD_GENERIC_T pCmd, RTGCPHYS GCPhysCmd, PEVT_GENERIC_T pEvtError) 4617 4602 { 4618 4603 IOMMU_ASSERT_NOT_LOCKED(pDevIns); 4619 4620 EVT_ILLEGAL_CMD_ERR_T EvtIllegalCmdErr;4621 4604 4622 4605 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); … … 4632 4615 if (!(pCmdComWait->au64[0] & ~IOMMU_CMD_COM_WAIT_QWORD_0_VALID_MASK)) 4633 4616 { 4634 /* If Completion Store is requested, write the Store Data to the specified Store Address.*/4617 /* If Completion Store is requested, write the StoreData to the specified address.*/ 4635 4618 if (pCmdComWait->n.u1Store) 4636 4619 { 4637 4620 RTGCPHYS const GCPhysStore = RT_MAKE_U64(pCmdComWait->n.u29StoreAddrLo << 3, pCmdComWait->n.u20StoreAddrHi); 4638 4621 uint64_t const u64Data = pCmdComWait->n.u64StoreData; 4639 4640 4622 int rc = PDMDevHlpPCIPhysWrite(pDevIns, GCPhysStore, &u64Data, sizeof(u64Data)); 4641 4623 if (RT_FAILURE(rc)) 4642 4624 { 4643 EVT_CMD_HW_ERR_T EvtCmdHwErr; 4644 iommuAmdInitCmdHwErrorEvent(GCPhysStore, &EvtCmdHwErr); 4645 iommuAmdRaiseCmdHwErrorEvent(pDevIns, &EvtCmdHwErr); 4646 Log((IOMMU_LOG_PFX ": Failed to write StoreData (%#RX64) to %#RGp. rc=%Rrc\n", u64Data, GCPhysStore, rc)); 4647 return rc; 4625 Log((IOMMU_LOG_PFX ": Cmd(%#x): Failed to write StoreData (%#RX64) to %#RGp, rc=%Rrc\n", bCmd, u64Data, 4626 GCPhysStore, rc)); 4627 iommuAmdInitCmdHwErrorEvent(GCPhysStore, (PEVT_CMD_HW_ERR_T)pEvtError); 4628 return VERR_IOMMU_CMD_HW_ERROR; 4648 4629 } 4649 4630 } 4650 4631 4651 /* If command completion interrupt is requested, honor it. */4632 /* If command completion interrupt is requested, raise an interrupt. */ 4652 4633 if (pCmdComWait->n.u1Interrupt) 4653 4634 { … … 4668 4649 return VINF_SUCCESS; 4669 4650 } 4670 4671 iommuAmdInitIllegalCmdEvent(GCPhysCmd, &EvtIllegalCmdErr); 4672 iommuAmdRaiseIllegalCmdEvent(pDevIns, &EvtIllegalCmdErr, kIllegalCmdErrType_RsvdNotZero); 4673 return VERR_INVALID_FUNCTION; 4651 iommuAmdInitIllegalCmdEvent(GCPhysCmd, (PEVT_ILLEGAL_CMD_ERR_T)pEvtError); 4652 return VERR_IOMMU_CMD_INVALID_FORMAT; 4674 4653 } 4675 4654 4676 4655 case IOMMU_CMD_INV_DEV_TAB_ENTRY: 4656 { 4657 /** @todo IOMMU: Implement this once we implement IOTLB. Pretend success until 4658 * then. */ 4659 return VINF_SUCCESS; 4660 } 4661 4677 4662 case IOMMU_CMD_INV_IOMMU_PAGES: 4663 { 4664 /** @todo IOMMU: Implement this once we implement IOTLB. Pretend success until 4665 * then. */ 4666 return VINF_SUCCESS; 4667 } 4668 4678 4669 case IOMMU_CMD_INV_IOTLB_PAGES: 4670 { 4671 uint32_t const uCapHdr = PDMPciDevGetDWord(pDevIns->apPciDevs[0], IOMMU_PCI_OFF_CAP_HDR); 4672 if (RT_BF_GET(uCapHdr, IOMMU_BF_CAPHDR_IOTLB_SUP)) 4673 { 4674 /** @todo IOMMU: Implement remote IOTLB invalidation. */ 4675 return VERR_NOT_IMPLEMENTED; 4676 } 4677 iommuAmdInitIllegalCmdEvent(GCPhysCmd, (PEVT_ILLEGAL_CMD_ERR_T)pEvtError); 4678 return VERR_IOMMU_CMD_NOT_SUPPORTED; 4679 } 4680 4679 4681 case IOMMU_CMD_INV_INTR_TABLE: 4680 4682 { 4681 return VERR_NOT_IMPLEMENTED; 4683 /** @todo IOMMU: Implement this once we implement IOTLB. Pretend success until 4684 * then. */ 4685 return VINF_SUCCESS; 4682 4686 } 4683 4687 … … 4686 4690 if (pThis->ExtFeat.n.u1PrefetchSup) 4687 4691 { 4688 /** @todo IOMMU: Implement prefetch. */4692 /** @todo IOMMU: Implement prefetch. Pretend success until then. */ 4689 4693 return VINF_SUCCESS; 4690 4694 } 4691 iommuAmdInitIllegalCmdEvent(GCPhysCmd, &EvtIllegalCmdErr); 4692 iommuAmdRaiseIllegalCmdEvent(pDevIns, &EvtIllegalCmdErr, kIllegalCmdErrType_CmdNotSupported); 4693 return VERR_INVALID_FUNCTION; 4695 iommuAmdInitIllegalCmdEvent(GCPhysCmd, (PEVT_ILLEGAL_CMD_ERR_T)pEvtError); 4696 return VERR_IOMMU_CMD_NOT_SUPPORTED; 4694 4697 } 4695 4698 4696 4699 case IOMMU_CMD_COMPLETE_PPR_REQ: 4700 { 4701 /* We don't support PPR requests yet. */ 4702 Assert(!pThis->ExtFeat.n.u1PprSup); 4703 iommuAmdInitIllegalCmdEvent(GCPhysCmd, (PEVT_ILLEGAL_CMD_ERR_T)pEvtError); 4704 return VERR_IOMMU_CMD_NOT_SUPPORTED; 4705 } 4706 4697 4707 case IOMMU_CMD_INV_IOMMU_ALL: 4698 4708 { 4699 NOREF(pThis); 4700 return VERR_NOT_IMPLEMENTED; 4701 } 4702 4703 default: 4704 break; 4705 } 4706 4707 Log((IOMMU_LOG_PFX ": Unrecognized or unsupported command opcode %u (%#x)\n", bCmd, bCmd)); 4708 return VERR_NOT_SUPPORTED; 4709 if (pThis->ExtFeat.n.u1InvAllSup) 4710 { 4711 /** @todo IOMMU: Invalidate all. Pretend success until then. */ 4712 return VINF_SUCCESS; 4713 } 4714 iommuAmdInitIllegalCmdEvent(GCPhysCmd, (PEVT_ILLEGAL_CMD_ERR_T)pEvtError); 4715 return VERR_IOMMU_CMD_NOT_SUPPORTED; 4716 } 4717 } 4718 4719 Log((IOMMU_LOG_PFX ": Cmd(%#x): Unrecognized\n", bCmd)); 4720 iommuAmdInitIllegalCmdEvent(GCPhysCmd, (PEVT_ILLEGAL_CMD_ERR_T)pEvtError); 4721 return VERR_IOMMU_CMD_NOT_SUPPORTED; 4709 4722 } 4710 4723 … … 4776 4789 4777 4790 /* Process the fetched command. */ 4791 EVT_GENERIC_T EvtError; 4778 4792 IOMMU_UNLOCK(pDevIns); 4779 rc = iommuAmdR3ProcessCmd(pDevIns, GCPhysCmd, &Cmd);4793 rc = iommuAmdR3ProcessCmd(pDevIns, &Cmd, GCPhysCmd, &EvtError); 4780 4794 IOMMU_LOCK(pDevIns); 4781 4795 if (RT_FAILURE(rc)) 4796 { 4797 if ( rc == VERR_IOMMU_CMD_NOT_SUPPORTED 4798 || rc == VERR_IOMMU_CMD_INVALID_FORMAT) 4799 iommuAmdRaiseIllegalCmdEvent(pDevIns, (PCEVT_ILLEGAL_CMD_ERR_T)&EvtError); 4800 else if (rc == VERR_IOMMU_CMD_HW_ERROR) 4801 iommuAmdRaiseCmdHwErrorEvent(pDevIns, (PCEVT_CMD_HW_ERR_T)&EvtError); 4782 4802 break; 4803 } 4783 4804 } 4784 4805 else … … 4919 4940 { 4920 4941 PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 4921 P PDMPCIDEV pPciDev = pDevIns->apPciDevs[0];4942 PCPDMPCIDEV pPciDev = pDevIns->apPciDevs[0]; 4922 4943 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev); 4923 4944
Note:
See TracChangeset
for help on using the changeset viewer.

