VirtualBox

Ignore:
Timestamp:
Apr 28, 2009 8:50:31 AM (16 years ago)
Author:
vboxsync
Message:

Implemented VMMGetCpu in ring 0. (SMP guests)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp

    r19141 r19227  
    954954    ASMAtomicWriteBool(&pCpu->fInUse, true);
    955955
     956    AssertMsg(pVCpu->hwaccm.s.idEnteredCpu == NIL_RTCPUID, ("%d", (int)pVCpu->hwaccm.s.idEnteredCpu));
     957    pVCpu->hwaccm.s.idEnteredCpu = idCpu;
     958
    956959    pCtx = CPUMQueryGuestCtxPtr(pVCpu);
    957960
     
    982985    if (RT_SUCCESS(rc))
    983986    {
    984         AssertMsg(pVCpu->hwaccm.s.idEnteredCpu == NIL_RTCPUID, ("%d", (int)pVCpu->hwaccm.s.idEnteredCpu));
    985         pVCpu->hwaccm.s.idEnteredCpu = idCpu;
    986 
    987987#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    988988        PGMDynMapMigrateAutoSet(pVCpu);
    989989#endif
    990990    }
     991    else
     992        pVCpu->hwaccm.s.idEnteredCpu = NIL_RTCPUID;
    991993    return rc;
    992994}
     
    11701172{
    11711173    return &HWACCMR0Globals.aCpuInfo[idCpu];
     1174}
     1175
     1176/**
     1177 * Returns the VMCPU of the current EMT thread.
     1178 *
     1179 * @param   pVM         The VM to operate on.
     1180 */
     1181VMMR0DECL(PVMCPU)  HWACCMR0GetVMCPU(PVM pVM)
     1182{
     1183    /* RTMpCpuId had better be cheap. */
     1184    RTCPUID idHostCpu = RTMpCpuId();
     1185
     1186    /** @todo optimize for large number of VCPUs when that becomes more common. */
     1187    for (unsigned idCpu=0;idCpu<pVM->cCPUs;idCpu++)
     1188    {
     1189        PVMCPU pVCpu = &pVM->aCpus[idCpu];
     1190
     1191        if (pVCpu->hwaccm.s.idEnteredCpu == idHostCpu)
     1192            return pVCpu;
     1193    }
     1194    AssertReleaseFailed();
     1195    return 0;
     1196}
     1197
     1198/**
     1199 * Returns the VMCPU id of the current EMT thread.
     1200 *
     1201 * @param   pVM         The VM to operate on.
     1202 */
     1203VMMR0DECL(VMCPUID) HWACCMR0GetVMCPUId(PVM pVM)
     1204{
     1205    PVMCPU pVCpu = HWACCMR0GetVMCPU(pVM);
     1206    if (pVCpu)
     1207        return pVCpu->idCpu;
     1208
     1209    AssertReleaseFailed();
     1210    return 0;
    11721211}
    11731212
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