Changeset 60468 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Apr 13, 2016 11:12:36 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/APIC.cpp
r60464 r60468 912 912 pXApicPage->timer_ccr.u32CurrentCount = uInitialCount; 913 913 if (uInitialCount) 914 { 915 Log4(("APIC%u: apicR3TimerCallback: Re-arming timer. uInitialCount=%#RX32\n", pVCpu->idCpu, uInitialCount)); 914 916 APICStartTimer(pApicCpu, uInitialCount); 917 } 915 918 break; 916 919 } … … 1002 1005 LogFlow(("APIC: apicR3TermState: pVM=%p\n", pVM)); 1003 1006 1004 if (pApic->pvApicPibR3) 1007 /* Unmap and free the PIB. */ 1008 if (pApic->pvApicPibR3 != NIL_RTR3PTR) 1005 1009 { 1006 1010 size_t const cPages = pApic->cbApicPib >> PAGE_SHIFT; … … 1009 1013 else 1010 1014 SUPR3ContFree((void *)pApic->pvApicPibR3, cPages); 1011 pApic->pvApicPibR3 = NULL; 1012 } 1013 1015 pApic->pvApicPibR3 = NIL_RTR3PTR; 1016 pApic->pvApicPibR0 = NIL_RTR0PTR; 1017 pApic->pvApicPibRC = NIL_RTRCPTR; 1018 } 1019 1020 /* Unmap and free the virtual-APIC pages. */ 1014 1021 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++) 1015 1022 { 1016 PVMCPU pVCpu = &pVM->aCpus[idCpu]; 1017 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 1018 if (pApicCpu->pvApicPageR3) 1023 PVMCPU pVCpu = &pVM->aCpus[idCpu]; 1024 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 1025 1026 pApicCpu->pvApicPibR3 = NIL_RTR3PTR; 1027 pApicCpu->pvApicPibR0 = NIL_RTR0PTR; 1028 pApicCpu->pvApicPibRC = NIL_RTRCPTR; 1029 1030 if (pApicCpu->pvApicPageR3 != NIL_RTR3PTR) 1019 1031 { 1020 1032 SUPR3PageFreeEx((void *)pApicCpu->pvApicPageR3, 1 /* cPages */); 1021 pApicCpu->pvApicPageR3 = NULL; 1022 pApicCpu->pvApicPibR3 = NULL; 1033 pApicCpu->pvApicPageR3 = NIL_RTR3PTR; 1034 pApicCpu->pvApicPageR0 = NIL_RTR0PTR; 1035 pApicCpu->pvApicPageRC = NIL_RTRCPTR; 1023 1036 } 1024 1037 } … … 1035 1048 { 1036 1049 PAPIC pApic = VM_TO_APIC(pVM); 1037 bool const fNeedGCMapping = !HMIsEnabled(pVM);1038 1050 LogFlow(("APIC: apicR3InitState: pVM=%p\n", pVM)); 1051 1052 /* With hardware virtualization, we don't need to map the APIC in GC. */ 1053 bool const fNeedsGCMapping = !HMIsEnabled(pVM); 1039 1054 1040 1055 /* … … 1044 1059 * physically contiguous allocations are rounded to a multiple of page size. 1045 1060 */ 1061 Assert(pApic->pvApicPibR3 == NIL_RTR3PTR); 1062 Assert(pApic->pvApicPibR0 == NIL_RTR0PTR); 1063 Assert(pApic->pvApicPibRC == NIL_RTRCPTR); 1046 1064 pApic->cbApicPib = RT_ALIGN_Z(pVM->cCpus * sizeof(APICPIB), PAGE_SIZE); 1047 1065 size_t const cPages = pApic->cbApicPib >> PAGE_SHIFT; 1048 Assert(!pApic->pvApicPibR3);1049 1066 if (cPages == 1) 1050 1067 { … … 1052 1069 RT_ZERO(SupApicPib); 1053 1070 SupApicPib.Phys = NIL_RTHCPHYS; 1054 int rc = SUPR3PageAllocEx( cPages, 0 /* fFlags */, (void **)&pApic->pvApicPibR3, &pApic->pvApicPibR0, &SupApicPib);1071 int rc = SUPR3PageAllocEx(1 /* cPages */, 0 /* fFlags */, (void **)&pApic->pvApicPibR3, &pApic->pvApicPibR0, &SupApicPib); 1055 1072 if (RT_SUCCESS(rc)) 1056 1073 { 1057 1074 pApic->HCPhysApicPib = SupApicPib.Phys; 1058 AssertReturn(pApic->pvApicPibR3, VERR_INVALID_POINTER); 1059 memset((void *)pApic->pvApicPibR3, 0, pApic->cbApicPib); 1075 AssertLogRelReturn(pApic->pvApicPibR3, VERR_INTERNAL_ERROR); 1060 1076 } 1061 1077 else … … 1070 1086 if (pApic->pvApicPibR3) 1071 1087 { 1072 Assert(pApic->pvApicPibR0 != NIL_RTR0PTR); 1073 Assert(pApic->HCPhysApicPib != NIL_RTHCPHYS); 1074 1075 /* Map the pending-interrupt bitmap (PIB) into GC. */ 1076 if (fNeedGCMapping) 1088 AssertLogRelReturn(pApic->pvApicPibR0 != NIL_RTR0PTR, VERR_INTERNAL_ERROR); 1089 AssertLogRelReturn(pApic->HCPhysApicPib != NIL_RTHCPHYS, VERR_INTERNAL_ERROR); 1090 1091 /* Initialize the PIB. */ 1092 memset((void *)pApic->pvApicPibR3, 0, pApic->cbApicPib); 1093 1094 /* Map the PIB into GC. */ 1095 if (fNeedsGCMapping) 1077 1096 { 1097 pApic->pvApicPibRC == NIL_RTRCPTR; 1078 1098 int rc = MMR3HyperMapHCPhys(pVM, (void *)pApic->pvApicPibR3, NIL_RTR0PTR, pApic->HCPhysApicPib, pApic->cbApicPib, 1079 1099 "APIC PIB", (PRTGCPTR)&pApic->pvApicPibRC); 1080 1100 if (RT_FAILURE(rc)) 1081 1101 { 1082 LogRel(("APIC: Failed to map %u bytes for the pending-interrupt bitmap to GC, rc=%Rrc\n", pApic->cbApicPib, rc)); 1102 LogRel(("APIC: Failed to map %u bytes for the pending-interrupt bitmap into GC, rc=%Rrc\n", pApic->cbApicPib, 1103 rc)); 1083 1104 apicR3TermState(pVM); 1084 1105 return rc; 1085 1106 } 1107 1108 AssertLogRelReturn(pApic->pvApicPibRC != NIL_RTRCPTR, VERR_INTERNAL_ERROR); 1086 1109 } 1087 1110 1111 /* 1112 * Allocate the map the virtual-APIC pages. 1113 */ 1088 1114 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++) 1089 1115 { … … 1091 1117 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 1092 1118 1093 /* Allocate and map the virtual-APIC page. */1094 1119 SUPPAGE SupApicPage; 1095 1120 RT_ZERO(SupApicPage); 1096 1121 SupApicPage.Phys = NIL_RTHCPHYS; 1097 1122 1123 Assert(pApicCpu->pvApicPageR3 == NIL_RTR0PTR); 1124 Assert(pApicCpu->pvApicPageR0 == NIL_RTR0PTR); 1125 Assert(pApicCpu->pvApicPageRC == NIL_RTRCPTR); 1126 AssertCompile(sizeof(XAPICPAGE) == PAGE_SIZE); 1098 1127 pApicCpu->cbApicPage = sizeof(XAPICPAGE); 1099 AssertCompile(sizeof(XAPICPAGE) == PAGE_SIZE);1100 1101 Assert(!pApicCpu->pvApicPageR3);1102 1128 int rc = SUPR3PageAllocEx(1 /* cPages */, 0 /* fFlags */, (void **)&pApicCpu->pvApicPageR3, &pApicCpu->pvApicPageR0, 1103 1129 &SupApicPage); 1104 1130 if (RT_SUCCESS(rc)) 1105 1131 { 1132 AssertLogRelReturn(pApicCpu->pvApicPageR3 != NIL_RTR3PTR, VERR_INTERNAL_ERROR); 1133 AssertLogRelReturn(pApicCpu->HCPhysApicPage != NIL_RTHCPHYS, VERR_INTERNAL_ERROR); 1106 1134 pApicCpu->HCPhysApicPage = SupApicPage.Phys; 1107 Assert(pApicCpu->HCPhysApicPage != NIL_RTHCPHYS);1108 Assert(pApicCpu->pvApicPageR3);1109 1135 1110 1136 /* Map the virtual-APIC page into GC. */ 1111 if (fNeed GCMapping)1137 if (fNeedsGCMapping) 1112 1138 { 1113 1139 rc = MMR3HyperMapHCPhys(pVM, (void *)pApicCpu->pvApicPageR3, NIL_RTR0PTR, pApicCpu->HCPhysApicPage, … … 1115 1141 if (RT_FAILURE(rc)) 1116 1142 { 1117 LogRel(("APIC%u: Failed to map %u bytes for the virtual-APIC page to GC, rc=%Rrc", idCpu,1143 LogRel(("APIC%u: Failed to map %u bytes for the virtual-APIC page into GC, rc=%Rrc", idCpu, 1118 1144 pApicCpu->cbApicPage, rc)); 1119 1145 apicR3TermState(pVM); 1120 1146 return rc; 1121 1147 } 1148 1149 AssertLogRelReturn(pApicCpu->pvApicPageRC != NIL_RTRCPTR, VERR_INTERNAL_ERROR); 1122 1150 } 1123 1151 … … 1126 1154 pApicCpu->pvApicPibR0 = (RTR0PTR)((RTR0UINTPTR)pApic->pvApicPibR0 + offApicPib); 1127 1155 pApicCpu->pvApicPibR3 = (RTR3PTR)((RTR3UINTPTR)pApic->pvApicPibR3 + offApicPib); 1128 if (fNeed GCMapping)1156 if (fNeedsGCMapping) 1129 1157 pApicCpu->pvApicPibRC += offApicPib; 1130 1158 … … 1133 1161 APICR3Reset(pVCpu); 1134 1162 1135 #ifdef VBOX_STRICT1136 Assert(pApicCpu->pvApicP ageR3);1137 Assert(pApicCpu->pvApicP ageR0);1138 Assert(!fNeed GCMapping || pApicCpu->pvApicPageRC);1139 Assert(pApicCpu->pvApicP ibR3);1140 Assert(pApicCpu->pvApicP ibR0);1141 Assert(!fNeed GCMapping || pApicCpu->pvApicPibRC);1163 #ifdef DEBUG_ramshankar 1164 Assert(pApicCpu->pvApicPibR3 != NIL_RTR3PTR); 1165 Assert(pApicCpu->pvApicPibR0 != NIL_RTR0PTR); 1166 Assert(!fNeedsGCMapping || pApicCpu->pvApicPibRC != NIL_RTRCPTR); 1167 Assert(pApicCpu->pvApicPageR3 != NIL_RTR3PTR); 1168 Assert(pApicCpu->pvApicPageR0 != NIL_RTR0PTR); 1169 Assert(!fNeedsGCMapping || pApicCpu->pvApicPageRC != NIL_RTRCPTR); 1142 1170 #endif 1143 1171 } 1144 1172 else 1145 1173 { 1146 LogRel(("APIC%u: Failed to allocate %u bytes for the virtual-APIC page \n", pApicCpu->cbApicPage));1174 LogRel(("APIC%u: Failed to allocate %u bytes for the virtual-APIC page, rc=%Rrc\n", pApicCpu->cbApicPage, rc)); 1147 1175 apicR3TermState(pVM); 1148 return VERR_NO_MEMORY;1176 return rc; 1149 1177 } 1150 1178 } 1151 1179 1152 #ifdef VBOX_STRICT1153 Assert(pApic->pvApicPibR 0);1154 Assert(pApic->pvApicPibR 3);1155 Assert(!fNeed GCMapping || pApic->pvApicPibRC);1180 #ifdef DEBUG_ramshankar 1181 Assert(pApic->pvApicPibR3 != NIL_RTR3PTR); 1182 Assert(pApic->pvApicPibR0 != NIL_RTR0PTR); 1183 Assert(!fNeedsGCMapping || pApic->pvApicPibRC != NIL_RTRCPTR); 1156 1184 #endif 1157 1185 return VINF_SUCCESS; 1158 1186 } 1159 1187 1160 LogRel(("APIC: Failed to allocate %u bytes of contiguous low-memory for the pending-interrupt bitmap\n", pApic->cbApicPib)); 1188 LogRel(("APIC: Failed to allocate %u bytes of physically contiguous memory for the pending-interrupt bitmap\n", 1189 pApic->cbApicPib)); 1161 1190 return VERR_NO_MEMORY; 1162 1191 } … … 1169 1198 { 1170 1199 PVM pVM = PDMDevHlpGetVM(pDevIns); 1200 LogFlow(("APIC: apicR3Destruct: pVM=%p\n", pVM)); 1201 1171 1202 apicR3TermState(pVM); 1172 1203 return VINF_SUCCESS; … … 1182 1213 PAPIC pApic = VM_TO_APIC(pVM); 1183 1214 1215 /* 1216 * Init APIC settings that rely on HM and CPUM configurations. 1217 */ 1184 1218 CPUMCPUIDLEAF CpuLeaf; 1185 1219 int rc = CPUMR3CpuIdGetLeaf(pVM, &CpuLeaf, 1, 0); 1186 1220 AssertRCReturn(rc, rc); 1221 1187 1222 pApic->fSupportsTscDeadline = RT_BOOL(CpuLeaf.uEcx & X86_CPUID_FEATURE_ECX_TSCDEADL); 1188 1189 1223 pApic->fPostedIntrsEnabled = HMR3IsPostedIntrsEnabled(pVM->pUVM); 1190 1224 pApic->fVirtApicRegsEnabled = HMR3IsVirtApicRegsEnabled(pVM->pUVM); … … 1199 1233 /** @todo Figure out why doing this from apicR3Construct() it doesn't work. See @bugref{8245#c48} */ 1200 1234 #define APIC_REG_COUNTER(a_Reg, a_Desc, a_Key) \ 1201 rc = STAMR3RegisterF(pVM, a_Reg, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, a_Desc, a_Key, idCpu) 1235 do { \ 1236 rc = STAMR3RegisterF(pVM, a_Reg, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, a_Desc, a_Key, idCpu); \ 1237 AssertRCReturn(rc, rc); \ 1238 } while(0) 1202 1239 1203 1240 bool const fHasRC = !HMIsEnabled(pVM);
Note:
See TracChangeset
for help on using the changeset viewer.