Changeset 83442 in vbox for trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
- Timestamp:
- Mar 26, 2020 4:13:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r83377 r83442 35 35 */ 36 36 #define IOMMU_CMD_COMPLETION_WAIT 0x01 37 #define IOMMU_CMD_INV_DEV TAB_ENTRY0x0237 #define IOMMU_CMD_INV_DEV_TAB_ENTRY 0x02 38 38 #define IOMMU_CMD_INV_IOMMU_PAGES 0x03 39 39 #define IOMMU_CMD_INV_IOTLB_PAGES 0x04 … … 184 184 * @{ 185 185 */ 186 /** MsiNumGA: MSI message number for guest v APIC. */186 /** MsiNumGA: MSI message number for guest virtual-APIC log. */ 187 187 #define IOMMU_BF_MISCINFO_1_MSI_NUM_GA_SHIFT 0 188 188 #define IOMMU_BF_MISCINFO_1_MSI_NUM_GA_MASK UINT32_C(0x0000001f) … … 202 202 #define IOMMU_BF_MSI_CAPHDR_CAP_ID_SHIFT 0 203 203 #define IOMMU_BF_MSI_CAPHDR_CAP_ID_MASK UINT32_C(0x000000ff) 204 /** MsiCapPtr: Pointer (PCI config offset) to the next capability register. */204 /** MsiCapPtr: Pointer (PCI config offset) to the next capability. */ 205 205 #define IOMMU_BF_MSI_CAPHDR_CAP_PTR_SHIFT 8 206 206 #define IOMMU_BF_MSI_CAPHDR_CAP_PTR_MASK UINT32_C(0x0000ff00) … … 232 232 #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID_SHIFT 0 233 233 #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID_MASK UINT32_C(0x000000ff) 234 /** MsiMapCapPtr: Pointer (PCI config offset) to the next capability register. */234 /** MsiMapCapPtr: Pointer (PCI config offset) to the next capability. */ 235 235 #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR_SHIFT 8 236 236 #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR_MASK UINT32_C(0x0000ff00) … … 296 296 uint32_t u20PageTableRootPtrHi : 20; /**< Bits 51:32 - Page Table Root Pointer (Hi). */ 297 297 uint32_t u1Ppr : 1; /**< Bit 52 - PPR: Peripheral Page Request. */ 298 uint32_t u1G rpr : 1;/**< Bit 53 - GRPR: Guest PPR Response with PASID. */299 uint32_t u1G Iov : 1;/**< Bit 54 - GIoV: Guest I/O Protection Valid. */300 uint32_t u1G Valid : 1;/**< Bit 55 - GV: Guest translation Valid. */301 uint32_t u2G lx : 2;/**< Bits 57:56 - GLX: Guest Levels Translated. */302 uint32_t u3G Cr3TableRootPtrLo : 2;/**< Bits 60:58 - GCR3 TRP: Guest CR3 Table Root Pointer (Lo). */298 uint32_t u1GstPprRespPasid : 1; /**< Bit 53 - GRPR: Guest PPR Response with PASID. */ 299 uint32_t u1GstIoValid : 1; /**< Bit 54 - GIoV: Guest I/O Protection Valid. */ 300 uint32_t u1GstTranslateValid : 1; /**< Bit 55 - GV: Guest translation Valid. */ 301 uint32_t u2GstCr3RootTblTranslated : 2; /**< Bits 57:56 - GLX: Guest Levels Translated. */ 302 uint32_t u3GstCr3TableRootPtrLo : 2; /**< Bits 60:58 - GCR3 TRP: Guest CR3 Table Root Pointer (Lo). */ 303 303 uint32_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */ 304 304 uint32_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Write permission. */ 305 305 uint32_t u1Rsvd0 : 1; /**< Bit 63 - Reserved. */ 306 306 uint32_t u16DomainId : 1; /**< Bits 79:64 - Domain ID. */ 307 uint32_t u16G Cr3TableRootPtrMed : 16;/**< Bits 95:80 - GCR3 TRP: Guest CR3 Table Root Pointer (Mid). */308 uint32_t u1Io tlbEnable : 1; /**< Bit 96 - IOTLB Enable. */307 uint32_t u16GstCr3TableRootPtrMed : 16; /**< Bits 95:80 - GCR3 TRP: Guest CR3 Table Root Pointer (Mid). */ 308 uint32_t u1IoTlbEnable : 1; /**< Bit 96 - IOTLB Enable. */ 309 309 uint32_t u1SuppressPfEvents : 1; /**< Bit 97 - SE: Supress Page-fault events. */ 310 310 uint32_t u1SuppressAllPfEvents : 1; /**< Bit 98 - SA: Supress All Page-fault events. */ … … 315 315 uint32_t u2SysMgt : 2; /**< Bits 105:104 - SysMgt: System Management message enable. */ 316 316 uint32_t u1Rsvd1 : 1; /**< Bit 106 - Reserved. */ 317 uint32_t u21G cr3TableRootPtrHi : 21;/**< Bits 127:107 - GCR3 TRP: Guest CR3 Table Root Pointer (Hi). */317 uint32_t u21GstCr3TableRootPtrHi : 21; /**< Bits 127:107 - GCR3 TRP: Guest CR3 Table Root Pointer (Hi). */ 318 318 uint32_t u1IntrMapValid : 1; /**< Bit 128 - IV: Interrupt map Valid. */ 319 319 uint32_t u4IntrTableLength : 4; /**< Bits 132:129 - IntTabLen: Interrupt Table Length. */ … … 399 399 struct 400 400 { 401 uint32_t u1RemapEnable : 1; /**< Bit 0 - RemapEn: Remap enable. */401 uint32_t u1RemapEnable : 1; /**< Bit 0 - RemapEn: Remap Enable. */ 402 402 uint32_t u1SuppressPf : 1; /**< Bit 1 - SupIOPF: Supress I/O Page Fault. */ 403 403 uint32_t u3IntrType : 1; /**< Bits 4:2 - IntType: Interrupt Type. */ … … 440 440 struct 441 441 { 442 uint32_t u1Store : 1; /**< Bit 0- S: Completion Store. */443 uint32_t u1Interrupt : 1; /**< Bit 1- I: Completion Interrupt. */444 uint32_t u1Flush : 1; /**< Bit 2- F: Flush Queue. */442 uint32_t u1Store : 1; /**< Bit 0 - S: Completion Store. */ 443 uint32_t u1Interrupt : 1; /**< Bit 1 - I: Completion Interrupt. */ 444 uint32_t u1Flush : 1; /**< Bit 2 - F: Flush Queue. */ 445 445 uint32_t u29StoreAddrLo : 29; /**< Bits 31:3 - Store Address (Lo). */ 446 446 uint32_t u20StoreAddrHi : 20; /**< Bits 51:32 - Store Address (Hi). */ … … 833 833 AssertCompileSize(EVT_EVENT_COUNTER_ZERO, 16); 834 834 835 836 /** 837 * The IOMMU device state. 835 /** 836 * Device Table Base Address Register (MMIO). 837 * In accordance with the AMD spec. 838 */ 839 typedef union 840 { 841 struct 842 { 843 RT_GCC_EXTENSION uint64_t u9Size : 9; /**< Bits 8:0 - Size: Size of the device table. */ 844 RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 11:9 - Reserved. */ 845 RT_GCC_EXTENSION uint64_t u40DevTabBase : 40; /**< Bits 51:12 - DevTabBase: Device table base address. */ 846 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */ 847 } n; 848 /** The 64-bit unsigned integer view. */ 849 uint64_t u64; 850 } DEV_TAB_BAR_T; 851 AssertCompileSize(DEV_TAB_BAR_T, 8); 852 853 /** 854 * Command Buffer Base Address Register (MMIO). 855 * In accordance with the AMD spec. 856 */ 857 typedef union 858 { 859 struct 860 { 861 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */ 862 RT_GCC_EXTENSION uint64_t u40CmdBase : 40; /**< Bits 51:12 - ComBase: Command buffer base address. */ 863 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */ 864 RT_GCC_EXTENSION uint64_t u4CmdLen : 4; /**< Bits 59:56 - ComLen: Command buffer length. */ 865 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */ 866 } n; 867 /** The 64-bit unsigned integer view. */ 868 uint64_t u64; 869 } CMD_BUF_BAR_T; 870 AssertCompileSize(CMD_BUF_BAR_T, 8); 871 872 /** 873 * Event Log Base Address Register (MMIO). 874 * In accordance with the AMD spec. 875 */ 876 typedef union 877 { 878 struct 879 { 880 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */ 881 RT_GCC_EXTENSION uint64_t u40EvtBase : 40; /**< Bits 51:12 - EventBase: Event log base address. */ 882 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */ 883 RT_GCC_EXTENSION uint64_t u4EvtLen : 4; /**< Bits 59:56 - EventLen: Event log length. */ 884 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */ 885 } n; 886 /** The 64-bit unsigned integer view. */ 887 uint64_t u64; 888 } EVT_LOG_BUF_BAR_T; 889 AssertCompileSize(EVT_LOG_BUF_BAR_T, 8); 890 891 /** 892 * IOMMU Control Register (MMIO). 893 * In accordance with the AMD spec. 894 */ 895 typedef union 896 { 897 struct 898 { 899 uint32_t u1IommuEn : 1; /**< Bit 0 - IommuEn: IOMMU Enable. */ 900 uint32_t u1HtTunEn : 1; /**< Bit 1 - HtTunEn: HyperTransport Tunnel Enable. */ 901 uint32_t u1EvtLogEn : 1; /**< Bit 2 - EventLogEn: Event Log Enable. */ 902 uint32_t u1EvtIntrEn : 1; /**< Bit 3 - EventIntEn: Event Log Interrupt Enable. */ 903 uint32_t u1CompWaitIntrEn : 1; /**< Bit 4 - ComWaitIntEn: Completion Wait Interrupt Enable. */ 904 uint32_t u3InvTimeOut : 3; /**< Bits 7:5 - InvTimeOut: Invalidation Timeout. */ 905 uint32_t u1PassPW : 1; /**< Bit 8 - PassPW: Pass Posted Write. */ 906 uint32_t u1ResPassPW : 1; /**< Bit 9 - ResPassPW: Response Pass Posted Write. */ 907 uint32_t u1Coherent : 1; /**< Bit 10 - Coherent: HT read request packet Coherent bit. */ 908 uint32_t u1Isoc : 1; /**< Bit 11 - Isoc: HT read request packet Isochronous bit. */ 909 uint32_t u1CmdBufEn : 1; /**< Bit 12 - CmdBufEn: Command Buffer Enable. */ 910 uint32_t u1PprLogEn : 1; /**< Bit 13 - PprLogEn: Peripheral Page Request (PPR) Log Enable. */ 911 uint32_t u1PprIntrEn : 1; /**< Bit 14 - PprIntrEn: Peripheral Page Request Interrupt Enable. */ 912 uint32_t u1PprEn : 1; /**< Bit 15 - PprEn: Peripheral Page Request processing Enable. */ 913 uint32_t u1GstTranslateEn : 1; /**< Bit 16 - GTEn: Guest Translate Enable. */ 914 uint32_t u1GstVirtApicEn : 1; /**< Bit 17 - GAEn: Guest Virtual-APIC Enable. */ 915 uint32_t u4Crw : 1; /**< Bits 21:18 - CRW: Intended for future use (not documented). */ 916 uint32_t u1SmiFilterEn : 1; /**< Bit 22 - SmiFEn: SMI Filter Enable. */ 917 uint32_t u1SelfWriteBackDis : 1; /**< Bit 23 - SlfWBDis: Self Write-Back Disable. */ 918 uint32_t u1SmiFilterLogEn : 1; /**< Bit 24 - SmiFLogEn: SMI Filter Log Enable. */ 919 uint32_t u3GstVirtApicModeEn : 3; /**< Bits 27:25 - GAMEn: Guest Virtual-APIC Mode Enable. */ 920 uint32_t u1GstLogEn : 1; /**< Bit 28 - GALogEn: Guest Virtual-APIC GA Log Enable. */ 921 uint32_t u1GstIntrEn : 1; /**< Bit 29 - GAIntEn: Guest Virtual-APIC Interrupt Enable. */ 922 uint32_t u2DualPprLogEn : 2; /**< Bits 31:30 - DualPprLogEn: Dual Peripheral Page Request Log Enable. */ 923 uint32_t u2DualEvtLogEn : 2; /**< Bits 33:32 - DualEventLogEn: Dual Event Log Enable. */ 924 uint32_t u3DevTabSegEn : 3; /**< Bits 36:34 - DevTblSegEn: Device Table Segment Enable. */ 925 uint32_t u2PrivAbortEn : 2; /**< Bits 38:37 - PrivAbrtEn: Privilege Abort Enable. */ 926 uint32_t u1PprAutoRespEn : 1; /**< Bit 39 - PprAutoRspEn: Peripheral Page Request Auto Response Enable. */ 927 uint32_t u1MarcEn : 1; /**< Bit 40 - MarcEn: Memory Address Routing and Control Enable. */ 928 uint32_t u1BlockStopMarkEn : 1; /**< Bit 41 - BlkStopMarkEn: Block StopMark messages Enable. */ 929 uint32_t u1PprAutoRespAlwaysOnEn : 1; /**< Bit 42 - PprAutoRspAon:: PPR Auto Response - Always On Enable. */ 930 uint32_t u1DomainIDPNE : 1; /**< Bit 43 - DomainIDPE: Reserved (not documented). */ 931 uint32_t u1Rsvd0 : 1; /**< Bit 44 - Reserved. */ 932 uint32_t u1EnhancedPpr : 1; /**< Bit 45 - EPHEn: Enhanced Peripheral Page Request Handling Enable. */ 933 uint32_t u2HstAccDirtyBitUpdate : 2; /**< Bits 47:46 - HADUpdate: Access and Dirty Bit updated in host page table. */ 934 uint32_t u1GstDirtyUpdateDis : 1; /**< Bit 48 - GDUpdateDis: Disable hardare update of Dirty bit in GPT. */ 935 uint32_t u1Rsvd1 : 1; /**< Bit 49 - Reserved. */ 936 uint32_t u1X2ApicEn : 1; /**< Bit 50 - XTEn: Enable X2APIC. */ 937 uint32_t u1X2ApicIntrGenEn : 1; /**< Bit 51 - IntCapXTEn: Enable IOMMU X2APIC Interrupt generation. */ 938 uint32_t u2Rsvd0 : 2; /**< Bits 53:52 - Reserved. */ 939 uint32_t u1GstAccessUpdateDis : 1; /**< Bit 54 - GAUpdateDis: Disable hardare update of Access bit in GPT. */ 940 uint32_t u8Rsvd0 : 8; /**< Bits 63:55 - Reserved. */ 941 } n; 942 /** The 64-bit unsigned integer view. */ 943 uint64_t u64; 944 } IOMMU_CTRL_T; 945 AssertCompileSize(IOMMU_CTRL_T, 8); 946 947 /** 948 * IOMMU Exclusion Base Register (MMIO). 949 * In accordance with the AMD spec. 950 */ 951 typedef union 952 { 953 struct 954 { 955 RT_GCC_EXTENSION uint64_t u1ExclEnable : 1; /**< Bit 0 - ExEn: Exclusion Range Enable. */ 956 RT_GCC_EXTENSION uint64_t u1AllowAll : 1; /**< Bit 1 - Allow: Allow All Devices. */ 957 RT_GCC_EXTENSION uint64_t u10Rsvd0 : 10; /**< Bits 11:2 - Reserved. */ 958 RT_GCC_EXTENSION uint64_t u40ExclRangeBase : 40; /**< Bits 51:12 - Exclusion Range Base Address. */ 959 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */ 960 } n; 961 /** The 64-bit unsigned integer view. */ 962 uint64_t u64; 963 } IOMMU_EXCL_BASE_T; 964 AssertCompileSize(IOMMU_EXCL_BASE_T, 8); 965 966 /** 967 * IOMMU Exclusion Range Limit Register (MMIO). 968 * In accordance with the AMD spec. 969 */ 970 typedef union 971 { 972 struct 973 { 974 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */ 975 RT_GCC_EXTENSION uint64_t u40ExclLimit : 40; /**< Bits 51:12 - Exclusion Range Limit. */ 976 RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */ 977 } n; 978 /** The 64-bit unsigned integer view. */ 979 uint64_t u64; 980 } IOMMU_EXCL_RANGE_LIMIT_T; 981 AssertCompileSize(IOMMU_EXCL_RANGE_LIMIT_T, 8); 982 983 /** 984 * IOMMU Extended Feature Register (MMIO). 985 * In accordance with the AMD spec. 986 */ 987 typedef union 988 { 989 struct 990 { 991 uint32_t u1PrefetchSup : 1; /**< Bit 0 - PreFSup: Prefetch Support. */ 992 uint32_t u1PprSup : 1; /**< Bit 1 - PPRSup: Peripheral Page Request Support. */ 993 uint32_t u1X2ApicSup : 1; /**< Bit 2 - XTSup: x2Apic Support. */ 994 uint32_t u1NoExecuteSup : 1; /**< Bit 3 - NXSup: No-Execute and Privilege Level Support. */ 995 uint32_t u1GstTranslateSup : 1; /**< Bit 4 - GTSup: Guest Translations Support. */ 996 uint32_t u1Rsvd0 : 1; /**< Bit 5 - Reserved. */ 997 uint32_t u1InvAllSup : 1; /**< Bit 6 - IASup: Invalidate-All Support. */ 998 uint32_t u1GstVirtApicSup : 1; /**< Bit 7 - GASup: Guest Virtual-APIC Support. */ 999 uint32_t u1HwErrorSup : 1; /**< Bit 8 - HESup: Hardware Error registers Support. */ 1000 uint32_t u1PerfCounterSup : 1; /**< Bit 8 - PCSup: Performance Counter Support. */ 1001 uint32_t u2HostAddrTranslateSize : 2; /**< Bits 11:10 - HATS: Host Address Translation Size. */ 1002 uint32_t u2GstAddrTranslateSize : 2; /**< Bits 13:12 - GATS: Guest Address Translation Size. */ 1003 uint32_t u2GstCr3RootTblLevel : 2; /**< Bits 15:14 - GLXSup: Guest CR3 Root Table Level (Max) Size Support. */ 1004 uint32_t u2SmiFilterSup : 2; /**< Bits 17:16 - SmiFSup: SMI Filter Register Support. */ 1005 uint32_t u3SmiFilterCount : 3; /**< Bits 20:18 - SmiFRC: SMI Filter Register Count. */ 1006 uint32_t u3GstVirtApicModeSup : 3; /**< Bits 23:21 - GAMSup: Guest Virtual-APIC Modes Supported. */ 1007 uint32_t u2DualPprLogSup : 2; /**< Bits 25:24 - DualPprLogSup: Dual Peripheral Page Request Log Support. */ 1008 uint32_t u2Rsvd0 : 2; /**< Bits 27:26 - Reserved. */ 1009 uint32_t u2DualEvtLogSup : 2; /**< Bits 29:28 - DualEventLogSup: Dual Event Log Support. */ 1010 uint32_t u2Rsvd1 : 2; /**< Bits 31:30 - Reserved. */ 1011 1012 uint32_t u5MaxPasidSup : 5; /**< Bits 36:32 - PASMax: Maximum PASID Supported. */ 1013 uint32_t u1UserSupervisorSup : 1; /**< Bit 37 - USSup: User/Supervisor Page Protection Support. */ 1014 uint32_t u2DevTabSegSup : 2; /**< Bits 39:38 - DevTlbSegSup: Segmented Device Table Support. */ 1015 uint32_t u1PprLogOverflowWarn : 1; /**< Bit 40 - PprOvrflwEarlySup: PPR Log Overflow Early Warning Support. */ 1016 uint32_t u1PprAutoRespSup : 1; /**< Bit 41 - PprAutoRspSup: PPR Automatic Response Support. */ 1017 uint32_t u2MarcSup : 2; /**< Bit 43:42 - MarcSup: Memory Access Routing and Control Support. */ 1018 uint32_t u1BlockStopMarkSup : 1; /**< Bit 44 - BlkStopMarkSup: Block StopMark messages Support. */ 1019 uint32_t u1PerfOptSup : 1; /**< Bit 45 - PerfOptSup: IOMMU Performance Optimization Support. */ 1020 uint32_t u1MsiCapMmioSup : 1; /**< Bit 46 - MsiCapMmioSup: MSI Capability Register MMIO Access Support. */ 1021 uint32_t u1Rsvd1 : 1; /**< Bit 47 - Reserved. */ 1022 uint32_t u1GstIoSup : 1; /**< Bit 48 - GIoSup: Guest I/O Protection Support. */ 1023 uint32_t u1HostAccessSup : 1; /**< Bit 49 - HASup: Host Access Support. */ 1024 uint32_t u1EnhancedPprSup : 1; /**< Bit 50 - EPHSup: Enhanced Peripheral Page Request Handling Support. */ 1025 uint32_t u1AttrForwardSup : 1; /**< Bit 51 - AttrFWSup: Attribute Forward Support. */ 1026 uint32_t u1HostDirtySup : 1; /**< Bit 52 - HDSup: Host Dirty Support. */ 1027 uint32_t u1Rsvd2 : 1; /**< Bit 53 - Reserved. */ 1028 uint32_t u1InvIoTlbTypeSup : 1; /**< Bit 54 - InvIotlbTypeSup: Invalidate IOTLB Type Support. */ 1029 uint32_t u6Rsvd0 : 6; /**< Bit 60:55 - Reserved. */ 1030 uint32_t u1GstUpdateDisSup : 1; /**< Bit 61 - GAUpdateDisSup: Disable hardware update on GPT Support. */ 1031 uint32_t u1ForcePhysDstSup : 1; /**< Bit 62 - ForcePhyDestSup: Force Phys. Dst. Mode for Remapped Intr. */ 1032 uint32_t u1Rsvd3 : 1; /**< Bit 63 - Reserved. */ 1033 } n; 1034 /** The 64-bit unsigned integer view. */ 1035 uint64_t u64; 1036 } IOMMU_EFR_T; 1037 AssertCompileSize(IOMMU_EFR_T, 8); 1038 1039 /** 1040 * Peripheral Page Request Log Base Address Register (MMIO). 1041 * In accordance with the AMD spec. 1042 */ 1043 typedef union 1044 { 1045 struct 1046 { 1047 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */ 1048 RT_GCC_EXTENSION uint64_t u40PprLogBase : 40; /**< Bits 51:12 - PPRLogBase: Peripheral Page Request Log Base Address. */ 1049 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */ 1050 RT_GCC_EXTENSION uint64_t u4PprLogLen : 4; /**< Bits 59:56 - PPRLogLen: Peripheral Page Request Log Length. */ 1051 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */ 1052 } n; 1053 /** The 64-bit unsigned integer view. */ 1054 uint64_t u64; 1055 } PPR_LOG_BAR_T; 1056 AssertCompileSize(PPR_LOG_BAR_T, 8); 1057 1058 /** 1059 * IOMMU Hardware Event Upper Register (MMIO). 1060 * In accordance with the AMD spec. 1061 */ 1062 typedef union 1063 { 1064 struct 1065 { 1066 RT_GCC_EXTENSION uint64_t u60FirstOperand : 60; /**< Bits 59:0 - First event code dependent operand. */ 1067 RT_GCC_EXTENSION uint64_t u4EvtCode : 4; /**< Bits 63:60 - Event Code. */ 1068 } n; 1069 /** The 64-bit unsigned integer view. */ 1070 uint64_t u64; 1071 } IOMMU_HW_EVT_HI_T; 1072 AssertCompileSize(PPR_LOG_BAR_T, 8); 1073 1074 /** 1075 * IOMMU Hardware Event Lower Register (MMIO). 1076 * In accordance with the AMD spec. 1077 */ 1078 typedef uint64_t IOMMU_HW_EVT_LO_T; 1079 1080 /** 1081 * IOMMU Hardware Event Status (MMIO). 1082 * In accordance with the AMD spec. 1083 */ 1084 typedef union 1085 { 1086 struct 1087 { 1088 uint32_t u1HwEventValid : 1; /**< Bit 0 - HEV: Hardware Event Valid. */ 1089 uint32_t u1HwEventOverflow : 1; /**< Bit 1 - HEO: Hardware Event Overflow. */ 1090 uint32_t u30Rsvd0 : 30; /**< Bits 31:2 - Reserved. */ 1091 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */ 1092 } n; 1093 /** The 64-bit unsigned integer view. */ 1094 uint64_t u64; 1095 } IOMMU_HW_EVT_STATUS_T; 1096 AssertCompileSize(IOMMU_HW_EVT_STATUS_T, 8); 1097 1098 /** 1099 * Device Table Segment Register (MMIO). 1100 * In accordance with the AMD spec. 1101 */ 1102 typedef union 1103 { 1104 struct 1105 { 1106 RT_GCC_EXTENSION uint64_t u8Size : 8; /**< Bits 7:0 - Size: Size of the Device Table segment. */ 1107 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 11:8 - Reserved. */ 1108 RT_GCC_EXTENSION uint64_t u40DevTabBase : 40; /**< Bits 51:12 - DevTabBase: Device Table Segment Base Address. */ 1109 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */ 1110 } n; 1111 /** The 64-bit unsigned integer view. */ 1112 uint64_t u64; 1113 } DEV_TAB_SEG_BAR_T; 1114 AssertCompileSize(DEV_TAB_SEG_BAR_T, 8); 1115 1116 /** 1117 * Device-specific Feature Extension (DSFX) Register (MMIO). 1118 * In accordance with the AMD spec. 1119 */ 1120 typedef union 1121 { 1122 struct 1123 { 1124 uint32_t u24DevSpecFeatSup : 24; /**< Bits 23:0 - DevSpecificFeatSupp: Implementation specific features. */ 1125 uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */ 1126 uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */ 1127 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/ 1128 } n; 1129 /** The 64-bit unsigned integer view. */ 1130 uint64_t u64; 1131 } DEV_SPECIFIC_FEAT_T; 1132 AssertCompileSize(DEV_SPECIFIC_FEAT_T, 8); 1133 1134 /** 1135 * Device-specific Control Extension (DSCX) Register (MMIO). 1136 * In accordance with the AMD spec. 1137 */ 1138 typedef union 1139 { 1140 struct 1141 { 1142 uint32_t u24DevSpecFeatSup : 24; /**< Bits 23:0 - DevSpecificFeatCntrl: Implementation specific control. */ 1143 uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */ 1144 uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */ 1145 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/ 1146 } n; 1147 /** The 64-bit unsigned integer view. */ 1148 uint64_t u64; 1149 } DEV_SPECIFIC_CTRL_T; 1150 AssertCompileSize(DEV_SPECIFIC_CTRL_T, 8); 1151 1152 /** 1153 * Device-specific Status Extension (DSSX) Register (MMIO). 1154 * In accordance with the AMD spec. 1155 */ 1156 typedef union 1157 { 1158 struct 1159 { 1160 uint32_t u24DevSpecStatus : 24; /**< Bits 23:0 - DevSpecificFeatStatus: Implementation specific status. */ 1161 uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */ 1162 uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */ 1163 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/ 1164 } n; 1165 /** The 64-bit unsigned integer view. */ 1166 uint64_t u64; 1167 } DEV_SPECIFIC_STATUS_T; 1168 AssertCompileSize(DEV_SPECIFIC_STATUS_T, 8); 1169 1170 /** 1171 * MSI Information Register 0 and 1 (PCI) / MSI Vector Register 0 and 1 (MMIO). 1172 * In accordance with the AMD spec. 1173 */ 1174 typedef union 1175 { 1176 struct 1177 { 1178 uint32_t u5MsiNum : 5; /**< Bits 4:0 - MsiNum: MSI Vector used for interrupt messages generated by the IOMMU. */ 1179 uint32_t u3GstVirtAddrSize: 3; /**< Bits 7:5 - GVAsize: Guest Virtual Address Size. */ 1180 uint32_t u7PhysAddrSize : 7; /**< Bits 14:8 - PAsize: Physical Address Size. */ 1181 uint32_t u7VirtAddrSize : 7; /**< Bits 21:15 - VAsize: Virtual Address Size. */ 1182 uint32_t u1HtAtsResv: 1; /**< Bit 22 - HtAtsResv: HyperTransport ATS Response Address range Reserved. */ 1183 uint32_t u4Rsvd0 : 4; /**< Bits 26:23 - Reserved. */ 1184 uint32_t u5MsiNumPpr : 5; /**< Bits 31:27 - MsiNumPPR: Peripheral Page Request MSI message number. */ 1185 uint32_t u5MsiNumGa : 5; /**< Bits 36:32 - MsiNumGa: MSI message number for guest virtual-APIC log. */ 1186 uint32_t u27Rsvd0: 27; /**< Bits 63:37 - Reserved. */ 1187 } n; 1188 /** The 32-bit unsigned integer view. */ 1189 uint32_t au32[2]; 1190 /** The 64-bit unsigned integer view. */ 1191 uint64_t u64; 1192 } MSI_MISC_INFO_T; 1193 AssertCompileSize(MSI_MISC_INFO_T, 8); 1194 /** MSI Vector Register 0 and 1 (MMIO). */ 1195 typedef MSI_MISC_INFO_T MSI_VECTOR_T; 1196 1197 /** 1198 * MSI Capability Header Register (PCI + MMIO). 1199 * In accordance with the AMD spec. 1200 */ 1201 typedef union 1202 { 1203 struct 1204 { 1205 uint32_t u8MsiCapId : 8; /**< Bits 7:0 - MsiCapId: Capability ID. */ 1206 uint32_t u8MsiCapPtr : 8; /**< Bits 15:8 - MsiCapPtr: Pointer (PCI config offset) to the next capability. */ 1207 uint32_t u1MsiEnable : 1; /**< Bit 16 - MsiEn: Message Signal Interrupt Enable. */ 1208 uint32_t u3MsiMultiMessCap : 3; /**< Bits 19:17 - MsiMultMessCap: MSI Multi-Message Capability. */ 1209 uint32_t u3MsiMultiMessEn : 3; /**< Bits 22:20 - MsiMultMessEn: MSI Multi-Message Enable. */ 1210 uint32_t u1Msi64BitEn : 1; /**< Bit 23 - Msi64BitEn: MSI 64-bit Enable. */ 1211 uint32_t u8Rsvd0 : 8; /**< Bits 31:24 - Reserved. */ 1212 } n; 1213 /** The 32-bit unsigned integer view. */ 1214 uint32_t u32; 1215 } MSI_CAP_HDR_T; 1216 AssertCompileSize(MSI_CAP_HDR_T, 4); 1217 1218 /** 1219 * MSI Address Register (PCI + MMIO). 1220 * In accordance with the AMD spec. 1221 */ 1222 typedef union 1223 { 1224 struct 1225 { 1226 uint32_t u2Rsvd : 2; /**< Bits 1:0 - Reserved. */ 1227 uint32_t u30MsiAddrLo : 30; /**< Bits 31:2 - MsiAddr: MSI Address (Lo). */ 1228 uint32_t u32MsiAddrHi; /**< Bits 63:32 - MsiAddr: MSI Address (Hi). */ 1229 } n; 1230 /** The 32-bit unsigned integer view. */ 1231 uint32_t au32[2]; 1232 /** The 64-bit unsigned integer view. */ 1233 uint64_t u64; 1234 } MSI_ADDR_T; 1235 AssertCompileSize(MSI_ADDR_T, 8); 1236 1237 /** 1238 * MSI Data Register (PCI + MMIO). 1239 * In accordance with the AMD spec. 1240 */ 1241 typedef union 1242 { 1243 struct 1244 { 1245 uint16_t u16MsiData; /**< Bits 15:0 - MsiData: MSI Data. */ 1246 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */ 1247 } n; 1248 /** The 32-bit unsigned integer view. */ 1249 uint32_t u32; 1250 } MSI_DATA_T; 1251 AssertCompileSize(MSI_DATA_T, 4); 1252 1253 /** 1254 * MSI Mapping Capability Header Register (PCI + MMIO). 1255 * In accordance with the AMD spec. 1256 */ 1257 typedef union 1258 { 1259 struct 1260 { 1261 uint32_t u8MsiMapCapId : 8; /**< Bits 7:0 - MsiMapCapId: MSI Map capability ID. */ 1262 uint32_t u8Rsvd0 : 8; /**< Bits 15:8 - Reserved. */ 1263 uint32_t u1MsiMapEn : 1; /**< Bit 16 - MsiMapEn: MSI Map enable. */ 1264 uint32_t u1MsiMapFixed : 1; /**< Bit 17 - MsiMapFixd: MSI Map fixed. */ 1265 uint32_t u9Rsvd0 : 9; /**< Bits 26:18 - Reserved. */ 1266 uint32_t u5MapCapType : 5; /**< Bits 31:27 - MsiMapCapType: MSI Mapping capability type. */ 1267 } n; 1268 } MSI_MAP_CAP_HDR_T; 1269 AssertCompileSize(MSI_MAP_CAP_HDR_T, 4); 1270 1271 1272 /** 1273 * The shared IOMMU device state. 838 1274 */ 839 1275 typedef struct IOMMU 840 1276 { 841 bool fRootComplex; 1277 /** Whether this IOMMU is at the top of the PCI tree hierarchy or not. */ 1278 bool fRootComplex; 1279 /** Alignment padding. */ 1280 bool afPadding[3]; 1281 1282 /** @name MMIO: Control and status registers. 1283 * @{ */ 1284 DEV_TAB_BAR_T DevTabBaseAddr; /**< Device table base address register. */ 1285 CMD_BUF_BAR_T CmdBufBaseAddr; /**< Command buffer base address register. */ 1286 EVT_LOG_BUF_BAR_T EvtLogBaseAddr; /**< Event log base address register. */ 1287 IOMMU_CTRL_T IommuCtrl; /**< IOMMU control register. */ 1288 IOMMU_EXCL_BASE_T ExclBase; /**< IOMMU exclusion base register. */ 1289 IOMMU_EXCL_RANGE_LIMIT_T ExclRangeLimit; /**< IOMMU exclusion range limit. */ 1290 IOMMU_EFR_T ExtFeat; /**< IOMMU extended feature register. */ 1291 /** @} */ 1292 1293 /** @name MMIO: PPR Log registers. 1294 * @{ */ 1295 PPR_LOG_BAR_T PprLogBaseAddr; /**< PPR Log base address register. */ 1296 IOMMU_HW_EVT_HI_T IommuHwEvtHi; /**< IOMMU hardware event register (Hi). */ 1297 IOMMU_HW_EVT_LO_T IommuHwEvtLo; /**< IOMMU hardware event register (Lo). */ 1298 IOMMU_HW_EVT_STATUS_T IommuHwEvtStatus; /**< IOMMU hardware event status. */ 1299 /** @} */ 1300 1301 /** @name MMIO: Device table segment registers. 1302 * @{ */ 1303 DEV_TAB_SEG_BAR_T DevTabSeg[7]; /**< Device Table Segment base address register. */ 1304 /** @} */ 1305 1306 /** @name MMIO: Device-specific feature registers. 1307 * @{ */ 1308 DEV_SPECIFIC_FEAT_T DevSpecificFeat; /**< Device-specific feature extension register (DSFX). */ 1309 DEV_SPECIFIC_CTRL_T DevSpecificCtrl; /**< Device-specific control extension register (DSCX). */ 1310 DEV_SPECIFIC_STATUS_T DevSpecificStatus; /**< Device-specific status extension register (DSSX). */ 1311 /** @} */ 1312 1313 /** @name MMIO: MSI Capability Block registers. 1314 * @{ */ 1315 MSI_MISC_INFO_T MsiMiscInfo0; /**< MSI Misc. info registers / MSI Vector registers. */ 1316 MSI_CAP_HDR_T MsiCapHdr; /**< MSI Capability header register. */ 1317 MSI_ADDR_T MsiAddr; /**< MSI Address register.*/ 1318 MSI_DATA_T MsiData; /**< MSI Data register. */ 1319 MSI_MAP_CAP_HDR_T MsiMapCapHdr; /**< MSI Mapping Capability Header register. */ 1320 /** @} */ 842 1321 } IOMMU; 843 1322 /** Pointer to the IOMMU device state. */ … … 943 1422 uint8_t const offMiscInfo1 = offCapHdr + 0x14; 944 1423 uint8_t const offMsiCapHdr = offCapHdr + 0x24; 1424 uint8_t const offMsiAddrLo = offCapHdr + 0x28; 1425 uint8_t const offMsiAddrHi = offCapHdr + 0x2c; 1426 uint8_t const offMsiData = offCapHdr + 0x30; 945 1427 uint8_t const offMsiMapCapHdr = offCapHdr + 0x34; 946 1428 … … 980 1462 981 1463 /* Base Address High Register. */ 982 PDMPciDevSetDWord(pPciDev, offBaseAddrHi, 0); /* RW - Base address high */1464 PDMPciDevSetDWord(pPciDev, offBaseAddrHi, 0); /* RW - Base address high */ 983 1465 984 1466 /* IOMMU Range Register. */ … … 1011 1493 | RT_BF_MAKE(IOMMU_BF_MSI_CAPHDR_64BIT_EN, 0x1)); /* RO - MSI 64-bit enable */ 1012 1494 1013 /* MSI Mapping Capability header register. */ 1495 /* MSI Address Lo. */ 1496 PDMPciDevSetDWord(pPciDev, offMsiAddrLo, 0); /* RW - MSI message address (Lo). */ 1497 1498 /* MSI Address Hi. */ 1499 PDMPciDevSetDWord(pPciDev, offMsiAddrHi, 0); /* RW - MSI message address (Hi). */ 1500 1501 /* MSI Data. */ 1502 PDMPciDevSetDWord(pPciDev, offMsiData, 0); /* RW - MSI data. */ 1503 1504 /* MSI Mapping Capability Header register. */ 1014 1505 PDMPciDevSetDWord(pPciDev, offMsiMapCapHdr, 1015 1506 RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID, 0x8) /* RO - Capability ID */
Note:
See TracChangeset
for help on using the changeset viewer.