VirtualBox

Changeset 60379 in vbox


Ignore:
Timestamp:
Apr 7, 2016 3:59:11 PM (9 years ago)
Author:
vboxsync
Message:

VMM/APIC: Missed as part of r106461.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/APIC.cpp

    r60364 r60379  
    350350
    351351/**
     352 * Resets the APIC base MSR.
     353 *
     354 * @param   pVCpu           The cross context virtual CPU structure.
     355 */
     356static 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 */
     385static 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/**
    352400 * Initializes per-VCPU APIC to the state following a power-up or hardware
    353401 * reset.
     
    384432#endif
    385433
    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      */
    395434    /** @todo It isn't very clear where the default base address is (re)initialized,
    396435     *        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);
    402437
    403438    /*
     
    447482
    448483            /*
    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, see APICR0InitVM().
     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().
    451486             */
    452487            for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     
    470505                        size_t const offApicPib = idCpu * sizeof(APICPIB);
    471506                        pApicCpu->pvApicPibRC   = GCPtrApicPib + offApicPib;
     507
     508                        /*
     509                         * Initialize the remaining state now that we have R3 mappings.
     510                         */
     511                        APICR3Reset(pVCpu);
    472512                    }
    473513                    else
     
    579619    bool const   fX2ApicMode = XAPIC_IN_X2APIC_MODE(pVCpu);
    580620
    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),
    582622                                                                 fX2ApicMode ? "x2APIC" : "xAPIC");
    583623    if (fX2ApicMode)
     
    10581098    /*
    10591099     * 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.
    10611101     */
    10621102    if (pApic->pvApicPibR3)
     
    11421182        PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu);
    11431183        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);
    11441190    }
    11451191
     
    12081254     */
    12091255    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);
    12111257    rc = PDMDevHlpMMIORegister(pDevIns, GCPhysApicBase, sizeof(XAPICPAGE), pVM,
    12121258                               IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_DWORD_ZEROED,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette