Changeset 60379 in vbox
- Timestamp:
- Apr 7, 2016 3:59:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/APIC.cpp
r60364 r60379 350 350 351 351 /** 352 * Resets the APIC base MSR. 353 * 354 * @param pVCpu The cross context virtual CPU structure. 355 */ 356 static void apicR3ResetBaseMsr(PVMCPU pVCpu) 357 { 358 /* 359 * Initialize the APIC base MSR. The APIC enable-bit is set upon power-up or reset[1]. 360 * 361 * A Reset (in xAPIC and x2APIC mode) brings up the local APIC in xAPIC mode. 362 * An INIT IPI does -not- cause a transition between xAPIC and x2APIC mode[2]. 363 * 364 * [1] See AMD spec. 14.1.3 "Processor Initialization State" 365 * [2] See Intel spec. 10.12.5.1 "x2APIC States". 366 */ 367 VMCPU_ASSERT_EMT_OR_NOT_RUNNING(pVCpu); 368 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 369 pApicCpu->uApicBaseMsr = XAPIC_APICBASE_PHYSADDR 370 | MSR_APICBASE_XAPIC_ENABLE_BIT; 371 if (pVCpu->idCpu == 0) 372 pApicCpu->uApicBaseMsr |= MSR_APICBASE_BOOTSTRAP_CPU_BIT; 373 } 374 375 376 /** 377 * Sets the xAPIC enabled bit in the APIC base MSR. 378 * 379 * @param pVCpu The cross context virtual CPU structure. 380 * @param fEnabled Whether to enable or disable the APIC. 381 * 382 * @remarks Warning!!! This does -not- touch the x2APIC enable bit and could 383 * thus lead to invalid states if used incorrectly! 384 */ 385 static void apicR3SetEnabled(PVMCPU pVCpu, bool fEnabled) 386 { 387 VMCPU_ASSERT_EMT_OR_NOT_RUNNING(pVCpu); 388 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 389 if (!fEnabled) 390 { 391 pApicCpu->uApicBaseMsr &= ~MSR_APICBASE_XAPIC_ENABLE_BIT; 392 Assert(!(pApicCpu->uApicBaseMsr & MSR_APICBASE_XAPIC_ENABLE_BIT)); 393 } 394 else 395 pApicCpu->uApicBaseMsr |= MSR_APICBASE_XAPIC_ENABLE_BIT; 396 } 397 398 399 /** 352 400 * Initializes per-VCPU APIC to the state following a power-up or hardware 353 401 * reset. … … 384 432 #endif 385 433 386 /*387 * Initialize the APIC base MSR. The APIC enable-bit is set upon power-up or reset[1].388 *389 * A Reset (in xAPIC and x2APIC mode) brings up the local APIC in xAPIC mode.390 * An INIT IPI does -not- cause a transition between xAPIC and x2APIC mode[2].391 *392 * [1] See AMD spec. 14.1.3 "Processor Initialization State"393 * [2] See Intel spec. 10.12.5.1 "x2APIC States".394 */395 434 /** @todo It isn't very clear where the default base address is (re)initialized, 396 435 * atm we do it here in Reset. */ 397 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 398 pApicCpu->uApicBaseMsr = (XAPIC_APICBASE_PHYSADDR << MSR_APICBASE_PHYSADDR_SHIFT) 399 | MSR_APICBASE_XAPIC_ENABLE_BIT; 400 if (pVCpu->idCpu == 0) 401 pApicCpu->uApicBaseMsr |= MSR_APICBASE_BOOTSTRAP_CPU_BIT; 436 apicR3ResetBaseMsr(pVCpu); 402 437 403 438 /* … … 447 482 448 483 /* 449 * Map the virtual-APIC page into RC and initialize per-VCPU APIC state.450 * The virtual-APIC page should've already been mapped into R0 and R3, seeAPICR0InitVM().484 * Map the virtual-APIC pages into RC and initialize per-VCPU APIC state. 485 * The virtual-APIC pages should by now have been mapped into R0 and R3 by APICR0InitVM(). 451 486 */ 452 487 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++) … … 470 505 size_t const offApicPib = idCpu * sizeof(APICPIB); 471 506 pApicCpu->pvApicPibRC = GCPtrApicPib + offApicPib; 507 508 /* 509 * Initialize the remaining state now that we have R3 mappings. 510 */ 511 APICR3Reset(pVCpu); 472 512 } 473 513 else … … 579 619 bool const fX2ApicMode = XAPIC_IN_X2APIC_MODE(pVCpu); 580 620 581 pHlp->pfnPrintf(pHlp, "VCPU[%u] APIC at %#RGp (%s mode):\n", pVCpu->idCpu, MSR_APICBASE_ PHYSADDR(pApicCpu->uApicBaseMsr),621 pHlp->pfnPrintf(pHlp, "VCPU[%u] APIC at %#RGp (%s mode):\n", pVCpu->idCpu, MSR_APICBASE_GET_PHYSADDR(pApicCpu->uApicBaseMsr), 582 622 fX2ApicMode ? "x2APIC" : "xAPIC"); 583 623 if (fX2ApicMode) … … 1058 1098 /* 1059 1099 * We can get invoked via PGMR3FinalizeMappings() which happens before initializing R0. 1060 * This means we may not have allocated and done the RC mappings & need to check for this.1100 * This we may not have allocated and mapped the R0, R3 data yet. Hence the NULL checks. 1061 1101 */ 1062 1102 if (pApic->pvApicPibR3) … … 1142 1182 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 1143 1183 RTStrPrintf(&pApicCpu->szTimerDesc[0], sizeof(pApicCpu->szTimerDesc), "APIC Timer %u", pVCpu->idCpu); 1184 1185 /* Initialize the APIC base MSR as we require it for registering the MMIO range. */ 1186 apicR3ResetBaseMsr(pVCpu); 1187 1188 /* Disable the APIC until we're fully initialized in APICR3InitCompleted(), see @bugref{8245#c46}. */ 1189 apicR3SetEnabled(pVCpu, false); 1144 1190 } 1145 1191 … … 1208 1254 */ 1209 1255 PAPICCPU pApicCpu0 = VMCPU_TO_APICCPU(&pVM->aCpus[0]); 1210 RTGCPHYS GCPhysApicBase = MSR_APICBASE_ PHYSADDR(pApicCpu0->uApicBaseMsr);1256 RTGCPHYS GCPhysApicBase = MSR_APICBASE_GET_PHYSADDR(pApicCpu0->uApicBaseMsr); 1211 1257 rc = PDMDevHlpMMIORegister(pDevIns, GCPhysApicBase, sizeof(XAPICPAGE), pVM, 1212 1258 IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_DWORD_ZEROED,
Note:
See TracChangeset
for help on using the changeset viewer.