VirtualBox

Changeset 56080 in vbox


Ignore:
Timestamp:
May 26, 2015 2:36:27 PM (10 years ago)
Author:
vboxsync
Message:

IOM,HM: Let IEM take over the MMIO handling from IOM when VBOX_WITH_2ND_IEM_STEP is defined (currently disabled).

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/err.h

    r56047 r56080  
    20592059/** Unknown or unrecognized SVM exit.  */
    20602060#define VERR_SVM_UNKNOWN_EXIT                       (-4060)
     2061/** Internal SVM processing error no 1. */
     2062#define VERR_SVM_IPE_1                              (-4061)
     2063/** Internal SVM processing error no 2. */
     2064#define VERR_SVM_IPE_2                              (-4062)
     2065/** Internal SVM processing error no 3. */
     2066#define VERR_SVM_IPE_3                              (-4063)
     2067/** Internal SVM processing error no 4. */
     2068#define VERR_SVM_IPE_4                              (-4064)
     2069/** Internal SVM processing error no 5. */
     2070#define VERR_SVM_IPE_5                              (-4065)
    20612071/** @} */
    20622072
  • trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp

    r56072 r56080  
    1616 */
    1717
    18 //#define IOM_USE_IEM_FOR_MMIO
    1918
    2019/*******************************************************************************
     
    3029#include <VBox/vmm/pgm.h>
    3130#include <VBox/vmm/trpm.h>
    32 #if defined(IOM_USE_IEM_FOR_MMIO) || (defined(IEM_VERIFICATION_MODE) && defined(IN_RING3))
    33 # include <VBox/vmm/iem.h>
    34 #endif
     31#include <VBox/vmm/iem.h>
    3532#include "IOMInternal.h"
    3633#include <VBox/vmm/vm.h>
     
    723720
    724721
    725 #ifndef IOM_USE_IEM_FOR_MMIO
     722#ifndef VBOX_WITH_2ND_IEM_STEP
    726723
    727724/**
     
    820817}
    821818
    822 #endif /* !IOM_USE_IEM_FOR_MMIO */
    823 
    824819
    825820/** Wrapper for reading virtual memory. */
     
    11211116
    11221117
    1123 #ifndef IOM_USE_IEM_FOR_MMIO
    1124 
    11251118/**
    11261119 * [REP] STOSB
     
    16541647}
    16551648
    1656 #endif /* !IOM_USE_IEM_FOR_MMIO */
     1649#endif /* !VBOX_WITH_2ND_IEM_STEP */
    16571650
    16581651/**
     
    17441737    }
    17451738
    1746 #ifdef IOM_USE_IEM_FOR_MMIO
     1739#ifdef VBOX_WITH_2ND_IEM_STEP
    17471740
    17481741    /*
     
    19031896    iomMmioReleaseRange(pVM, pRange);
    19041897    return rc;
    1905 #endif /* !IOM_USE_IEM_FOR_MMIO */
     1898#endif /* !VBOX_WITH_2ND_IEM_STEP */
    19061899}
    19071900
     
    20222015}
    20232016
     2017
     2018#ifdef IN_RING3 /* Only used by REM. */
    20242019
    20252020/**
     
    22612256}
    22622257
     2258#endif /* IN_RING3 - only used by REM. */
     2259#ifndef VBOX_WITH_2ND_IEM_STEP
    22632260
    22642261/**
     
    25022499    return rcStrict;
    25032500}
     2501
     2502#endif /* !VBOX_WITH_2ND_IEM_STEP */
    25042503
    25052504
     
    26062605     * Lookup the context range node the page belongs to.
    26072606     */
    2608 #ifdef VBOX_STRICT
     2607#  ifdef VBOX_STRICT
    26092608    /* Can't lock IOM here due to potential deadlocks in the VGA device; not safe to access. */
    26102609    PIOMMMIORANGE pRange = iomMMIOGetRangeUnsafe(pVM, pVCpu, GCPhys);
     
    26132612    Assert((pRange->GCPhys       & PAGE_OFFSET_MASK) == 0);
    26142613    Assert((pRange->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK);
    2615 #endif
     2614#  endif
    26162615
    26172616    /*
     
    26342633    return VINF_SUCCESS;
    26352634}
    2636 #endif /* !IEM_VERIFICATION_MODE_FULL */
     2635# endif /* !IEM_VERIFICATION_MODE_FULL */
    26372636
    26382637
     
    26602659     * Lookup the context range node the page belongs to.
    26612660     */
    2662 #ifdef VBOX_STRICT
     2661# ifdef VBOX_STRICT
    26632662    /* Can't lock IOM here due to potential deadlocks in the VGA device; not safe to access. */
    26642663    PIOMMMIORANGE pRange = iomMMIOGetRangeUnsafe(pVM, pVCpu, GCPhys);
     
    26672666    Assert((pRange->GCPhys       & PAGE_OFFSET_MASK) == 0);
    26682667    Assert((pRange->Core.KeyLast & PAGE_OFFSET_MASK) == PAGE_OFFSET_MASK);
    2669 #endif
     2668# endif
    26702669
    26712670    /*
     
    26782677    AssertRC(rc);
    26792678
    2680 #ifdef VBOX_STRICT
     2679# ifdef VBOX_STRICT
    26812680    if (!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3))
    26822681    {
     
    26932692        }
    26942693    }
    2695 #endif
     2694# endif
    26962695    return rc;
    26972696}
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r55863 r56080  
    47794779    if (IoExitInfo.n.u1STR)
    47804780    {
     4781#ifdef VBOX_WITH_2ND_IEM_STEP
     4782        /* INS/OUTS - I/O String instruction. */
     4783        /** @todo Huh? why can't we use the segment prefix information given by AMD-V
     4784         *        in EXITINFO1? Investigate once this thing is up and running. */
     4785        Log4(("CS:RIP=%04x:%08RX64 %#06x/%u %c str\n", pCtx->cs.Sel, pCtx->rip, IoExitInfo.n.u16Port, cbValue,
     4786              IoExitInfo.n.u1Type == SVM_IOIO_WRITE ? 'w' : 'r'));
     4787        AssertReturn(pCtx->dx == IoExitInfo.n.u16Port, VERR_SVM_IPE_2);
     4788        static IEMMODE const s_aenmAddrMode[8] =
     4789        {
     4790            (IEMMODE)-1, IEMMODE_16BIT, IEMMODE_32BIT, (IEMMODE)-1, IEMMODE_64BIT, (IEMMODE)-1, (IEMMODE)-1, (IEMMODE)-1
     4791        };
     4792        IEMMODE enmAddrMode = s_aenmAddrMode[(IoExitInfo.u >> 7) & 0x7];
     4793        if (enmAddrMode != (IEMMODE)-1)
     4794        {
     4795            uint64_t cbInstr = pVmcb->ctrl.u64ExitInfo2 - pCtx->rip;
     4796            if (cbInstr <= 15 && cbInstr >= 2)
     4797            {
     4798                if (IoExitInfo.n.u1Type == SVM_IOIO_WRITE)
     4799                {
     4800                    if (pVM->hm.s.svm.u32Features & AMD_CPUID_SVM_FEATURE_EDX_NRIP_SAVE)
     4801                        rcStrict = IEMExecStringIoWrite(pVCpu, cbValue, enmAddrMode, IoExitInfo.n.u1REP, (uint8_t)cbInstr,
     4802                                                        IoExitInfo.n.u3SEG);
     4803                    else
     4804                        rcStrict = IEMExecOne(pVCpu);
     4805                    STAM_COUNTER_INC(&pVCpu->hm.s.StatExitIOStringWrite);
     4806                }
     4807                else
     4808                {
     4809                    AssertMsg(IoExitInfo.n.u3SEG == X86_SREG_ES /*=0*/, ("%#x\n", IoExitInfo.n.u3SEG));
     4810                    rcStrict = IEMExecStringIoRead(pVCpu, cbValue, enmAddrMode, IoExitInfo.n.u1REP, (uint8_t)cbInstr);
     4811                    STAM_COUNTER_INC(&pVCpu->hm.s.StatExitIOStringRead);
     4812                }
     4813            }
     4814            else
     4815            {
     4816                AssertMsgFailed(("rip=%RX64 nrip=%#RX64 cbInstr=%#RX64\n", pCtx->rip, pVmcb->ctrl.u64ExitInfo2, cbInstr));
     4817                rcStrict = IEMExecOne(pVCpu);
     4818            }
     4819        }
     4820        else
     4821        {
     4822            AssertMsgFailed(("IoExitInfo=%RX64\n", IoExitInfo.u));
     4823            rcStrict = IEMExecOne(pVCpu);
     4824        }
     4825
     4826#else
    47814827        /* INS/OUTS - I/O String instruction. */
    47824828        PDISCPUSTATE pDis = &pVCpu->hm.s.DisState;
     
    48034849        else
    48044850            rcStrict = VINF_EM_RAW_EMULATE_INSTR;
     4851#endif
    48054852    }
    48064853    else
     
    48204867        {
    48214868            uint32_t u32Val = 0;
    4822 
    48234869            rcStrict = IOMIOPortRead(pVM, pVCpu, IoExitInfo.n.u16Port, &u32Val, cbValue);
    48244870            if (IOM_SUCCESS(rcStrict))
    48254871            {
    48264872                /* Save result of I/O IN instr. in AL/AX/EAX. */
     4873                /** @todo r=bird: 32-bit op size should clear high bits of rax! */
    48274874                pCtx->eax = (pCtx->eax & ~uAndVal) | (u32Val & uAndVal);
    48284875            }
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r56048 r56080  
    1118611186    if (fIOString)
    1118711187    {
    11188 #if 0       /* Not yet ready. IEM gurus with debian 32-bit guest without NP (on ATA reads). See @bugref{5752#c158} */
     11188#ifdef VBOX_WITH_2ND_IEM_STEP /* This used to gurus with debian 32-bit guest without NP (on ATA reads). See @bugref{5752#c158}. Should work now. */
    1118911189        /*
    1119011190         * INS/OUTS - I/O String instruction.
  • trunk/src/VBox/VMM/VMMRC/IOMRC.cpp

    r56072 r56080  
    2727#include <VBox/vmm/mm.h>
    2828#include <VBox/vmm/em.h>
     29#include <VBox/vmm/iem.h>
    2930#include <VBox/vmm/pgm.h>
    3031#include <VBox/vmm/trpm.h>
     
    4041#include <iprt/asm.h>
    4142#include <iprt/string.h>
     43
     44
     45#ifdef VBOX_WITH_2ND_IEM_STEP
     46/**
     47 * Converts disassembler mode to IEM mode.
     48 * @return IEM CPU mode.
     49 * @param  enmDisMode   Disassembler CPU mode.
     50 */
     51DECLINLINE(IEMMODE) iomDisModeToIemMode(DISCPUMODE enmDisMode)
     52{
     53    switch (enmDisMode)
     54    {
     55        case DISCPUMODE_16BIT: return IEMMODE_16BIT;
     56        case DISCPUMODE_32BIT: return IEMMODE_32BIT;
     57        case DISCPUMODE_64BIT: return IEMMODE_64BIT;
     58        default:
     59            AssertFailed();
     60            return IEMMODE_32BIT;
     61    }
     62}
     63#endif
    4264
    4365
     
    178200static VBOXSTRICTRC iomRCInterpretINS(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu)
    179201{
     202#ifdef VBOX_WITH_2ND_IEM_STEP
     203    uint8_t cbValue = pCpu->pCurInstr->uOpcode == OP_INSB ? 1
     204                    : pCpu->uOpMode == DISCPUMODE_16BIT ? 2 : 4;       /* dword in both 32 & 64 bits mode */
     205    return IEMExecStringIoRead(pVCpu,
     206                               cbValue,
     207                               iomDisModeToIemMode((DISCPUMODE)pCpu->uCpuMode),
     208                               RT_BOOL(pCpu->fPrefix & (DISPREFIX_REPNE | DISPREFIX_REP)),
     209                               pCpu->cbInstr);
     210#else
    180211    /*
    181212     * Get port number directly from the register (no need to bother the
     
    197228
    198229    return IOMInterpretINSEx(pVM, pVCpu, pRegFrame, Port, pCpu->fPrefix, (DISCPUMODE)pCpu->uAddrMode, cb);
     230#endif
    199231}
    200232
     
    222254static VBOXSTRICTRC iomRCInterpretOUTS(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu)
    223255{
     256#ifdef VBOX_WITH_2ND_IEM_STEP
     257    uint8_t cbValue = pCpu->pCurInstr->uOpcode == OP_OUTSB ? 1
     258                    : pCpu->uOpMode == DISCPUMODE_16BIT ? 2 : 4;       /* dword in both 32 & 64 bits mode */
     259    return IEMExecStringIoWrite(pVCpu,
     260                                cbValue,
     261                                iomDisModeToIemMode((DISCPUMODE)pCpu->uCpuMode),
     262                                RT_BOOL(pCpu->fPrefix & (DISPREFIX_REPNE | DISPREFIX_REP)),
     263                                pCpu->cbInstr,
     264                                pCpu->fPrefix & DISPREFIX_SEG ? pCpu->idxSegPrefix : X86_SREG_DS);
     265#else
    224266    /*
    225267     * Get port number from the first parameter.
     
    227269     */
    228270    uint64_t    Port = 0;
    229     unsigned    cb;
    230271    bool fRc = iomGetRegImmData(pCpu, &pCpu->Param1, pRegFrame, &Port, &cb);
    231272    AssertMsg(fRc, ("Failed to get reg/imm port number!\n")); NOREF(fRc);
     273    unsigned cb;
    232274    if (pCpu->pCurInstr->uOpcode == OP_OUTSB)
    233275        cb = 1;
     
    243285
    244286    return IOMInterpretOUTSEx(pVM, pVCpu, pRegFrame, Port, pCpu->fPrefix, (DISCPUMODE)pCpu->uAddrMode, cb);
     287#endif
    245288}
    246289
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