VirtualBox

Changeset 62257 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 14, 2016 2:54:37 PM (9 years ago)
Author:
vboxsync
Message:

IEM: Fix missing read cleanup in retf to different level code path. Cleaned up the pop memory interface a little.

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

Legend:

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

    r62246 r62257  
    99069906 * @returns Strict VBox status code.
    99079907 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
    9908  * @param   cbMem               The number of bytes to push onto the stack.
     9908 * @param   cbMem               The number of bytes to pop from the stack.
    99099909 * @param   ppvMem              Where to return the pointer to the stack memory.
    99109910 * @param   puNewRsp            Where to return the new RSP value.  This must be
    9911  *                              passed unchanged to
    9912  *                              iemMemStackPopCommitSpecial() or applied
    9913  *                              manually if iemMemStackPopDoneSpecial() is used.
     9911 *                              assigned to CPUMCTX::rsp manually some time
     9912 *                              after iemMemStackPopDoneSpecial() has been
     9913 *                              called.
    99149914 */
    99159915IEM_STATIC VBOXSTRICTRC iemMemStackPopBeginSpecial(PVMCPU pVCpu, size_t cbMem, void const **ppvMem, uint64_t *puNewRsp)
     
    99299929 * @returns Strict VBox status code.
    99309930 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
    9931  * @param   cbMem               The number of bytes to push onto the stack.
     9931 * @param   cbMem               The number of bytes to pop from the stack.
    99329932 * @param   ppvMem              Where to return the pointer to the stack memory.
    99339933 * @param   puNewRsp            Where to return the new RSP value.  This must be
    9934  *                              passed unchanged to
    9935  *                              iemMemStackPopCommitSpecial() or applied
    9936  *                              manually if iemMemStackPopDoneSpecial() is used.
     9934 *                              assigned to CPUMCTX::rsp manually some time
     9935 *                              after iemMemStackPopDoneSpecial() has been
     9936 *                              called.
    99379937 */
    99389938IEM_STATIC VBOXSTRICTRC iemMemStackPopContinueSpecial(PVMCPU pVCpu, size_t cbMem, void const **ppvMem, uint64_t *puNewRsp)
    99399939{
    99409940    Assert(cbMem < UINT8_MAX);
    9941     PCPUMCTX    pCtx     = IEM_GET_CTX(pVCpu);
     9941    PCPUMCTX    pCtx = IEM_GET_CTX(pVCpu);
    99429942    RTUINT64U   NewRsp;
    99439943    NewRsp.u = *puNewRsp;
     
    99459945    *puNewRsp = NewRsp.u;
    99469946    return iemMemMap(pVCpu, (void **)ppvMem, cbMem, X86_SREG_SS, GCPtrTop, IEM_ACCESS_STACK_R);
    9947 }
    9948 
    9949 
    9950 /**
    9951  * Commits a special stack pop (started by iemMemStackPopBeginSpecial).
    9952  *
    9953  * This will update the rSP.
    9954  *
    9955  * @returns Strict VBox status code.
    9956  * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
    9957  * @param   pvMem               The pointer returned by
    9958  *                              iemMemStackPopBeginSpecial().
    9959  * @param   uNewRsp             The new RSP value returned by
    9960  *                              iemMemStackPopBeginSpecial().
    9961  */
    9962 IEM_STATIC VBOXSTRICTRC iemMemStackPopCommitSpecial(PVMCPU pVCpu, void const *pvMem, uint64_t uNewRsp)
    9963 {
    9964     VBOXSTRICTRC rcStrict = iemMemCommitAndUnmap(pVCpu, (void *)pvMem, IEM_ACCESS_STACK_R);
    9965     if (rcStrict == VINF_SUCCESS)
    9966         IEM_GET_CTX(pVCpu)->rsp = uNewRsp;
    9967     return rcStrict;
    99689947}
    99699948
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h

    r62171 r62257  
    21622162        uNewCs  = uPtrFrame.pu16[4];
    21632163    }
     2164    rcStrict = iemMemStackPopDoneSpecial(pVCpu, uPtrFrame.pv);
     2165    if (RT_LIKELY(rcStrict == VINF_SUCCESS))
     2166    { /* extremely likely */ }
     2167    else
     2168        return rcStrict;
    21642169
    21652170    /*
     
    21792184
    21802185        /* commit the operation. */
    2181         rcStrict = iemMemStackPopCommitSpecial(pVCpu, uPtrFrame.pv, uNewRsp);
    2182         if (rcStrict != VINF_SUCCESS)
    2183             return rcStrict;
     2186        pCtx->rsp           = uNewRsp;
    21842187        pCtx->rip           = uNewRip;
    21852188        pCtx->cs.Sel        = uNewCs;
     
    22662269    {
    22672270        /* Read the outer stack pointer stored *after* the parameters. */
    2268         RTCPTRUNION uPtrStack;
    2269         rcStrict = iemMemStackPopContinueSpecial(pVCpu, cbPop + cbRetPtr, &uPtrStack.pv, &uNewRsp);
     2271        rcStrict = iemMemStackPopContinueSpecial(pVCpu, cbPop + cbRetPtr, &uPtrFrame.pv, &uNewRsp);
    22702272        if (rcStrict != VINF_SUCCESS)
    22712273            return rcStrict;
    22722274
    2273         uPtrStack.pu8 += cbPop; /* Skip the parameters. */
     2275        uPtrFrame.pu8 += cbPop; /* Skip the parameters. */
    22742276
    22752277        uint16_t uNewOuterSs;
     
    22772279        if (enmEffOpSize == IEMMODE_16BIT)
    22782280        {
    2279             uNewOuterRsp = uPtrStack.pu16[0];
    2280             uNewOuterSs  = uPtrStack.pu16[1];
     2281            uNewOuterRsp = uPtrFrame.pu16[0];
     2282            uNewOuterSs  = uPtrFrame.pu16[1];
    22812283        }
    22822284        else if (enmEffOpSize == IEMMODE_32BIT)
    22832285        {
    2284             uNewOuterRsp = uPtrStack.pu32[0];
    2285             uNewOuterSs  = uPtrStack.pu16[2];
     2286            uNewOuterRsp = uPtrFrame.pu32[0];
     2287            uNewOuterSs  = uPtrFrame.pu16[2];
    22862288        }
    22872289        else
    22882290        {
    2289             uNewOuterRsp = uPtrStack.pu64[0];
    2290             uNewOuterSs  = uPtrStack.pu16[4];
    2291         }
     2291            uNewOuterRsp = uPtrFrame.pu64[0];
     2292            uNewOuterSs  = uPtrFrame.pu16[4];
     2293        }
     2294        rcStrict = iemMemStackPopDoneSpecial(pVCpu, uPtrFrame.pv);
     2295        if (RT_LIKELY(rcStrict == VINF_SUCCESS))
     2296        { /* extremely likely */ }
     2297        else
     2298            return rcStrict;
    22922299
    22932300        /* Check for NULL stack selector (invalid in ring-3 and non-long mode)
     
    24112418
    24122419        /* commit */
    2413         rcStrict = iemMemStackPopCommitSpecial(pVCpu, uPtrFrame.pv, uNewRsp);
    2414         if (rcStrict != VINF_SUCCESS)
    2415             return rcStrict;
     2420        pCtx->rsp               = uNewRsp;
    24162421        if (enmEffOpSize == IEMMODE_16BIT)
    24172422            pCtx->rip           = uNewRip & UINT16_MAX; /** @todo Testcase: When exactly does this occur? With call it happens prior to the limit check according to Intel... */
     
    24982503
    24992504        /* commit */
    2500         rcStrict = iemMemStackPopCommitSpecial(pVCpu, uPtrFrame.pv, uNewRsp);
    2501         if (rcStrict != VINF_SUCCESS)
    2502             return rcStrict;
     2505        pCtx->rsp           = uNewRsp;
    25032506        if (enmEffOpSize == IEMMODE_16BIT)
    25042507            pCtx->rip       = uNewRip & UINT16_MAX; /** @todo Testcase: When exactly does this occur? With call it happens prior to the limit check according to Intel... */
     
    28622865            uNewFlags &= ~(X86_EFL_NT | X86_EFL_IOPL);
    28632866    }
     2867    rcStrict = iemMemStackPopDoneSpecial(pVCpu, uFrame.pv);
     2868    if (RT_LIKELY(rcStrict == VINF_SUCCESS))
     2869    { /* extremely likely */ }
     2870    else
     2871        return rcStrict;
     2872
    28642873    /** @todo Check how this is supposed to work if sp=0xfffe. */
    28652874    Log7(("iemCImpl_iret_real_v8086: uNewCs=%#06x uNewRip=%#010x uNewFlags=%#x uNewRsp=%#18llx\n",
     
    29042913     * Commit the operation.
    29052914     */
    2906     rcStrict = iemMemStackPopCommitSpecial(pVCpu, uFrame.pv, uNewRsp);
    2907     if (rcStrict != VINF_SUCCESS)
    2908         return rcStrict;
    29092915#ifdef DBGFTRACE_ENABLED
    29102916    RTTraceBufAddMsgF(pVCpu->CTX_SUFF(pVM)->CTX_SUFF(hTraceBuf), "iret/rm %04x:%04x -> %04x:%04x %x %04llx",
    29112917                      pCtx->cs.Sel, pCtx->eip, uNewCs, uNewEip, uNewFlags, uNewRsp);
    29122918#endif
    2913 
     2919    pCtx->rsp           = uNewRsp;
    29142920    pCtx->rip           = uNewEip;
    29152921    pCtx->cs.Sel        = uNewCs;
     
    31233129        uNewFlags  = uFrame.pu16[2];
    31243130    }
    3125     rcStrict = iemMemCommitAndUnmap(pVCpu, (void *)uFrame.pv, IEM_ACCESS_STACK_R); /* don't use iemMemStackPopCommitSpecial here. */
    3126     if (rcStrict != VINF_SUCCESS)
     3131    rcStrict = iemMemStackPopDoneSpecial(pVCpu, (void *)uFrame.pv); /* don't use iemMemStackPopCommitSpecial here. */
     3132    if (RT_LIKELY(rcStrict == VINF_SUCCESS))
     3133    { /* extremely likely */ }
     3134    else
    31273135        return rcStrict;
    31283136    Log7(("iemCImpl_iret_prot: uNewCs=%#06x uNewEip=%#010x uNewFlags=%#x uNewRsp=%#18llx\n", uNewCs, uNewEip, uNewFlags, uNewRsp));
     
    35203528        uNewSs     = uFrame.pu16[4];
    35213529    }
    3522     rcStrict = iemMemCommitAndUnmap(pVCpu, (void *)uFrame.pv, IEM_ACCESS_STACK_R); /* don't use iemMemStackPopCommitSpecial here. */
    3523     if (rcStrict != VINF_SUCCESS)
     3530    rcStrict = iemMemStackPopDoneSpecial(pVCpu, (void *)uFrame.pv); /* don't use iemMemStackPopCommitSpecial here. */
     3531    if (RT_LIKELY(rcStrict == VINF_SUCCESS))
     3532    { /* extremely like */ }
     3533    else
    35243534        return rcStrict;
    35253535    Log7(("iretq stack: cs:rip=%04x:%016RX64 rflags=%016RX64 ss:rsp=%04x:%016RX64\n", uNewCs, uNewRip, uNewFlags, uNewSs, uNewRsp));
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