Changeset 60646 in vbox
- Timestamp:
- Apr 22, 2016 12:59:40 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106813
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/apic.h
r60601 r60646 926 926 */ 927 927 VMMR3_INT_DECL(void) APICR3InitIpi(PVMCPU pVCpu); 928 VMMR3_INT_DECL(void) APICR3Reset(PVMCPU pVCpu );928 VMMR3_INT_DECL(void) APICR3Reset(PVMCPU pVCpu, bool fResetApicBaseMsr); 929 929 /** @} */ 930 930 #endif /* IN_RING3 */ -
trunk/src/VBox/VMM/VMMAll/APICAll.cpp
r60632 r60646 373 373 * @param uApicBaseMsr The APIC Base MSR value. 374 374 */ 375 staticAPICMODE apicGetMode(uint64_t uApicBaseMsr)375 APICMODE apicGetMode(uint64_t uApicBaseMsr) 376 376 { 377 377 uint32_t const uMode = MSR_APICBASE_GET_MODE(uApicBaseMsr); … … 1970 1970 { 1971 1971 Assert(pVCpu); 1972 NOREF(pDevIns); 1973 1974 #ifdef IN_RING3 1972 1975 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 1973 1976 PAPIC pApic = VM_TO_APIC(pVCpu->CTX_SUFF(pVM)); … … 1976 1979 uint64_t uBaseMsr = pApicCpu->uApicBaseMsr; 1977 1980 1978 /** @todo probably go back to ring-3 for all cases regardless of 1979 * fRZEnabled. Writing this MSR is not something guests 1980 * typically do often, and therefore is not performance 1981 * critical. We'll have better diagnostics in ring-3. */ 1982 if (!pApic->fRZEnabled) 1983 return VINF_CPUM_R3_MSR_WRITE; 1981 Log4(("APIC%u: ApicSetBaseMsr: u64BaseMsr=%#RX64 enmNewMode=%s enmOldMode=%s\n", pVCpu->idCpu, u64BaseMsr, 1982 apicGetModeName(enmNewMode), apicGetModeName(enmOldMode))); 1984 1983 1985 1984 /* … … 1993 1992 if (MSR_APICBASE_GET_PHYSADDR(uBaseMsr) != XAPIC_APICBASE_PHYSADDR) 1994 1993 { 1995 #ifdef IN_RING31996 1994 LogRelMax(5, ("APIC%u: Attempt to relocate base to %#RGp, unsupported -> #GP(0)\n", pVCpu->idCpu, 1997 1995 MSR_APICBASE_GET_PHYSADDR(uBaseMsr))); 1998 1996 return VERR_CPUM_RAISE_GP_0; 1999 #else2000 return VINF_CPUM_R3_MSR_WRITE;2001 #endif2002 1997 } 2003 1998 … … 2014 2009 case APICMODE_DISABLED: 2015 2010 { 2016 #ifdef IN_RING32017 2011 /* 2018 2012 * The APIC state needs to be reset (especially the APIC ID as x2APIC APIC ID bit layout … … 2021 2015 * See Intel spec. 10.4.3 "Enabling or Disabling the Local APIC". 2022 2016 */ 2023 APICR3Reset(pVCpu );2017 APICR3Reset(pVCpu, false /* fResetApicBaseMsr */); 2024 2018 uBaseMsr &= ~(MSR_APICBASE_XAPIC_ENABLE_BIT | MSR_APICBASE_X2APIC_ENABLE_BIT); 2025 2019 Log4(("APIC%u: Switched mode to disabled\n", pVCpu->idCpu)); 2026 #else2027 return VINF_CPUM_R3_MSR_WRITE;2028 #endif2029 2020 break; 2030 2021 } … … 2044 2035 case APICMODE_X2APIC: 2045 2036 { 2046 uBaseMsr |= MSR_APICBASE_X 2APIC_ENABLE_BIT;2037 uBaseMsr |= MSR_APICBASE_XAPIC_ENABLE_BIT | MSR_APICBASE_X2APIC_ENABLE_BIT; 2047 2038 2048 2039 /* … … 2078 2069 ASMAtomicWriteU64(&pApicCpu->uApicBaseMsr, uBaseMsr); 2079 2070 return VINF_SUCCESS; 2071 #else /* !IN_RING3 */ 2072 return VINF_CPUM_R3_MSR_WRITE; 2073 #endif /* IN_RING3 */ 2080 2074 } 2081 2075 … … 2195 2189 switch (enmDeliveryMode) 2196 2190 { 2191 case XAPICDELIVERYMODE_INIT: 2192 { 2193 /** @todo won't work in R0/RC because callers don't care about rcRZ. */ 2194 AssertMsgFailed(("INIT through LINT0/LINT1 is not yet supported\n")); 2195 /* fallthru */ 2196 } 2197 2197 case XAPICDELIVERYMODE_FIXED: 2198 2198 { … … 2208 2208 case XAPICDELIVERYMODE_SMI: 2209 2209 case XAPICDELIVERYMODE_NMI: 2210 case XAPICDELIVERYMODE_INIT: /** @todo won't work in R0/RC because callers don't care about rcRZ. */2211 2210 { 2212 2211 VMCPUSET DestCpuSet; … … 2221 2220 case XAPICDELIVERYMODE_EXTINT: 2222 2221 { 2223 Log4(("APIC%u: APICLocalInterrupt: External interrupt. u8Pin=%u u8Level=%u\n", pVCpu->idCpu, u8Pin, u8Level)); 2222 Log4(("APIC%u: APICLocalInterrupt: %s ExtINT through LINT%u\n", pVCpu->idCpu, 2223 u8Level ? "Raising" : "Lowering", u8Pin)); 2224 2224 if (u8Level) 2225 2225 APICSetInterruptFF(pVCpu, PDMAPICIRQ_EXTINT); … … 2244 2244 else 2245 2245 { 2246 /* The APIC is disabled, pass it through the CPU. */ 2247 LogFlow(("APIC%u: APICLocalInterrupt: APIC hardware-disabled, passing interrupt to CPU. u8Pin=%u u8Level=%u\n", 2248 pVCpu->idCpu, u8Pin, u8Level)); 2249 if (u8Level) 2250 APICSetInterruptFF(pVCpu, PDMAPICIRQ_EXTINT); 2246 /* The APIC is hardware disabled. The CPU behaves as though there is no on-chip APIC. */ 2247 if (u8Pin == 0) 2248 { 2249 /* LINT0 behaves as an external interrupt pin. */ 2250 Log4(("APIC%u: APICLocalInterrupt: APIC hardware-disabled, %s ExtINT through LINT0\n", pVCpu->idCpu, 2251 u8Level ? "raising" : "lowering")); 2252 if (u8Level) 2253 APICSetInterruptFF(pVCpu, PDMAPICIRQ_EXTINT); 2254 else 2255 APICClearInterruptFF(pVCpu, PDMAPICIRQ_EXTINT); 2256 } 2251 2257 else 2252 APICClearInterruptFF(pVCpu, PDMAPICIRQ_EXTINT); 2258 { 2259 /* LINT1 behaves as NMI. */ 2260 Log4(("APIC%u: APICLocalInterrupt: APIC hardware-disabled, raising NMI through LINT1\n", pVCpu->idCpu)); 2261 APICSetInterruptFF(pVCpu, PDMAPICIRQ_NMI); 2262 } 2253 2263 } 2254 2264 -
trunk/src/VBox/VMM/VMMR3/APIC.cpp
r60632 r60646 253 253 * reset. 254 254 * 255 * @param pVCpu The cross context virtual CPU structure. 256 */ 257 VMMR3_INT_DECL(void) APICR3Reset(PVMCPU pVCpu) 255 * @param pVCpu The cross context virtual CPU structure. 256 * @param fResetApicBaseMsr Whether to reset the APIC base MSR. 257 */ 258 VMMR3_INT_DECL(void) APICR3Reset(PVMCPU pVCpu, bool fResetApicBaseMsr) 258 259 { 259 260 VMCPU_ASSERT_EMT_OR_NOT_RUNNING(pVCpu); … … 291 292 /** @todo It isn't clear in the spec. where exactly the default base address 292 293 * is (re)initialized, atm we do it here in Reset. */ 293 apicR3ResetBaseMsr(pVCpu); 294 if (fResetApicBaseMsr) 295 apicR3ResetBaseMsr(pVCpu); 294 296 295 297 /* … … 373 375 PCXAPICPAGE pXApicPage = VMCPU_TO_CXAPICPAGE(pVCpu); 374 376 PCX2APICPAGE pX2ApicPage = VMCPU_TO_CX2APICPAGE(pVCpu); 377 378 uint64_t const uBaseMsr = pApicCpu->uApicBaseMsr; 379 APICMODE const enmMode = apicGetMode(uBaseMsr); 375 380 bool const fX2ApicMode = XAPIC_IN_X2APIC_MODE(pVCpu); 376 381 377 pHlp->pfnPrintf(pHlp, "VCPU[%u] APIC at %#RGp\n", pVCpu->idCpu, MSR_APICBASE_GET_PHYSADDR(pApicCpu->uApicBaseMsr)); 378 pHlp->pfnPrintf(pHlp, " Mode = %s\n", fX2ApicMode ? "x2Apic" : "xApic"); 382 pHlp->pfnPrintf(pHlp, "VCPU[%u] APIC:\n", pVCpu->idCpu); 383 pHlp->pfnPrintf(pHlp, " APIC Base MSR = %#RX64 (Addr=%#RX64)\n", uBaseMsr, 384 MSR_APICBASE_GET_PHYSADDR(uBaseMsr)); 385 pHlp->pfnPrintf(pHlp, " Mode = %#x (%s)\n", enmMode, apicGetModeName(enmMode)); 379 386 if (fX2ApicMode) 380 387 { … … 386 393 pHlp->pfnPrintf(pHlp, " Version = %#x\n", pXApicPage->version.all.u32Version); 387 394 pHlp->pfnPrintf(pHlp, " APIC Version = %#x\n", pXApicPage->version.u.u8Version); 388 pHlp->pfnPrintf(pHlp, " Max LVT entr ies= %u\n", pXApicPage->version.u.u8MaxLvtEntry);395 pHlp->pfnPrintf(pHlp, " Max LVT entry index (0..N) = %u\n", pXApicPage->version.u.u8MaxLvtEntry); 389 396 pHlp->pfnPrintf(pHlp, " EOI Broadcast supression = %RTbool\n", pXApicPage->version.u.fEoiBroadcastSupression); 390 397 if (!fX2ApicMode) … … 929 936 TMTimerStop(pApicCpu->pTimerR3); 930 937 931 APICR3Reset(pVCpuDest );938 APICR3Reset(pVCpuDest, true /* fResetApicBaseMsr */); 932 939 933 940 /* Clear the interrupt pending force flag. */ … … 1070 1077 if (fNeedsGCMapping) 1071 1078 { 1072 pApic->pvApicPibRC = =NIL_RTRCPTR;1079 pApic->pvApicPibRC = NIL_RTRCPTR; 1073 1080 int rc = MMR3HyperMapHCPhys(pVM, (void *)pApic->pvApicPibR3, NIL_RTR0PTR, pApic->HCPhysApicPib, pApic->cbApicPib, 1074 1081 "APIC PIB", (PRTGCPTR)&pApic->pvApicPibRC); … … 1127 1134 1128 1135 /* Associate the per-VCPU PIB pointers to the per-VM PIB mapping. */ 1129 size_t const offApicPib= idCpu * sizeof(APICPIB);1136 uint32_t const offApicPib = idCpu * sizeof(APICPIB); 1130 1137 pApicCpu->pvApicPibR0 = (RTR0PTR)((RTR0UINTPTR)pApic->pvApicPibR0 + offApicPib); 1131 1138 pApicCpu->pvApicPibR3 = (RTR3PTR)((RTR3UINTPTR)pApic->pvApicPibR3 + offApicPib); … … 1135 1142 /* Initialize the virtual-APIC state. */ 1136 1143 memset((void *)pApicCpu->pvApicPageR3, 0, pApicCpu->cbApicPage); 1137 APICR3Reset(pVCpu );1144 APICR3Reset(pVCpu, true /* fResetApicBaseMsr */); 1138 1145 1139 1146 #ifdef DEBUG_ramshankar -
trunk/src/VBox/VMM/include/APICInternal.h
r60632 r60646 629 629 const char *apicGetTimerModeName(XAPICTIMERMODE enmTimerMode); 630 630 void apicHintTimerFreq(PAPICCPU pApicCpu, uint32_t uInitialCount, uint8_t uTimerShift); 631 APICMODE apicGetMode(uint64_t uApicBaseMsr); 631 632 632 633 VMMDECL(uint64_t) APICGetBaseMsr(PPDMDEVINS pDevIns, PVMCPU pVCpu);
Note:
See TracChangeset
for help on using the changeset viewer.