VirtualBox

Changeset 47748 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Aug 15, 2013 10:41:44 AM (11 years ago)
Author:
vboxsync
Message:

IEM: Some RF adjustments. Verification logging fixes.

File:
1 edited

Legend:

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

    r47744 r47748  
    20202020/** Generated by the breakpoint instruction. */
    20212021#define IEM_XCPT_FLAGS_BP_INSTR         RT_BIT_32(5)
     2022/** Generated by a DRx instruction breakpoint and RF should be cleared. */
     2023#define IEM_XCPT_FLAGS_DRx_INSTR_BP     RT_BIT_32(6)
    20222024/** @}  */
    20232025
     
    24212423    }
    24222424
     2425    /* Calc the flag image to push. */
     2426    uint32_t        fEfl    = IEMMISC_GET_EFL(pIemCpu, pCtx);
     2427    if (fFlags & (IEM_XCPT_FLAGS_DRx_INSTR_BP | IEM_XCPT_FLAGS_T_SOFT_INT))
     2428        fEfl &= ~X86_EFL_RF;
     2429    else if (!IEM_FULL_VERIFICATION_REM_ENABLED(pIemCpu))
     2430        fEfl |= X86_EFL_RF; /* Vagueness is all I've found on this so far... */ /** @todo Automatically pushing EFLAGS.RF. */
     2431
     2432    /* From V8086 mode only go to CPL 0. */
    24232433    uint8_t const   uNewCpl = DescCS.Legacy.Gen.u4Type & X86_SEL_TYPE_CONF
    24242434                            ? pIemCpu->uCpl : DescCS.Legacy.Gen.u2Dpl;
    2425     uint32_t        fEfl    = IEMMISC_GET_EFL(pIemCpu, pCtx);
    2426     if (   !(fFlags & IEM_XCPT_FLAGS_T_SOFT_INT)
    2427         && (u8Vector != X86_XCPT_DE || (fFlags & IEM_XCPT_FLAGS_T_EXT_INT))
    2428         && !IEM_FULL_VERIFICATION_REM_ENABLED(pIemCpu))
    2429         fEfl |= X86_EFL_RF; /* Vagueness is all I've found on this so far... */ /** @todo Automatically pushing EFLAGS.RF. */
    2430 
    2431     /* From V8086 mode only go to CPL 0. */
    24322435    if ((fEfl & X86_EFL_VM) && uNewCpl != 0) /** @todo When exactly is this raised? */
    24332436    {
     
    27832786     */
    27842787    uint64_t        uNewRsp;
    2785     uint32_t        fEfl    = IEMMISC_GET_EFL(pIemCpu, pCtx);
    27862788    uint8_t const   uNewCpl = DescCS.Legacy.Gen.u4Type & X86_SEL_TYPE_CONF
    27872789                            ? pIemCpu->uCpl : DescCS.Legacy.Gen.u2Dpl;
     
    27962798        uNewRsp = pCtx->rsp;
    27972799    uNewRsp &= ~(uint64_t)0xf;
     2800
     2801    /*
     2802     * Calc the flag image to push.
     2803     */
     2804    uint32_t        fEfl    = IEMMISC_GET_EFL(pIemCpu, pCtx);
     2805    if (fFlags & (IEM_XCPT_FLAGS_DRx_INSTR_BP | IEM_XCPT_FLAGS_T_SOFT_INT))
     2806        fEfl &= ~X86_EFL_RF;
     2807    else if (!IEM_FULL_VERIFICATION_REM_ENABLED(pIemCpu))
     2808        fEfl |= X86_EFL_RF; /* Vagueness is all I've found on this so far... */ /** @todo Automatically pushing EFLAGS.RF. */
    27982809
    27992810    /*
     
    91219132                     && VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)
    91229133                     && EMGetInhibitInterruptsPC(pVCpu) == pOrgCtx->rip)
    9123                  || (   pOrgCtx->rip < pDebugCtx->rip
    9124                      && (pDebugCtx->rip - pOrgCtx->rip) < 15)
    9125                      && iLoops < 32);
     9134                 || (   pOrgCtx->rip != pDebugCtx->rip
     9135                     && pIemCpu->uInjectCpl != UINT8_MAX
     9136                     && iLoops < 8) );
    91269137    }
    91279138#endif
     
    94509461
    94519462
     9463#ifdef LOG_ENABLED
     9464/**
     9465 * Logs the current instruction.
     9466 * @param   pVCpu       The cross context virtual CPU structure of the caller.
     9467 * @param   pCtx        The current CPU context.
     9468 * @param   fSameCtx    Set if we have the same context information as the VMM,
     9469 *                      clear if we may have already executed an instruction in
     9470 *                      our debug context. When clear, we assume IEMCPU holds
     9471 *                      valid CPU mode info.
     9472 */
     9473static void iemLogCurInstr(PVMCPU pVCpu, PCPUMCTX pCtx, bool fSameCtx)
     9474{
     9475# ifdef IN_RING3
     9476    if (LogIs2Enabled())
     9477    {
     9478        char     szInstr[256];
     9479        uint32_t cbInstr = 0;
     9480        if (fSameCtx)
     9481            DBGFR3DisasInstrEx(pVCpu->pVMR3->pUVM, pVCpu->idCpu, 0, 0,
     9482                               DBGF_DISAS_FLAGS_CURRENT_GUEST | DBGF_DISAS_FLAGS_DEFAULT_MODE,
     9483                               szInstr, sizeof(szInstr), &cbInstr);
     9484        else
     9485        {
     9486            uint32_t fFlags = 0;
     9487            switch (pVCpu->iem.s.enmCpuMode)
     9488            {
     9489                case IEMMODE_64BIT: fFlags |= DBGF_DISAS_FLAGS_64BIT_MODE; break;
     9490                case IEMMODE_32BIT: fFlags |= DBGF_DISAS_FLAGS_32BIT_MODE; break;
     9491                case IEMMODE_16BIT:
     9492                    if (!(pCtx->cr0 & X86_CR0_PE) || pCtx->eflags.Bits.u1VM)
     9493                        fFlags |= DBGF_DISAS_FLAGS_16BIT_REAL_MODE;
     9494                    else
     9495                        fFlags |= DBGF_DISAS_FLAGS_16BIT_MODE;
     9496                    break;
     9497            }
     9498            DBGFR3DisasInstrEx(pVCpu->pVMR3->pUVM, pVCpu->idCpu, pCtx->cs.Sel, pCtx->rip, fFlags,
     9499                               szInstr, sizeof(szInstr), &cbInstr);
     9500        }
     9501
     9502        Log2(("****\n"
     9503              " eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n"
     9504              " eip=%08x esp=%08x ebp=%08x iopl=%d\n"
     9505              " cs=%04x ss=%04x ds=%04x es=%04x fs=%04x gs=%04x efl=%08x\n"
     9506              " fsw=%04x fcw=%04x ftw=%02x mxcsr=%04x/%04x\n"
     9507              " %s\n"
     9508              ,
     9509              pCtx->eax, pCtx->ebx, pCtx->ecx, pCtx->edx, pCtx->esi, pCtx->edi,
     9510              pCtx->eip, pCtx->esp, pCtx->ebp, pCtx->eflags.Bits.u2IOPL,
     9511              pCtx->cs.Sel, pCtx->ss.Sel, pCtx->ds.Sel, pCtx->es.Sel,
     9512              pCtx->fs.Sel, pCtx->gs.Sel, pCtx->eflags.u,
     9513              pCtx->fpu.FSW, pCtx->fpu.FCW, pCtx->fpu.FTW, pCtx->fpu.MXCSR, pCtx->fpu.MXCSR_MASK,
     9514              szInstr));
     9515
     9516        if (LogIs3Enabled())
     9517            DBGFR3Info(pVCpu->pVMR3->pUVM, "cpumguest", "verbose", NULL);
     9518    }
     9519    else
     9520# endif
     9521        LogFlow(("IEMExecOne: cs:rip=%04x:%08RX64 ss:rsp=%04x:%08RX64 EFL=%06x\n",
     9522                 pCtx->cs.Sel, pCtx->rip, pCtx->ss.Sel, pCtx->rsp, pCtx->eflags.u));
     9523}
     9524#endif
     9525
     9526
    94529527/**
    94539528 * Makes status code addjustments (pass up from I/O and access handler)
     
    95419616        if (rcStrict == VINF_SUCCESS)
    95429617        {
     9618# ifdef LOG_ENABLED
     9619            iemLogCurInstr(IEMCPU_TO_VMCPU(pIemCpu), pIemCpu->CTX_SUFF(pCtx), false);
     9620# endif
    95439621            b; IEM_OPCODE_GET_NEXT_U8(&b);
    95449622            rcStrict = FNIEMOP_CALL(g_apfnOneByteMap[b]);
     
    96029680#ifdef LOG_ENABLED
    96039681    PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx);
    9604 # ifdef IN_RING3
    9605     if (LogIs2Enabled())
    9606     {
    9607         char     szInstr[256];
    9608         uint32_t cbInstr = 0;
    9609         DBGFR3DisasInstrEx(pVCpu->pVMR3->pUVM, pVCpu->idCpu, 0, 0,
    9610                            DBGF_DISAS_FLAGS_CURRENT_GUEST | DBGF_DISAS_FLAGS_DEFAULT_MODE,
    9611                            szInstr, sizeof(szInstr), &cbInstr);
    9612 
    9613         Log2(("**** "
    9614               " eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n"
    9615               " eip=%08x esp=%08x ebp=%08x iopl=%d\n"
    9616               " cs=%04x ss=%04x ds=%04x es=%04x fs=%04x gs=%04x efl=%08x\n"
    9617               " fsw=%04x fcw=%04x ftw=%02x mxcsr=%04x/%04x\n"
    9618               " %s\n"
    9619               ,
    9620               pCtx->eax, pCtx->ebx, pCtx->ecx, pCtx->edx, pCtx->esi, pCtx->edi,
    9621               pCtx->eip, pCtx->esp, pCtx->ebp, pCtx->eflags.Bits.u2IOPL,
    9622               pCtx->cs.Sel, pCtx->ss.Sel, pCtx->ds.Sel, pCtx->es.Sel,
    9623               pCtx->fs.Sel, pCtx->gs.Sel, pCtx->eflags.u,
    9624               pCtx->fpu.FSW, pCtx->fpu.FCW, pCtx->fpu.FTW, pCtx->fpu.MXCSR, pCtx->fpu.MXCSR_MASK,
    9625               szInstr));
    9626 
    9627         if (LogIs3Enabled())
    9628             DBGFR3Info(pVCpu->pVMR3->pUVM, "cpumguest", "verbose", NULL);
    9629     }
    9630     else
    9631 # endif
    9632         LogFlow(("IEMExecOne: cs:rip=%04x:%08RX64 ss:rsp=%04x:%08RX64 EFL=%06x\n",
    9633                  pCtx->cs.Sel, pCtx->rip, pCtx->ss.Sel, pCtx->rsp, pCtx->eflags.u));
     9682    iemLogCurInstr(pVCpu, pCtx, true);
    96349683#endif
    96359684
     
    97629811{
    97639812    PIEMCPU  pIemCpu = &pVCpu->iem.s;
    9764     PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx);
    97659813
    97669814    /*
     
    97689816     */
    97699817#if !defined(IEM_VERIFICATION_MODE_FULL) || !defined(IN_RING3)
     9818    PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx);
    97709819# ifdef IEM_VERIFICATION_MODE_FULL
    97719820    pIemCpu->uInjectCpl = UINT8_MAX;
     
    97869835#else
    97879836    iemExecVerificationModeSetup(pIemCpu);
     9837    PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx);
    97889838#endif
    97899839
     
    97929842     */
    97939843#ifdef LOG_ENABLED
    9794 # ifdef IN_RING3
    9795     if (LogIs2Enabled())
    9796     {
    9797         char     szInstr[256];
    9798         uint32_t cbInstr = 0;
    9799         DBGFR3DisasInstrEx(pVCpu->pVMR3->pUVM, pVCpu->idCpu, 0, 0,
    9800                            DBGF_DISAS_FLAGS_CURRENT_GUEST | DBGF_DISAS_FLAGS_DEFAULT_MODE,
    9801                            szInstr, sizeof(szInstr), &cbInstr);
    9802 
    9803         Log2(("**** "
    9804               " eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n"
    9805               " eip=%08x esp=%08x ebp=%08x iopl=%d\n"
    9806               " cs=%04x ss=%04x ds=%04x es=%04x fs=%04x gs=%04x efl=%08x\n"
    9807               " fsw=%04x fcw=%04x ftw=%02x mxcsr=%04x/%04x\n"
    9808               " %s\n"
    9809               ,
    9810               pCtx->eax, pCtx->ebx, pCtx->ecx, pCtx->edx, pCtx->esi, pCtx->edi,
    9811               pCtx->eip, pCtx->esp, pCtx->ebp, pCtx->eflags.Bits.u2IOPL,
    9812               pCtx->cs.Sel, pCtx->ss.Sel, pCtx->ds.Sel, pCtx->es.Sel,
    9813               pCtx->fs.Sel, pCtx->gs.Sel, pCtx->eflags.u,
    9814               pCtx->fpu.FSW, pCtx->fpu.FCW, pCtx->fpu.FTW, pCtx->fpu.MXCSR, pCtx->fpu.MXCSR_MASK,
    9815               szInstr));
    9816 
    9817         if (LogIs3Enabled())
    9818             DBGFR3Info(pVCpu->pVMR3->pUVM, "cpumguest", "verbose", NULL);
    9819     }
    9820     else
    9821 # endif
    9822         LogFlow(("IEMExecOne: cs:rip=%04x:%08RX64 ss:rsp=%04x:%08RX64 EFL=%06x\n",
    9823                  pCtx->cs.Sel, pCtx->rip, pCtx->ss.Sel, pCtx->rsp, pCtx->eflags.u));
     9844    iemLogCurInstr(pVCpu, pCtx, true);
    98249845#endif
    98259846
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