VirtualBox

Changeset 60428 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Apr 11, 2016 2:33:04 PM (9 years ago)
Author:
vboxsync
Message:

VMM/APIC: fixes with APIC base MSR initialization and nits.

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/APICAll.cpp

    r60377 r60428  
    373373    if (pXApicPage->svr.u.fApicSoftwareEnable)
    374374    {
    375         int const irrv = apicGetLastSetBit(&pXApicPage->irr, VERR_NOT_FOUND);
     375        int const irrv = apicGetLastSetBit(&pXApicPage->irr, -1 /* rcNotFound */);
    376376        if (irrv >= 0)
    377377        {
     
    963963static VBOXSTRICTRC apicSetTpr(PVMCPU pVCpu, uint32_t uTpr)
    964964{
    965     VMCPU_ASSERT_EMT_OR_NOT_RUNNING(pVCpu);
     965    VMCPU_ASSERT_EMT(pVCpu);
    966966
    967967    if (   XAPIC_IN_X2APIC_MODE(pVCpu)
     
    993993
    994994    PXAPICPAGE pXApicPage = VMCPU_TO_XAPICPAGE(pVCpu);
    995     int isrv = apicGetLastSetBit(&pXApicPage->isr, VERR_NOT_FOUND);
     995    int isrv = apicGetLastSetBit(&pXApicPage->isr, -1 /* rcNotFound */);
    996996    if (isrv >= 0)
    997997    {
     
    15461546        return VINF_CPUM_R3_MSR_READ;
    15471547
    1548     STAM_COUNTER_INC(&VMCPU_TO_APICCPU(pVCpu)->StatMsrWrite);
     1548    STAM_COUNTER_INC(&VMCPU_TO_APICCPU(pVCpu)->StatMsrRead);
    15491549
    15501550    VBOXSTRICTRC rcStrict = VINF_SUCCESS;
     
    19041904VMMDECL(uint8_t) APICGetTpr(PPDMDEVINS pDevIns, PVMCPU pVCpu)
    19051905{
    1906     VMCPU_ASSERT_EMT_OR_NOT_RUNNING(pVCpu);
     1906    VMCPU_ASSERT_EMT(pVCpu);
    19071907    PCXAPICPAGE pXApicPage = VMCPU_TO_CXAPICPAGE(pVCpu);
    19081908    return pXApicPage->tpr.u8Tpr;
     
    19611961    AssertReturn(u8Pin <= 1, VERR_INVALID_PARAMETER);
    19621962    AssertReturn(u8Level <= 1, VERR_INVALID_PARAMETER);
     1963
     1964    LogFlow(("APIC%u: APICLocalInterrupt\n", pVCpu->idCpu));
    19631965
    19641966    PCXAPICPAGE  pXApicPage = VMCPU_TO_CXAPICPAGE(pVCpu);
     
    20062008                    VMCPUSET_ADD(&DestCpuSet, pVCpu->idCpu);
    20072009                    uint8_t const uVector = XAPIC_LVT_GET_VECTOR(uLvt);
     2010
     2011                    Log4(("APIC%u: APICLocalInterrupt: Sending interrupt. enmDeliveryMode=%u u8Pin=%u uVector=%u\n",
     2012                          pVCpu->idCpu, enmDeliveryMode, u8Pin, uVector));
     2013
    20082014                    rcStrict = apicSendIntr(pVCpu, uVector, enmTriggerMode, enmDeliveryMode, &DestCpuSet, rcRZ);
    20092015                    break;
     
    20262032    {
    20272033        /* The APIC is disabled, pass it through the CPU. */
     2034        LogFlow(("APIC%u: APICLocalInterrupt: APIC hardware-disabled, passing interrupt to CPU. u8Pin=%u u8Level=%u\n", u8Pin,
     2035              u8Level));
    20282036        if (u8Level)
    20292037            APICSetInterruptFF(pVCpu, PDMAPICIRQ_EXTINT);
     
    20522060    VMCPU_ASSERT_EMT(pVCpu);
    20532061
     2062    LogFlow(("APIC%u: APICGetInterrupt\n", pVCpu->idCpu));
     2063
    20542064    PXAPICPAGE pXApicPage = VMCPU_TO_XAPICPAGE(pVCpu);
    20552065    if (   apicIsEnabled(pVCpu)
     
    20672077            uint8_t const uTpr = pXApicPage->tpr.u8Tpr;
    20682078            if (uTpr > 0 && uVector <= uTpr)
     2079            {
     2080                Log4(("APIC%u: APICGetInterrupt: Returns spurious vector %#x\n", pVCpu->idCpu,
     2081                      pXApicPage->svr.u.u8SpuriousVector));
    20692082                return pXApicPage->svr.u.u8SpuriousVector;
    2070 
    2071             apicClearVectorInReg(&pXApicPage->irr, uVector);
    2072             apicSetVectorInReg(&pXApicPage->isr, uVector);
    2073             apicUpdatePpr(pVCpu);
    2074             apicSignalNextPendingIntr(pVCpu);
    2075             return uVector;
     2083            }
     2084
     2085            uint8_t const uPpr = pXApicPage->ppr.u8Ppr;
     2086            if (   !uPpr
     2087                ||  XAPIC_PPR_GET_PP(uVector) > XAPIC_PPR_GET_PP(uPpr))
     2088            {
     2089                apicClearVectorInReg(&pXApicPage->irr, uVector);
     2090                apicSetVectorInReg(&pXApicPage->isr, uVector);
     2091                apicUpdatePpr(pVCpu);
     2092                apicSignalNextPendingIntr(pVCpu);
     2093
     2094                Log4(("APIC%u: APICGetInterrupt: Returns vector %#x\n", pVCpu->idCpu, uVector));
     2095                return uVector;
     2096            }
    20762097        }
    20772098    }
     
    20942115    uint16_t offReg   = (GCPhysAddr & 0xff0);
    20952116    uint32_t uValue   = 0;
     2117
    20962118#ifdef VBOX_WITH_STATISTICS
    20972119    PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu);
    20982120    STAM_COUNTER_INC(&CTXSUFF(pApicCpu->StatMmioRead));
    20992121#endif
     2122
     2123    Log4(("APIC%u: ApicReadMmio: offReg=%#RX16\n", pVCpu->idCpu, offReg));
     2124
    21002125    int rc = apicReadRegister(pApicDev, pVCpu, offReg, &uValue);
    21012126    *(uint32_t *)pv = uValue;
     
    21172142    uint16_t offReg   = (GCPhysAddr & 0xff0);
    21182143    uint32_t uValue   = *(uint32_t *)pv;
     2144
    21192145#ifdef VBOX_WITH_STATISTICS
    21202146    PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu);
    21212147    STAM_COUNTER_INC(&CTXSUFF(pApicCpu->StatMmioWrite));
    21222148#endif
     2149
     2150    LogRel(("APIC%u: APICWriteMmio: offReg=%#RX16\n", pVCpu->idCpu, offReg));
     2151
    21232152    int rc = VBOXSTRICTRC_VAL(apicWriteRegister(pApicDev, pVCpu, offReg, uValue));
    21242153    return rc;
     
    21772206    if (RT_LIKELY(uVector > XAPIC_ILLEGAL_VECTOR_END))
    21782207    {
     2208        Log4(("APIC%u: APICPostInterrupt: uVector=%#x\n", pVCpu->idCpu, uVector));
    21792209        if (enmTriggerMode == XAPICTRIGGERMODE_EDGE)
    21802210        {
  • trunk/src/VBox/VMM/VMMR3/APIC.cpp

    r60400 r60428  
    456456
    457457    size_t cPending = 0;
    458     pHlp->pfnPrintf(pHlp, "  Pending\n");
    459     pHlp->pfnPrintf(pHlp, "   ");
     458    pHlp->pfnPrintf(pHlp, "    Pending:\n");
     459    pHlp->pfnPrintf(pHlp, "     ");
    460460    for (ssize_t i = cFragments - 1; i >= 0; i--)
    461461    {
     
    494494    bool const   fX2ApicMode = XAPIC_IN_X2APIC_MODE(pVCpu);
    495495
    496     pHlp->pfnPrintf(pHlp, "VCPU[%u] APIC at %#RGp (%s mode):\n", pVCpu->idCpu, MSR_APICBASE_GET_PHYSADDR(pApicCpu->uApicBaseMsr),
    497                                                                  fX2ApicMode ? "x2APIC" : "xAPIC");
     496    pHlp->pfnPrintf(pHlp, "VCPU[%u] APIC at %#RGp\n", pVCpu->idCpu, MSR_APICBASE_GET_PHYSADDR(pApicCpu->uApicBaseMsr));
     497    pHlp->pfnPrintf(pHlp, "  Mode                          = %s\n", fX2ApicMode ? "x2Apic" : "xApic");
    498498    if (fX2ApicMode)
    499499    {
     
    537537    pHlp->pfnPrintf(pHlp, "  IRR\n");
    538538    apicR3DbgInfo256BitReg(&pXApicPage->irr, pHlp);
    539     pHlp->pfnPrintf(pHlp, "ESR Internal                    = %#x\n",      pApicCpu->uEsrInternal);
     539    pHlp->pfnPrintf(pHlp, "  ESR Internal                  = %#x\n",      pApicCpu->uEsrInternal);
    540540    pHlp->pfnPrintf(pHlp, "  ESR                           = %#x\n",      pXApicPage->esr.all.u32Errors);
    541541    pHlp->pfnPrintf(pHlp, "    Redirectable IPI            = %RTbool\n",  pXApicPage->esr.u.fRedirectableIpi);
     
    574574    uint32_t const uLvtTimer = pXApicPage->lvt_timer.all.u32LvtTimer;
    575575    pHlp->pfnPrintf(pHlp, "LVT Timer          = %#RX32\n",   uLvtTimer);
    576     pHlp->pfnPrintf(pHlp, "  Vector           = %u (%#x)\n", pXApicPage->lvt_timer.u.u8Vector);
     576    pHlp->pfnPrintf(pHlp, "  Vector           = %u (%#x)\n", pXApicPage->lvt_timer.u.u8Vector, pXApicPage->lvt_timer.u.u8Vector);
    577577    pHlp->pfnPrintf(pHlp, "  Delivery status  = %u\n",       pXApicPage->lvt_timer.u.u1DeliveryStatus);
    578578    pHlp->pfnPrintf(pHlp, "  Masked           = %RTbool\n",  XAPIC_LVT_IS_MASKED(uLvtTimer));
     
    626626                    apicGetTriggerModeName((XAPICTRIGGERMODE)pXApicPage->lvt_lint0.u.u1TriggerMode));
    627627    pHlp->pfnPrintf(pHlp, "  Masked           = %RTbool\n",  XAPIC_LVT_IS_MASKED(uLvtLint0));
     628    pHlp->pfnPrintf(pHlp, "\n");
    628629
    629630    uint32_t const uLvtLint1 = pXApicPage->lvt_lint1.all.u32LvtLint1;
     
    665666    pHlp->pfnPrintf(pHlp, "  DCR              = %#RX32\n", pXApicPage->timer_dcr.all.u32DivideValue);
    666667    pHlp->pfnPrintf(pHlp, "    Timer shift    = %#x\n",    apicGetTimerShift(pXApicPage));
    667     pHlp->pfnPrintf(pHlp, "  Timer initial TS = %#RU64", pApicCpu->u64TimerInitial);
     668    pHlp->pfnPrintf(pHlp, "  Timer initial TS = %#RU64\n", pApicCpu->u64TimerInitial);
    668669    pHlp->pfnPrintf(pHlp, "\n");
    669670
     
    12961297    PAPICCPU pApicCpu0 = VMCPU_TO_APICCPU(&pVM->aCpus[0]);
    12971298    RTGCPHYS GCPhysApicBase = MSR_APICBASE_GET_PHYSADDR(pApicCpu0->uApicBaseMsr);
    1298     rc = PDMDevHlpMMIORegister(pDevIns, GCPhysApicBase, sizeof(XAPICPAGE), pVM,
     1299    LogRel(("APIC: PDMDevHlpMMIORegister new = %#RGp\n", GCPhysApicBase));
     1300    rc = PDMDevHlpMMIORegister(pDevIns, GCPhysApicBase, sizeof(XAPICPAGE), NULL /* pvUser */,
    12991301                               IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_DWORD_ZEROED,
    13001302                               APICWriteMmio, APICReadMmio, "APIC");
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