VirtualBox

Changeset 72392 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 30, 2018 12:27:17 PM (7 years ago)
Author:
vboxsync
Message:

NEM/win: TSC_AUX and APIC_BASE work. bugref:9044

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

Legend:

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

    r71266 r72392  
    21742174 *
    21752175 * @returns Strict VBox status code.
     2176 * @retval  VINF_SUCCESS
     2177 * @retval  VINF_CPUM_R3_MSR_WRITE
     2178 * @retval  VERR_CPUM_RAISE_GP_0
     2179 *
    21762180 * @param   pVCpu       The cross context virtual CPU structure.
    21772181 * @param   u64BaseMsr  The value to set.
  • trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h

    r72387 r72392  
    12561256    }
    12571257
    1258     if (rc == VERR_NEM_CHANGE_PGM_MODE || rc == VERR_NEM_FLUSH_TLB)
     1258    if (rc == VERR_NEM_CHANGE_PGM_MODE || rc == VERR_NEM_FLUSH_TLB || rc == VERR_NEM_UPDATE_APIC_BASE)
    12591259    {
    12601260        Log4(("%s/%u: nemR0WinImportState -> %Rrc\n", pszCaller, pGVCpu->idCpu, -rc));
     
    17961796            Log(("UnrecovExit/%u: %04x:%08RX64/%s: RFL=%#RX64 -> VINF_SUCCESS\n", pVCpu->idCpu, pMsgHdr->CsSegment.Selector,
    17971797                 pMsgHdr->Rip, nemHCWinExecStateToLogStr(pMsgHdr), pMsgHdr->Rflags ));
     1798            pCtx->fExtrn &= ~CPUMCTX_EXTRN_NEM_WIN_EVENT_INJECT; /* Make sure to reset pending #DB(0). */
    17981799            return VINF_SUCCESS;
    17991800        }
     
    23672368        if (RT_SUCCESS(rc2))
    23682369            pCtx->fExtrn = 0;
    2369         else if (rc2 == VERR_NEM_CHANGE_PGM_MODE || rc2 == VERR_NEM_FLUSH_TLB)
     2370        else if (rc2 == VERR_NEM_CHANGE_PGM_MODE || rc2 == VERR_NEM_FLUSH_TLB || rc2 == VERR_NEM_UPDATE_APIC_BASE)
    23702371        {
    23712372            pCtx->fExtrn = 0;
     
    23742375            else
    23752376            {
    2376                 pVCpu->nem.s.rcPgmPending = -rc2;
    2377                 LogFlow(("NEM/%u: rcPgmPending=%Rrc (rcStrict=%Rrc)\n", pVCpu->idCpu, rc2, VBOXSTRICTRC_VAL(rcStrict) ));
     2377                pVCpu->nem.s.rcPending = -rc2;
     2378                LogFlow(("NEM/%u: rcPending=%Rrc (rcStrict=%Rrc)\n", pVCpu->idCpu, rc2, VBOXSTRICTRC_VAL(rcStrict) ));
    23782379            }
    23792380        }
  • trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp

    r72386 r72392  
    11531153        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.MtrrFix4K_F8000;
    11541154        iReg++;
     1155        HV_REGISTER_ASSOC_ZERO_PADDING_AND_HI64(&pInput->Elements[iReg]);
     1156        pInput->Elements[iReg].Name                 = HvX64RegisterTscAux;
     1157        pInput->Elements[iReg].Value.Reg64          = pCtxMsrs->msr.TscAux;
     1158        iReg++;
    11551159
    11561160#if 0 /** @todo Why can't we write these on Intel systems? Not that we really care... */
     
    14801484        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kF0000;
    14811485        pInput->Names[iReg++] = HvX64RegisterMtrrFix4kF8000;
     1486        pInput->Names[iReg++] = HvX64RegisterTscAux;
    14821487#if 0 /** @todo why can't we read HvX64RegisterIa32MiscEnable? */
    14831488        if (enmCpuVendor != CPUMCPUVENDOR_AMD)
     
    19471952        iReg++;
    19481953    }
     1954    bool fUpdateApicBase = false;
    19491955    if (fWhat & CPUMCTX_EXTRN_OTHER_MSRS)
    19501956    {
     
    19561962                  pVCpu->idCpu, uOldBase, paValues[iReg].Reg64, paValues[iReg].Reg64 ^ uOldBase));
    19571963            VBOXSTRICTRC rc2 = APICSetBaseMsr(pVCpu, paValues[iReg].Reg64);
    1958             Assert(rc2 == VINF_SUCCESS); NOREF(rc2);
     1964            if (rc2 == VINF_CPUM_R3_MSR_WRITE)
     1965            {
     1966                pVCpu->nem.s.uPendingApicBase = paValues[iReg].Reg64;
     1967                fUpdateApicBase = true;
     1968            }
     1969            else
     1970                AssertLogRelMsg(rc2 == VINF_SUCCESS, ("rc2=%Rrc [%#RX64]\n", VBOXSTRICTRC_VAL(rc2), paValues[iReg].Reg64));
    19591971        }
    19601972        iReg++;
     
    20462058            Log7(("NEM/%u: MSR MTRR_FIX16K_F8000 changed %RX64 -> %RX64\n", pVCpu->idCpu, pCtxMsrs->msr.MtrrFix4K_F8000, paValues[iReg].Reg64));
    20472059        pCtxMsrs->msr.MtrrFix4K_F8000 = paValues[iReg].Reg64;
     2060        iReg++;
     2061
     2062        Assert(pInput->Names[iReg] == HvX64RegisterTscAux);
     2063        if (paValues[iReg].Reg64 != pCtxMsrs->msr.TscAux )
     2064            Log7(("NEM/%u: MSR TSC_AUX changed %RX64 -> %RX64\n", pVCpu->idCpu, pCtxMsrs->msr.TscAux, paValues[iReg].Reg64));
     2065        pCtxMsrs->msr.TscAux = paValues[iReg].Reg64;
    20482066        iReg++;
    20492067
     
    21192137
    21202138    /* Typical. */
    2121     if (!fMaybeChangedMode && !fFlushTlb)
     2139    if (!fMaybeChangedMode && !fFlushTlb && !fUpdateApicBase)
    21222140        return VINF_SUCCESS;
    21232141
     
    21412159        LogFlow(("nemR0WinImportState: -> VERR_NEM_FLUSH_TLB!\n"));
    21422160        rc = VERR_NEM_FLUSH_TLB; /* Calling PGMFlushTLB w/o long jump setup doesn't work, ring-3 does it. */
     2161    }
     2162
     2163    if (fUpdateApicBase && rc == VINF_SUCCESS)
     2164    {
     2165        LogFlow(("nemR0WinImportState: -> VERR_NEM_UPDATE_APIC_BASE!\n"));
     2166        rc = VERR_NEM_UPDATE_APIC_BASE;
    21432167    }
    21442168
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp

    r72358 r72392  
    11011101
    11021102    /*
     1103     * Some state init.
     1104     */
     1105    for (VMCPUID iCpu = 0; iCpu < pVM->cCpus; iCpu++)
     1106    {
     1107        PNEMCPU pNemCpu = &pVM->aCpus[iCpu].nem.s;
     1108        pNemCpu->uPendingApicBase = UINT64_MAX;
     1109    }
     1110
     1111    /*
    11031112     * Error state.
    11041113     * The error message will be non-empty on failure and 'rc' will be set too.
     
    20372046        if (RT_SUCCESS(rcStrict))
    20382047        {
    2039             /* We deal with VINF_NEM_CHANGE_PGM_MODE and VINF_NEM_FLUSH_TLB here, since we're running
    2040                the risk of getting these while we already got another RC (I/O ports). */
    2041             VBOXSTRICTRC rcPgmPending = pVCpu->nem.s.rcPgmPending;
    2042             pVCpu->nem.s.rcPgmPending = VINF_SUCCESS;
     2048            /*
     2049             * We deal with VINF_NEM_CHANGE_PGM_MODE, VINF_NEM_FLUSH_TLB and
     2050             * VINF_NEM_UPDATE_APIC_BASE  here, since we're running the risk of
     2051             * getting these while we already got another RC (I/O ports).
     2052             *
     2053             * The APIC base update and a PGM update can happen at the same time, so
     2054             * we don't depend on the status code for that and always checks it first.
     2055             */
     2056            /* APIC base: */
     2057            if (pVCpu->nem.s.uPendingApicBase != UINT64_MAX)
     2058            {
     2059                LogFlow(("nemR3NativeRunGC: calling APICSetBaseMsr(,%RX64)...\n", pVCpu->nem.s.uPendingApicBase));
     2060                VBOXSTRICTRC rc2 = APICSetBaseMsr(pVCpu, pVCpu->nem.s.uPendingApicBase);
     2061                AssertLogRelMsg(rc2 == VINF_SUCCESS, ("rc2=%Rrc [%#RX64]\n", VBOXSTRICTRC_VAL(rc2), pVCpu->nem.s.uPendingApicBase));
     2062                pVCpu->nem.s.uPendingApicBase = UINT64_MAX;
     2063            }
     2064
     2065            /* Status codes: */
     2066            VBOXSTRICTRC rcPending = pVCpu->nem.s.rcPending;
     2067            pVCpu->nem.s.rcPending = VINF_SUCCESS;
    20432068            if (   rcStrict == VINF_NEM_CHANGE_PGM_MODE
    20442069                || rcStrict == VINF_PGM_CHANGE_MODE
    2045                 || rcPgmPending == VINF_NEM_CHANGE_PGM_MODE )
     2070                || rcPending == VINF_NEM_CHANGE_PGM_MODE )
    20462071            {
    20472072                LogFlow(("nemR3NativeRunGC: calling PGMChangeMode...\n"));
     
    20602085                }
    20612086            }
    2062             else if (rcStrict == VINF_NEM_FLUSH_TLB || rcPgmPending == VINF_NEM_FLUSH_TLB)
     2087            else if (rcStrict == VINF_NEM_FLUSH_TLB || rcPending == VINF_NEM_FLUSH_TLB)
    20632088            {
    20642089                LogFlow(("nemR3NativeRunGC: calling PGMFlushTLB...\n"));
     
    20772102                }
    20782103            }
     2104            else if (rcStrict == VINF_NEM_UPDATE_APIC_BASE || rcPending == VERR_NEM_UPDATE_APIC_BASE)
     2105                continue;
    20792106            else
    2080                 AssertMsg(rcPgmPending == VINF_SUCCESS, ("rcPgmPending=%Rrc\n", VBOXSTRICTRC_VAL(rcPgmPending) ));
     2107                AssertMsg(rcPending == VINF_SUCCESS, ("rcPending=%Rrc\n", VBOXSTRICTRC_VAL(rcPending) ));
    20812108        }
    20822109        LogFlow(("nemR3NativeRunGC: returns %Rrc\n", VBOXSTRICTRC_VAL(rcStrict) ));
  • trunk/src/VBox/VMM/include/NEMInternal.h

    r72358 r72392  
    195195    bool                        fLastInterruptShadow : 1;
    196196    bool                        afPadding[1];
     197    /** Pending APIC base value.
     198     * This is set to UINT64_MAX when not pending  */
     199    uint64_t                    uPendingApicBase;
    197200# ifdef NEM_WIN_USE_OUR_OWN_RUN_API
    198     /** Pending VERR_NEM_CHANGE_PGM_MODE or VERR_NEM_FLUSH_TLB. */
    199     int32_t                     rcPgmPending;
     201    /** Pending VINF_NEM_CHANGE_PGM_MODE, VINF_NEM_FLUSH_TLB or VINF_NEM_UPDATE_APIC_BASE. */
     202    int32_t                     rcPending;
    200203    /** The VID_MSHAGN_F_XXX flags.
    201204     * Either VID_MSHAGN_F_HANDLE_MESSAGE | VID_MSHAGN_F_GET_NEXT_MESSAGE or zero. */
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