VirtualBox

Changeset 19293 in vbox for trunk


Ignore:
Timestamp:
May 1, 2009 4:11:18 PM (16 years ago)
Author:
vboxsync
Message:

DBGF,VMM: SMP refactoring of the DBGF disassembler code. Changed VMMGetCpu and VMMGetCpuId to return NULL and NIL if the caller isn't an EMT. Renamed VMMGetCpuEx to VMMGetCpuById.

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/dbgf.h

    r19291 r19293  
    771771#define DBGF_SEL_FLAT                       1
    772772
    773 VMMR3DECL(int) DBGFR3DisasInstrEx(PVM pVM, PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr, unsigned fFlags, char *pszOutput, uint32_t cchOutput, uint32_t *pcbInstr);
    774 VMMR3DECL(int) DBGFR3DisasInstr(PVM pVM, PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr, char *pszOutput, uint32_t cbOutput);
     773VMMR3DECL(int) DBGFR3DisasInstrEx(PVM pVM, VMCPUID idCpu, RTSEL Sel, RTGCPTR GCPtr, unsigned fFlags, char *pszOutput, uint32_t cchOutput, uint32_t *pcbInstr);
    775774VMMR3DECL(int) DBGFR3DisasInstrCurrent(PVM pVM, char *pszOutput, uint32_t cbOutput);
    776775VMMR3DECL(int) DBGFR3DisasInstrCurrentLogInternal(PVM pVM, const char *pszPrefix);
     
    791790#endif
    792791
    793 VMMR3DECL(int) DBGFR3DisasInstrLogInternal(PVM pVM, PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr);
     792VMMR3DECL(int) DBGFR3DisasInstrLogInternal(PVM pVM, RTSEL Sel, RTGCPTR GCPtr);
    794793
    795794/** @def DBGFR3DisasInstrLog
    796795 * Disassembles the specified guest context instruction and writes it to the log.
    797796 * Addresses will be attempted resolved to symbols.
     797 * @thread Any EMT.
    798798 */
    799799#ifdef LOG_ENABLED
  • trunk/include/VBox/pdmdev.h

    r19043 r19293  
    26942694
    26952695    /**
    2696      * Get CPUID.
     2696     * Get the specified CPUID leaf for the virtual CPU associated with the calling
     2697     * thread.
    26972698     *
    26982699     * @param   pDevIns             Device instance.
     
    27022703     * @param   pEcx                Where to store the ECX value.
    27032704     * @param   pEdx                Where to store the EDX value.
     2705     * @thread  EMT.
    27042706     */
    27052707    DECLR3CALLBACKMEMBER(void, pfnGetCpuId,(PPDMDEVINS pDevIns, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx));
  • trunk/include/VBox/vmm.h

    r19257 r19293  
    114114VMMDECL(PVMCPU)      VMMGetCpu(PVM pVM);
    115115VMMDECL(PVMCPU)      VMMGetCpu0(PVM pVM);
    116 VMMDECL(PVMCPU)      VMMGetCpuEx(PVM pVM, RTCPUID idCpu);
     116VMMDECL(PVMCPU)      VMMGetCpuById(PVM pVM, RTCPUID idCpu);
    117117VMMDECL(uint32_t)    VMMGetSvnRev(void);
    118118VMMDECL(VMMSWITCHER) VMMGetSwitcher(PVM pVM);
  • trunk/src/VBox/VMM/DBGFAddr.cpp

    r19286 r19293  
    6969    {
    7070        SELMSELINFO SelInfo;
    71         int rc = SELMR3GetSelectorInfo(pVM, VMMGetCpuEx(pVM, idCpu), Sel, &SelInfo);
     71        int rc = SELMR3GetSelectorInfo(pVM, VMMGetCpuById(pVM, idCpu), Sel, &SelInfo);
    7272        if (RT_FAILURE(rc))
    7373            return rc;
     
    229229    else
    230230    {
    231         PVMCPU pVCpu = VMMGetCpuEx(pVM, idCpu);
     231        PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
    232232        if (VMCPU_IS_EMT(pVCpu))
    233233            rc = dbgfR3AddrToPhysOnVCpu(pVCpu, pAddress, pGCPhys);
     
    344344        else
    345345        {
    346             PVMCPU pVCpu = VMMGetCpuEx(pVM, idCpu);
     346            PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
    347347            if (fReadOnly)
    348348                rc = PGMPhysGCPtr2CCPtrReadOnly(pVCpu, pAddress->FlatPtr, (void const **)ppvR3Ptr, &Lock);
  • trunk/src/VBox/VMM/DBGFDisas.cpp

    r19181 r19293  
    312312                         char *pszOutput, uint32_t cchOutput, uint32_t *pcbInstr)
    313313{
     314    VMCPU_ASSERT_EMT(pVCpu);
    314315    RTGCPTR GCPtr = *pGCPtr;
    315316
     
    520521 * @returns VBox status code.
    521522 * @param   pVM             VM handle.
    522  * @param   pVCpu           The virtual CPU handle, defaults to CPU 0 if NULL.
     523 * @param   idCpu           The ID of virtual CPU.
    523524 * @param   Sel             The code selector. This used to determin the 32/16 bit ness and
    524525 *                          calculation of the actual instruction address.
     
    533534 *          address conversion.
    534535 */
    535 VMMR3DECL(int) DBGFR3DisasInstrEx(PVM pVM, PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr, unsigned fFlags,
     536VMMR3DECL(int) DBGFR3DisasInstrEx(PVM pVM, VMCPUID idCpu, RTSEL Sel, RTGCPTR GCPtr, unsigned fFlags,
    536537                                  char *pszOutput, uint32_t cchOutput, uint32_t *pcbInstr)
    537538{
    538     /* If not specified, assume CPU 0. */
    539     if (!pVCpu)
    540         pVCpu = &pVM->aCpus[0];
    541 
    542     int rc;
    543     if (VMCPU_IS_EMT(pVCpu)) /* not necessary, but it's faster. */
     539    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     540    AssertReturn(idCpu < pVM->cCPUs, VERR_INVALID_CPU_ID);
     541
     542    int     rc;
     543    PVMCPU  pVCpu = VMMGetCpu(pVM);
     544    if (    pVCpu
     545        &&  pVCpu->idCpu == idCpu) /* not necessary, but it's faster. */
    544546        rc = dbgfR3DisasInstrExOnVCpu(pVM, pVCpu, Sel, &GCPtr, fFlags, pszOutput, cchOutput, pcbInstr);
    545547    else
    546548    {
    547549        PVMREQ pReq = NULL;
    548         rc = VMR3ReqCall(pVCpu->pVMR3, VMREQDEST_FROM_VMCPU(pVCpu), &pReq, RT_INDEFINITE_WAIT,
     550        rc = VMR3ReqCall(pVM, VMREQDEST_FROM_ID(idCpu), &pReq, RT_INDEFINITE_WAIT,
    549551                         (PFNRT)dbgfR3DisasInstrExOnVCpu, 8,
    550                          pVM, pVCpu, Sel, &GCPtr, fFlags, pszOutput, cchOutput, pcbInstr);
     552                         pVM, VMMGetCpuById(pVM, idCpu), Sel, &GCPtr, fFlags, pszOutput, cchOutput, pcbInstr);
    551553        if (RT_SUCCESS(rc))
    552554        {
     
    556558    }
    557559    return rc;
    558 }
    559 
    560 
    561 /**
    562  * Disassembles an instruction.
    563  * Addresses will be tried resolved to symbols
    564  *
    565  * @returns VBox status code.
    566  * @param   pVM             VM handle.
    567  * @param   pVCpu           The virtual CPU handle, defaults to CPU 0 if NULL.
    568  * @param   Sel             The code selector. This used to determin the 32/16 bit ness and
    569  *                          calculation of the actual instruction address.
    570  * @param   GCPtr           The code address relative to the base of Sel.
    571  * @param   pszOutput       Output buffer.
    572  * @param   cchOutput        Size of the output buffer.
    573  */
    574 VMMR3DECL(int) DBGFR3DisasInstr(PVM pVM, PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr, char *pszOutput, uint32_t cchOutput)
    575 {
    576     return DBGFR3DisasInstrEx(pVM, pVCpu, Sel, GCPtr, 0, pszOutput, cchOutput, NULL);
    577560}
    578561
     
    589572VMMR3DECL(int) DBGFR3DisasInstrCurrent(PVM pVM, char *pszOutput, uint32_t cchOutput)
    590573{
    591     return DBGFR3DisasInstrEx(pVM, VMMGetCpu(pVM), 0, 0, DBGF_DISAS_FLAGS_CURRENT_GUEST, pszOutput, cchOutput, NULL);
     574    *pszOutput = '\0';
     575    PVMCPU pVCpu = VMMGetCpu(pVM);
     576    AssertReturn(pVCpu, VERR_INVALID_CONTEXT);
     577    return DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, 0, 0, DBGF_DISAS_FLAGS_CURRENT_GUEST,
     578                              pszOutput, cchOutput, NULL);
    592579}
    593580
     
    628615 * @param   GCPtr           The code address relative to the base of Sel.
    629616 */
    630 VMMR3DECL(int) DBGFR3DisasInstrLogInternal(PVM pVM, PVMCPU pVCpu, RTSEL Sel, RTGCPTR GCPtr)
    631 {
     617VMMR3DECL(int) DBGFR3DisasInstrLogInternal(PVM pVM, RTSEL Sel, RTGCPTR GCPtr)
     618{
     619    PVMCPU pVCpu = VMMGetCpu(pVM);
     620    AssertReturn(pVCpu, VERR_INVALID_CONTEXT);
     621
    632622    char szBuf[256];
    633623    szBuf[0] = '\0';
    634     int rc = DBGFR3DisasInstr(pVM, pVCpu, Sel, GCPtr, &szBuf[0], sizeof(szBuf));
     624    int rc = DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, Sel, GCPtr, 0, &szBuf[0], sizeof(szBuf), NULL);
    635625    if (RT_FAILURE(rc))
    636626        RTStrPrintf(szBuf, sizeof(szBuf), "DBGFR3DisasInstrLog(, %RTsel, %RGv) failed with rc=%Rrc\n", Sel, GCPtr, rc);
  • trunk/src/VBox/VMM/DBGFMem.cpp

    r19286 r19293  
    6868     */
    6969    int     rc;
    70     PVMCPU  pVCpu = VMMGetCpuEx(pVM, idCpu);
     70    PVMCPU  pVCpu   = VMMGetCpuById(pVM, idCpu);
    7171    PGMMODE enmMode = PGMGetGuestMode(pVCpu);
    7272    if (    enmMode == PGMMODE_REAL
     
    167167         * Select DBGF worker by addressing mode.
    168168         */
    169         PVMCPU  pVCpu   = VMMGetCpuEx(pVM, idCpu);
     169        PVMCPU  pVCpu   = VMMGetCpuById(pVM, idCpu);
    170170        PGMMODE enmMode = PGMGetGuestMode(pVCpu);
    171171        if (    enmMode == PGMMODE_REAL
     
    335335         * Select PGM function by addressing mode.
    336336         */
    337         PVMCPU  pVCpu = VMMGetCpuEx(pVM, idCpu);
     337        PVMCPU  pVCpu   = VMMGetCpuById(pVM, idCpu);
    338338        PGMMODE enmMode = PGMGetGuestMode(pVCpu);
    339339        if (    enmMode == PGMMODE_REAL
  • trunk/src/VBox/VMM/DBGFStack.cpp

    r19291 r19293  
    292292        else if (DBGFADDRESS_IS_FLAT(&pCur->AddrPC))
    293293        {
    294             CPUMMODE CpuMode = CPUMGetGuestMode(VMMGetCpuEx(pVM, idCpu));
     294            CPUMMODE CpuMode = CPUMGetGuestMode(VMMGetCpuById(pVM, idCpu));
    295295            if (CpuMode == CPUMMODE_REAL)
    296296                fAddrMask = UINT16_MAX;
     
    397397     */
    398398    PCCPUMCTXCORE   pCtxCore = fGuest
    399                              ? CPUMGetGuestCtxCore(VMMGetCpuEx(pVM, idCpu))
    400                              : CPUMGetHyperCtxCore(VMMGetCpuEx(pVM, idCpu));
     399                             ? CPUMGetGuestCtxCore(VMMGetCpuById(pVM, idCpu))
     400                             : CPUMGetHyperCtxCore(VMMGetCpuById(pVM, idCpu));
    401401    PVMREQ          pReq;
    402402    int rc = VMR3ReqCall(pVM, VMREQDEST_FROM_ID(idCpu), &pReq, RT_INDEFINITE_WAIT,
  • trunk/src/VBox/VMM/PATM/PATM.cpp

    r19240 r19293  
    58645864        char szBuf[256];
    58655865        szBuf[0] = '\0';
    5866         DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pCurPatchInstrGC, szBuf, sizeof(szBuf));
     5866        DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurPatchInstrGC, 0, szBuf, sizeof(szBuf), NULL);
    58675867        Log(("DIRTY: %s\n", szBuf));
    58685868#endif
     
    59265926                char szBuf[256];
    59275927                szBuf[0] = '\0';
    5928                 DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pCurInstrGC, szBuf, sizeof(szBuf));
     5928                DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurInstrGC, 0, szBuf, sizeof(szBuf), NULL);
    59295929                Log(("NEW:   %s\n", szBuf));
    59305930#endif
     
    59425942                char szBuf[256];
    59435943                szBuf[0] = '\0';
    5944                 DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pCurInstrGC, szBuf, sizeof(szBuf));
     5944                DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurInstrGC, 0, szBuf, sizeof(szBuf), NULL);
    59455945                Log(("NEW:   %s (FAILED)\n", szBuf));
    59465946#endif
     
    61406140        char szBuf[256];
    61416141        szBuf[0] = '\0';
    6142         DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pEip, szBuf, sizeof(szBuf));
     6142        DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pEip, 0, szBuf, sizeof(szBuf), NULL);
    61436143
    61446144        /* Very bad. We crashed in emitted code. Probably stack? */
  • trunk/src/VBox/VMM/PDMDevHlp.cpp

    r19217 r19293  
    12571257{
    12581258    PDMDEV_ASSERT_DEVINS(pDevIns);
    1259     LogFlow(("pdmR3DevHlp_GetVMCPU: caller='%s'/%d for CPU %d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VMMGetCpuId(pDevIns->Internal.s.pVMR3)));
     1259    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
     1260    LogFlow(("pdmR3DevHlp_GetVMCPU: caller='%s'/%d for CPU %u\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VMMGetCpuId(pDevIns->Internal.s.pVMR3)));
    12601261    return VMMGetCpu(pDevIns->Internal.s.pVMR3);
    12611262}
     
    21642165             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pvDst, GCVirtSrc, cb));
    21652166
    2166     if (!VM_IS_EMT(pVM))
     2167    PVMCPU pVCpu = VMMGetCpu(pVM);
     2168    if (!pVCpu)
    21672169        return VERR_ACCESS_DENIED;
    21682170#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     
    21702172#endif
    21712173
    2172     int rc = PGMPhysSimpleReadGCPtr(VMMGetCpu(pVM), pvDst, GCVirtSrc, cb);
     2174    int rc = PGMPhysSimpleReadGCPtr(pVCpu, pvDst, GCVirtSrc, cb);
    21732175
    21742176    LogFlow(("pdmR3DevHlp_PhysReadGCVirt: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
     
    21872189             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCVirtDst, pvSrc, cb));
    21882190
    2189     if (!VM_IS_EMT(pVM))
     2191    PVMCPU pVCpu = VMMGetCpu(pVM);
     2192    if (!pVCpu)
    21902193        return VERR_ACCESS_DENIED;
    21912194#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     
    21932196#endif
    21942197
    2195     int rc = PGMPhysSimpleWriteGCPtr(VMMGetCpu(pVM), GCVirtDst, pvSrc, cb);
     2198    int rc = PGMPhysSimpleWriteGCPtr(pVCpu, GCVirtDst, pvSrc, cb);
    21962199
    21972200    LogFlow(("pdmR3DevHlp_PhysWriteGCVirt: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
     
    22102213             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPtr, pGCPhys));
    22112214
    2212     if (!VM_IS_EMT(pVM))
     2215    PVMCPU pVCpu = VMMGetCpu(pVM);
     2216    if (!pVCpu)
    22132217        return VERR_ACCESS_DENIED;
    22142218#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     
    22162220#endif
    22172221
    2218     int rc = PGMPhysGCPtr2GCPhys(VMMGetCpu(pVM), GCPtr, pGCPhys);
     2222    int rc = PGMPhysGCPtr2GCPhys(pVCpu, GCPtr, pGCPhys);
    22192223
    22202224    LogFlow(("pdmR3DevHlp_PhysGCPtr2GCPhys: caller='%s'/%d: returns %Rrc *pGCPhys=%RGp\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc, *pGCPhys));
     
    22562260    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
    22572261    LogFlow(("pdmR3DevHlp_A20Set: caller='%s'/%d: fEnable=%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, fEnable));
    2258     //Assert(*(unsigned *)&fEnable <= 1);
    22592262    PGMR3PhysSetA20(VMMGetCpu(pDevIns->Internal.s.pVMR3), fEnable);
    22602263}
     
    25312534{
    25322535    PDMDEV_ASSERT_DEVINS(pDevIns);
     2536    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
     2537
    25332538    LogFlow(("pdmR3DevHlp_GetCpuId: caller='%s'/%d: iLeaf=%d pEax=%p pEbx=%p pEcx=%p pEdx=%p\n",
    25342539             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, iLeaf, pEax, pEbx, pEcx, pEdx));
  • trunk/src/VBox/VMM/PDMDevMiscHlp.cpp

    r19217 r19293  
    226226{
    227227    PDMDEV_ASSERT_DEVINS(pDevIns);
     228    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
    228229    return VMMGetCpuId(pDevIns->Internal.s.pVMR3);
    229230}
  • trunk/src/VBox/VMM/VM.cpp

    r19267 r19293  
    18701870    }
    18711871
    1872     /* 
     1872    /*
    18731873     * Now all queued VCPU requests (again, there shouldn't be any).
    18741874     */
     
    33173317
    33183318/**
    3319  * Returns the VMCPU id of the current EMT thread.
     3319 * Gets the ID virtual of the virtual CPU assoicated with the calling thread.
     3320 *
     3321 * @returns The CPU ID. NIL_VMCPUID if the thread isn't an EMT.
    33203322 *
    33213323 * @param   pVM             The VM handle.
    3322  * @thread  EMT
    33233324 */
    33243325VMMR3DECL(RTCPUID) VMR3GetVMCPUId(PVM pVM)
    33253326{
    33263327    PUVMCPU pUVCpu = (PUVMCPU)RTTlsGet(pVM->pUVM->vm.s.idxTLS);
    3327 
    3328     AssertMsg(pUVCpu, ("RTTlsGet %d failed!\n", pVM->pUVM->vm.s.idxTLS));
    3329     return pUVCpu->idCpu;
     3328    return pUVCpu
     3329         ? pUVCpu->idCpu
     3330         : NIL_VMCPUID;
    33303331}
    33313332
  • trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp

    r19262 r19293  
    6969    Assert(pVM);
    7070    PVMCPU pVCpu = VMMGetCpu(pVM);
     71    Assert(pVCpu);
    7172
    7273    /*
     
    223224#else
    224225    PVM pVM = pCritSect->s.CTX_SUFF(pVM);
    225     Assert(pVM);
     226    Assert(pVM); Assert(VMMGetCpu(pVM));
    226227    return pCritSect->s.Core.NativeThreadOwner == VMMGetCpu(pVM)->hNativeThread;
    227228#endif
  • trunk/src/VBox/VMM/VMMAll/VMMAll.cpp

    r19228 r19293  
    4848
    4949/**
    50  * Gets the current virtual CPU ID.
     50 * Gets the ID virtual of the virtual CPU assoicated with the calling thread.
    5151 *
    52  * @returns The CPU ID.
     52 * @returns The CPU ID. NIL_VMCPUID if the thread isn't an EMT.
     53 *
    5354 * @param   pVM         Pointer to the shared VM handle.
    54  * @thread  EMT
    5555 */
    5656VMMDECL(VMCPUID) VMMGetCpuId(PVM pVM)
    5757{
    58 #ifdef IN_RING3
    59     /* Only emulation thread(s) allowed to ask for CPU id */
    60     if (!VM_IS_EMT(pVM))
    61         return 0;
    62 #endif
     58#if defined(IN_RING3)
     59    return VMR3GetVMCPUId(pVM);
    6360
    64     /* Only emulation thread(s) allowed to ask for CPU id */
     61#elif defined(IN_RING0)
     62    /* ASSUME that only EMTs calls this function in R0. */
    6563    VM_ASSERT_EMT(pVM);
    66 
    67     /* Shortcut for one CPU */
    6864    if (pVM->cCPUs == 1)
    6965        return 0;
     66    return HWACCMR0GetVMCPUId(pVM);
    7067
    71 #if defined(IN_RING3)
    72     return VMR3GetVMCPUId(pVM);
    73 #elif defined(IN_RING0)
    74     return HWACCMR0GetVMCPUId(pVM);
    75 #endif /* IN_RING0 */
    76 
    77     AssertFailed();
     68#else /* RC: Always EMT(0) */
    7869    return 0;
     70#endif
    7971}
    8072
     73
    8174/**
    82  * Returns the VMCPU of the current EMT thread.
     75 * Returns the VMCPU of the calling EMT.
    8376 *
    84  * @returns The VMCPU pointer.
     77 * @returns The VMCPU pointer. NULL if not an EMT.
     78 *
    8579 * @param   pVM         The VM to operate on.
    8680 */
     
    8882{
    8983#ifdef IN_RING3
    90     /* Only emulation thread(s) allowed to ask for CPU id */
    91     if (!VM_IS_EMT(pVM))
    92         return &pVM->aCpus[0];
    93 #endif
    94     /* Only emulation thread(s) allowed to ask for CPU id */
     84    VMCPUID idCpu = VMR3GetVMCPUId(pVM);
     85    if (idCpu == NIL_VMCPUID)
     86        return NULL;
     87    Assert(idCpu < pVM->cCPUs);
     88    return &pVM->aCpus[VMR3GetVMCPUId(pVM)];
     89
     90#elif defined(IN_RING0)
     91    /* ASSUME that only EMTs calls this function in R0. */
    9592    VM_ASSERT_EMT(pVM);
    96 
    97     /* Shortcut for one CPU */
    9893    if (pVM->cCPUs == 1)
    9994        return &pVM->aCpus[0];
     95    return HWACCMR0GetVMCPU(pVM);
    10096
    101 #ifdef IN_RING3
    102     return &pVM->aCpus[VMR3GetVMCPUId(pVM)];
    103 #elif defined(IN_RING0)
    104     return HWACCMR0GetVMCPU(pVM);
     97#else /* RC: Always EMT(0) */
     98    return &pVM->aCpus[0];
    10599#endif /* IN_RING0 */
     100}
    106101
    107     AssertFailed();
    108     return &pVM->aCpus[0];
    109 }
    110102
    111103/**
     
    121113}
    122114
     115
    123116/**
    124117 * Returns the VMCPU of the specified virtual CPU.
    125118 *
    126  * @returns The VMCPU pointer.
     119 * @returns The VMCPU pointer. NULL if idCpu is invalid.
     120 *
    127121 * @param   pVM         The VM to operate on.
     122 * @param   idCpu       The ID of the virtual CPU.
    128123 */
    129 VMMDECL(PVMCPU) VMMGetCpuEx(PVM pVM, RTCPUID idCpu)
     124VMMDECL(PVMCPU) VMMGetCpuById(PVM pVM, RTCPUID idCpu)
    130125{
    131126    AssertReturn(idCpu < pVM->cCPUs, NULL);
    132127    return &pVM->aCpus[idCpu];
    133128}
     129
    134130
    135131/**
     
    146142}
    147143
     144
    148145/**
    149146 * Queries the current switcher
     
    156153    return pVM->vmm.s.enmSwitcher;
    157154}
     155
  • trunk/src/VBox/VMM/VMMGuruMeditation.cpp

    r19291 r19293  
    324324                /* Disassemble the instruction. */
    325325                char szInstr[256];
    326                 rc2 = DBGFR3DisasInstrEx(pVM, pVCpu, 0, 0, DBGF_DISAS_FLAGS_CURRENT_HYPER, &szInstr[0], sizeof(szInstr), NULL);
     326                rc2 = DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, 0, 0, DBGF_DISAS_FLAGS_CURRENT_HYPER, &szInstr[0], sizeof(szInstr), NULL);
    327327                if (RT_SUCCESS(rc2))
    328328                    pHlp->pfnPrintf(pHlp,
  • trunk/src/recompiler_new/VBoxREMWrapper.cpp

    r19141 r19293  
    557557{
    558558    { REMPARMDESC_FLAGS_INT,        sizeof(PVM), NULL },
    559     { REMPARMDESC_FLAGS_INT,        sizeof(PVMCPU), NULL },
     559    { REMPARMDESC_FLAGS_INT,        sizeof(VMCPUID), NULL },
    560560    { REMPARMDESC_FLAGS_INT,        sizeof(RTSEL), NULL },
    561561    { REMPARMDESC_FLAGS_INT,        sizeof(RTGCPTR), NULL },
  • trunk/src/recompiler_new/VBoxRecompiler.c

    r19141 r19293  
    13931393        return false;
    13941394    }
    1395    
     1395
    13961396    Assert(env->pVCpu && PGMPhysIsA20Enabled(env->pVCpu));
    13971397    *piException = EXCP_EXECUTE_RAW;
     
    37093709            uint32_t    cbInstr;
    37103710            int rc = DBGFR3DisasInstrEx(pVM,
    3711                                         pVCpu,
     3711                                        pVCpu->idCpu,
    37123712                                        cs,
    37133713                                        eip,
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