VirtualBox

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


Ignore:
Timestamp:
Feb 26, 2010 2:30:43 PM (15 years ago)
Author:
vboxsync
Message:

Introduced EMInterpretInstructionCPUEx to allow user-level instruction emulation.

File:
1 edited

Legend:

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

    r26273 r26855  
    7979*   Internal Functions                                                         *
    8080*******************************************************************************/
    81 DECLINLINE(int) emInterpretInstructionCPU(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize);
     81DECLINLINE(int) emInterpretInstructionCPU(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize, EMCODETYPE enmCodeType = EMCODETYPE_SUPERVISOR);
    8282
    8383
     
    360360 * @param   pvFault     The fault address (CR2).
    361361 * @param   pcbSize     Size of the write (if applicable).
     362 * @param   enmCodeType Code type (user/supervisor)
    362363 *
    363364 * @remark  Invalid opcode exceptions have a higher priority than GP (see Intel
     
    368369 *          Make sure this can't happen!! (will add some assertions/checks later)
    369370 */
    370 VMMDECL(int) EMInterpretInstructionCPU(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize)
     371VMMDECL(int) EMInterpretInstructionCPUEx(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize, EMCODETYPE enmCodeType)
    371372{
    372373    STAM_PROFILE_START(&pVCpu->em.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,Emulate), a);
    373     int rc = emInterpretInstructionCPU(pVM, pVCpu, pDis, pRegFrame, pvFault, pcbSize);
     374    int rc = emInterpretInstructionCPU(pVM, pVCpu, pDis, pRegFrame, pvFault, pcbSize, enmCodeType);
    374375    STAM_PROFILE_STOP(&pVCpu->em.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,Emulate), a);
    375376    if (RT_SUCCESS(rc))
     
    31503151 * @copydoc EMInterpretInstructionCPU
    31513152 */
    3152 DECLINLINE(int) emInterpretInstructionCPU(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize)
    3153 {
     3153DECLINLINE(int) emInterpretInstructionCPU(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize, EMCODETYPE enmCodeType)
     3154{
     3155    Assert(enmCodeType == EMCODETYPE_SUPERVISOR || enmCodeType == EMCODETYPE_ALL);
    31543156    Assert(pcbSize);
    31553157    *pcbSize = 0;
    31563158
    3157     /*
    3158      * Only supervisor guest code!!
    3159      * And no complicated prefixes.
    3160      */
    3161     /* Get the current privilege level. */
    3162     uint32_t cpl = CPUMGetGuestCPL(pVCpu, pRegFrame);
    3163     if (    cpl != 0
    3164         &&  pDis->pCurInstr->opcode != OP_RDTSC)    /* rdtsc requires emulation in ring 3 as well */
    3165     {
    3166         Log(("WARNING: refusing instruction emulation for user-mode code!!\n"));
    3167         STAM_COUNTER_INC(&pVCpu->em.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,FailedUserMode));
    3168         return VERR_EM_INTERPRETER;
    3169     }
     3159    if (enmCodeType == EMCODETYPE_SUPERVISOR)
     3160    {
     3161        /*
     3162         * Only supervisor guest code!!
     3163         * And no complicated prefixes.
     3164         */
     3165        /* Get the current privilege level. */
     3166        uint32_t cpl = CPUMGetGuestCPL(pVCpu, pRegFrame);
     3167        if (    cpl != 0
     3168            &&  pDis->pCurInstr->opcode != OP_RDTSC)    /* rdtsc requires emulation in ring 3 as well */
     3169        {
     3170            Log(("WARNING: refusing instruction emulation for user-mode code!!\n"));
     3171            STAM_COUNTER_INC(&pVCpu->em.s.CTX_SUFF(pStats)->CTX_MID_Z(Stat,FailedUserMode));
     3172            return VERR_EM_INTERPRETER;
     3173        }
     3174    }
     3175    else
     3176        Log2(("emInterpretInstructionCPU allowed to interpret user-level code!!\n"));
    31703177
    31713178#ifdef IN_RC
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