VirtualBox

Changeset 97466 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Nov 8, 2022 10:32:34 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154476
Message:

VMM/IEM: Wrap the the longjmp calls in a macro both to shorten the code and also make it possbile to replace it with a throw if we desire. bugref:9898

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

Legend:

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

    r97458 r97466  
    858858            int rc = PGMPhysIemGCPhys2PtrNoLock(pVCpu->CTX_SUFF(pVM), pVCpu, pTlbe->GCPhys, &pVCpu->iem.s.CodeTlb.uTlbPhysRev,
    859859                                                &pTlbe->pbMappingR3, &pTlbe->fFlagsAndPhysRev);
    860             AssertRCStmt(rc, longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), rc));
     860            AssertRCStmt(rc, IEM_DO_LONGJMP(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), rc));
    861861        }
    862862
     
    914914                     GCPtrNext, GCPhys, VBOXSTRICTRC_VAL(rcStrict), cbToTryRead));
    915915                rcStrict = iemSetPassUpStatus(pVCpu, rcStrict);
    916                 AssertStmt(rcStrict == VINF_SUCCESS, longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), VBOXSTRICRC_VAL(rcStrict)));
     916                AssertStmt(rcStrict == VINF_SUCCESS, IEM_DO_LONGJMP(pVCpu, VBOXSTRICRC_VAL(rcStrict)));
    917917            }
    918918            else
     
    922922                     : "iemOpcodeFetchMoreBytes: %RGv/%RGp LB %#x - read error - rcStrict=%Rrc (!!)\n",
    923923                     GCPtrNext, GCPhys, VBOXSTRICTRC_VAL(rcStrict), cbToTryRead));
    924                 longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     924                IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    925925            }
    926926        }
     
    943943                     GCPtrFirst, pTlbe->GCPhys + (GCPtrFirst & X86_PAGE_OFFSET_MASK), VBOXSTRICTRC_VAL(rcStrict), cbToRead));
    944944                rcStrict = iemSetPassUpStatus(pVCpu, rcStrict);
    945                 AssertStmt(rcStrict == VINF_SUCCESS, longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), VBOXSTRICTRC_VAL(rcStrict)));
     945                AssertStmt(rcStrict == VINF_SUCCESS, IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict)));
    946946            }
    947947            else
     
    951951                     : "iemOpcodeFetchMoreBytes: %RGv/%RGp LB %#x - read error - rcStrict=%Rrc (!!)\n",
    952952                     GCPtrFirst, pTlbe->GCPhys + (GCPtrFirst & X86_PAGE_OFFSET_MASK), VBOXSTRICTRC_VAL(rcStrict), cbToRead));
    953                 longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     953                IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    954954            }
    955955            pVCpu->iem.s.offInstrNextByte = offBuf + cbToRead;
     
    966966#else
    967967    RT_NOREF(pvDst, cbDst);
    968     longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), VERR_INTERNAL_ERROR);
     968    IEM_DO_LONGJMP(pVCpu, VERR_INTERNAL_ERROR);
    969969#endif
    970970}
     
    11521152    if (rcStrict == VINF_SUCCESS)
    11531153        return pVCpu->iem.s.abOpcode[pVCpu->iem.s.offOpcode++];
    1154     longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     1154    IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    11551155# endif
    11561156}
     
    12661266#  endif
    12671267    }
    1268     longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     1268    IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    12691269# endif
    12701270}
     
    13781378#  endif
    13791379    }
    1380     longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     1380    IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    13811381# endif
    13821382}
     
    15041504#  endif
    15051505    }
    1506     longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     1506    IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    15071507# endif
    15081508}
     
    39113911{
    39123912    VBOXSTRICTRC rcStrict = iemRaiseXcptOrInt(pVCpu, cbInstr, u8Vector, fFlags, uErr, uCr2);
    3913     longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     3913    IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    39143914}
    39153915#endif
     
    41594159DECL_NO_RETURN(void) iemRaisePageFaultJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrWhere, uint32_t fAccess, int rc) IEM_NOEXCEPT_MAY_LONGJMP
    41604160{
    4161     longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), VBOXSTRICTRC_VAL(iemRaisePageFault(pVCpu, GCPtrWhere, fAccess, rc)));
     4161    IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(iemRaisePageFault(pVCpu, GCPtrWhere, fAccess, rc)));
    41624162}
    41634163#endif
     
    41864186DECL_NO_RETURN(void) iemRaiseAlignmentCheckExceptionJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP
    41874187{
    4188     longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), VBOXSTRICTRC_VAL(iemRaiseAlignmentCheckException(pVCpu)));
     4188    IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(iemRaiseAlignmentCheckException(pVCpu)));
    41894189}
    41904190#endif
     
    61596159        int rc = PGMPhysIemGCPhys2PtrNoLock(pVCpu->CTX_SUFF(pVM), pVCpu, pTlbe->GCPhys, &pVCpu->iem.s.DataTlb.uTlbPhysRev,
    61606160                                            &pbMem, &pTlbe->fFlagsAndPhysRev);
    6161         AssertRCStmt(rc, longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), rc));
     6161        AssertRCStmt(rc, IEM_DO_LONGJMP(pVCpu, rc));
    61626162# ifdef IN_RING3
    61636163        pTlbe->pbMappingR3 = pbMem;
     
    63156315    VBOXSTRICTRC rcStrict = iemMemApplySegment(pVCpu, fAccess, iSegReg, cbMem, &GCPtrMem);
    63166316    if (rcStrict == VINF_SUCCESS) { /*likely*/ }
    6317     else longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     6317    else IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    63186318
    63196319    /*
     
    63596359                             pVCpu->iem.s.aMemMappings[0].fAccess, pVCpu->iem.s.aMemMappings[1].fAccess,
    63606360                             pVCpu->iem.s.aMemMappings[2].fAccess),
    6361                             longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VERR_IEM_IPE_9));
     6361                            IEM_DO_LONGJMP(pVCpu, VERR_IEM_IPE_9));
    63626362    }
    63636363
     
    63736373        if (rcStrict == VINF_SUCCESS)
    63746374            return pvMem;
    6375         longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     6375        IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    63766376    }
    63776377
     
    64896489            int rc = PGMPhysIemGCPhys2PtrNoLock(pVCpu->CTX_SUFF(pVM), pVCpu, pTlbe->GCPhys, &pVCpu->iem.s.DataTlb.uTlbPhysRev,
    64906490                                                &pbMem, &pTlbe->fFlagsAndPhysRev);
    6491             AssertRCStmt(rc, longjmp(*CTX_SUFF(pVCpu->iem.s.pJmpBuf), rc));
     6491            AssertRCStmt(rc, IEM_DO_LONGJMP(pVCpu, rc));
    64926492# ifdef IN_RING3
    64936493            pTlbe->pbMappingR3 = pbMem;
     
    65096509            if (rcStrict == VINF_SUCCESS)
    65106510                return pbMem;
    6511             longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     6511            IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    65126512        }
    65136513    }
     
    65276527        if (rcStrict == VINF_SUCCESS)
    65286528            return pbMem;
    6529         longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     6529        IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    65306530    }
    65316531
     
    65436543    rcStrict = iemMemPageTranslateAndCheckAccess(pVCpu, GCPtrMem, fAccess, &GCPhysFirst);
    65446544    if (rcStrict == VINF_SUCCESS) { /*likely*/ }
    6545     else longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     6545    else IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    65466546
    65476547    if (fAccess & IEM_ACCESS_TYPE_WRITE)
     
    65596559        if (rcStrict == VINF_SUCCESS)
    65606560            return pvMem;
    6561         longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     6561        IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    65626562    }
    65636563
     
    65876587{
    65886588    int iMemMap = iemMapLookup(pVCpu, pvMem, fAccess);
    6589     AssertStmt(iMemMap >= 0, longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), iMemMap));
     6589    AssertStmt(iMemMap >= 0, IEM_DO_LONGJMP(pVCpu, iMemMap));
    65906590
    65916591    /* If it's bounce buffered, we may need to write back the buffer. */
     
    65976597            if (rcStrict == VINF_SUCCESS)
    65986598                return;
    6599             longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VBOXSTRICTRC_VAL(rcStrict));
     6599            IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(rcStrict));
    66006600        }
    66016601    }
     
    92889288                    case 1:  IEM_OPCODE_GET_NEXT_S8_SX_U16(&u16EffAddr); break;
    92899289                    case 2:  IEM_OPCODE_GET_NEXT_U16(&u16EffAddr);       break;
    9290                     default: AssertFailedStmt(longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VERR_IEM_IPE_1)); /* (caller checked for these) */
     9290                    default: AssertFailedStmt(IEM_DO_LONGJMP(pVCpu, VERR_IEM_IPE_1)); /* (caller checked for these) */
    92919291                }
    92929292
     
    93949394                }
    93959395                default:
    9396                     AssertFailedStmt(longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), VERR_IEM_IPE_2)); /* (caller checked for these) */
     9396                    AssertFailedStmt(IEM_DO_LONGJMP(pVCpu, VERR_IEM_IPE_2)); /* (caller checked for these) */
    93979397            }
    93989398        }
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r97464 r97466  
    6565#if defined(DOXYGEN_RUNNING) || defined(RT_OS_WINDOWS) || 1
    6666# define IEM_WITH_SETJMP
     67#endif
     68
     69/** @def IEM_DO_LONGJMP
     70 *
     71 * Wrapper around longjmp / throw.
     72 *
     73 * @param   a_pVCpu     The CPU handle.
     74 * @param   a_rc        The status code jump back with / throw.
     75 */
     76#if defined(IEM_WITH_SETJMP) || defined(DOXYGEN_RUNNING)
     77# define IEM_DO_LONGJMP(a_pVCpu, a_rc)  longjmp(*(a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf), (a_rc))
    6778#endif
    6879
     
    866877        { \
    867878            int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
    868             AssertRCStmt(rcCtxImport, longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), rcCtxImport)); \
     879            AssertRCStmt(rcCtxImport, IEM_DO_LONGJMP(pVCpu, rcCtxImport)); \
    869880        } \
    870881    } while (0)
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