VirtualBox

Changeset 97370 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Nov 2, 2022 12:53:30 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154368
Message:

VMM/IEM: iemRegAddToRipAndClearRF -> iemRegUpdateRipAndFinishClearingRF and made callers use the return code. bugref:9898

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/IEMInline.h

    r97358 r97370  
    16141614 * @param   cbInstr             The number of bytes to add.
    16151615 */
    1616 DECLINLINE(VBOXSTRICTRC) iemRegAddToRipAndClearRF(PVMCPUCC pVCpu, uint8_t cbInstr)
     1616DECLINLINE(VBOXSTRICTRC) iemRegAddToRipAndFinishingClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr)
    16171617{
    16181618    /*
     
    16471647
    16481648/**
     1649 * Extended version of iemRegAddToRipAndFinishingClearingRF for use by POPF and
     1650 * others potentially updating EFLAGS.TF.
     1651 *
     1652 * The single step event must be generated using the TF value at the start of
     1653 * the instruction, not the new value set by it.
     1654 *
     1655 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
     1656 * @param   cbInstr             The number of bytes to add.
     1657 * @param   fEflOld             The EFLAGS at the start of the instruction
     1658 *                              execution.
     1659 */
     1660DECLINLINE(VBOXSTRICTRC) iemRegAddToRipAndFinishingClearingRfEx(PVMCPUCC pVCpu, uint8_t cbInstr, uint32_t fEflOld)
     1661{
     1662    /*
     1663     * Advance RIP.
     1664     *
     1665     * When we're targetting 8086/8, 80186/8 or 80286 mode the updates are 16-bit,
     1666     * while in all other modes except LM64 the updates are 32-bit.  This means
     1667     * we need to watch for both 32-bit and 16-bit "carry" situations, i.e.
     1668     * 4GB and 64KB rollovers, and decide whether anything needs masking.
     1669     *
     1670     * See PC wrap around tests in bs3-cpu-weird-1.
     1671     */
     1672    uint64_t const uRipPrev = pVCpu->cpum.GstCtx.rip;
     1673    uint64_t const uRipNext = uRipPrev + cbInstr;
     1674    if (RT_LIKELY(   !((uRipNext ^ uRipPrev) & (RT_BIT_64(32) | RT_BIT_64(16)))
     1675                  || CPUMIsGuestIn64BitCodeEx(&pVCpu->cpum.GstCtx)))
     1676        pVCpu->cpum.GstCtx.rip = uRipNext;
     1677    else if (IEM_GET_TARGET_CPU(pVCpu) >= IEMTARGETCPU_386)
     1678        pVCpu->cpum.GstCtx.rip = (uint32_t)uRipNext;
     1679    else
     1680        pVCpu->cpum.GstCtx.rip = (uint16_t)uRipNext;
     1681
     1682    /*
     1683     * Clear RF and interrupt shadowing.
     1684     */
     1685    AssertCompile(CPUMCTX_INHIBIT_SHADOW < UINT32_MAX);
     1686    pVCpu->cpum.GstCtx.eflags.uBoth &= ~(X86_EFL_RF | CPUMCTX_INHIBIT_SHADOW);
     1687
     1688    RT_NOREF(fEflOld);
     1689    return VINF_SUCCESS;
     1690}
     1691
     1692
     1693/**
    16491694 * Updates the RIP/EIP/IP to point to the next instruction and clears EFLAGS.RF.
    16501695 *
    16511696 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
    16521697 */
    1653 DECLINLINE(VBOXSTRICTRC) iemRegUpdateRipAndClearRF(PVMCPUCC pVCpu)
    1654 {
    1655     return iemRegAddToRipAndClearRF(pVCpu, IEM_GET_INSTR_LEN(pVCpu));
     1698DECLINLINE(VBOXSTRICTRC) iemRegUpdateRipAndFinishClearingRF(PVMCPUCC pVCpu)
     1699{
     1700    return iemRegAddToRipAndFinishingClearingRF(pVCpu, IEM_GET_INSTR_LEN(pVCpu));
    16561701}
    16571702
  • trunk/src/VBox/VMM/include/IEMMc.h

    r97358 r97370  
    5555/** Advances RIP, finishes the instruction and returns.
    5656 * This may include raising debug exceptions and such. */
    57 #define IEM_MC_ADVANCE_RIP_AND_FINISH()                 return iemRegUpdateRipAndClearRF(pVCpu)
     57#define IEM_MC_ADVANCE_RIP_AND_FINISH()                 return iemRegUpdateRipAndFinishClearingRF(pVCpu)
    5858/** Sets RIP (may trigger \#GP), finishes the instruction and returns. */
    5959#define IEM_MC_REL_JMP_S8_AND_FINISH(a_i8)              return iemRegRipRelativeJumpS8(pVCpu, (a_i8))
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette