VirtualBox

Changeset 20530 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Jun 13, 2009 8:53:44 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
48532
Message:

VMM: remove DISCPUSTATE from the stack.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r20516 r20530  
    10231023     *
    10241024     * Interrupts are disabled before the call to make sure we don't miss any interrupt
    1025      * that would flag preemption (IPI, timer tick, ++). 
     1025     * that would flag preemption (IPI, timer tick, ++).
    10261026     *
    10271027     * Note! Interrupts must be disabled done *before* we check for TLB flushes; TLB
     
    20622062        {
    20632063            /* ins/outs */
    2064             DISCPUSTATE Cpu;
     2064            PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState;
    20652065
    20662066            /* Disassemble manually to deal with segment prefixes. */
    2067             rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, NULL);
     2067            rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, NULL);
    20682068            if (rc == VINF_SUCCESS)
    20692069            {
     
    20722072                    Log2(("IOMInterpretOUTSEx %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, IoExitInfo.n.u16Port, uIOSize));
    20732073                    STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringWrite);
    2074                     rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), IoExitInfo.n.u16Port, Cpu.prefix, uIOSize);
     2074                    rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), IoExitInfo.n.u16Port, pDis->prefix, uIOSize);
    20752075                }
    20762076                else
     
    20782078                    Log2(("IOMInterpretINSEx  %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, IoExitInfo.n.u16Port, uIOSize));
    20792079                    STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringRead);
    2080                     rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), IoExitInfo.n.u16Port, Cpu.prefix, uIOSize);
     2080                    rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), IoExitInfo.n.u16Port, pDis->prefix, uIOSize);
    20812081                }
    20822082            }
     
    23372337 * @returns VBox status code.
    23382338 * @param   pVCpu       The VM CPU to operate on.
    2339  * @param   pDisState   Disassembly state
     2339 * @param   pDis        Disassembly state
    23402340 * @param   pCtx        CPU context
    23412341 * @param   cbOp        Opcode size
    23422342 */
    2343 static int svmR0EmulateTprMov(PVMCPU pVCpu, DISCPUSTATE *pDisState, PCPUMCTX pCtx, unsigned cbOp)
     2343static int svmR0EmulateTprMov(PVMCPU pVCpu, PDISCPUSTATE pDis, PCPUMCTX pCtx, unsigned cbOp)
    23442344{
    23452345    int rc;
    23462346
    2347     if (pDisState->param1.flags == USE_DISPLACEMENT32)
     2347    if (pDis->param1.flags == USE_DISPLACEMENT32)
    23482348    {
    23492349        /* write */
     
    23512351
    23522352        /* Fetch the new TPR value */
    2353         if (pDisState->param2.flags == USE_REG_GEN32)
     2353        if (pDis->param2.flags == USE_REG_GEN32)
    23542354        {
    23552355            uint32_t val;
    23562356
    2357             rc = DISFetchReg32(CPUMCTX2CORE(pCtx), pDisState->param2.base.reg_gen, &val);
     2357            rc = DISFetchReg32(CPUMCTX2CORE(pCtx), pDis->param2.base.reg_gen, &val);
    23582358            AssertRC(rc);
    23592359            u8Tpr = val >> 4;
    23602360        }
    23612361        else
    2362         if (pDisState->param2.flags == USE_IMMEDIATE32)
    2363         {
    2364             u8Tpr = (uint8_t)pDisState->param2.parval >> 4;
     2362        if (pDis->param2.flags == USE_IMMEDIATE32)
     2363        {
     2364            u8Tpr = (uint8_t)pDis->param2.parval >> 4;
    23652365        }
    23662366        else
     
    23752375    }
    23762376    else
    2377     if (pDisState->param2.flags == USE_DISPLACEMENT32)
     2377    if (pDis->param2.flags == USE_DISPLACEMENT32)
    23782378    {
    23792379        /* read */
     
    23852385        AssertRC(rc);
    23862386
    2387         rc = DISWriteReg32(CPUMCTX2CORE(pCtx), pDisState->param1.base.reg_gen, u8Tpr << 4);
     2387        rc = DISWriteReg32(CPUMCTX2CORE(pCtx), pDis->param1.base.reg_gen, u8Tpr << 4);
    23882388        AssertRC(rc);
    23892389
     
    24052405static int svmR0ReplaceTprInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
    24062406{
    2407     RTGCPTR     oldrip = pCtx->rip;
    2408     DISCPUSTATE Cpu;
    2409     unsigned    cbOp;
     2407    RTGCPTR      oldrip = pCtx->rip;
     2408    PDISCPUSTATE pDis   = &pVCpu->hwaccm.s.DisState;
     2409    unsigned     cbOp;
    24102410
    24112411    Log(("Replace TPR access at %RGv\n", pCtx->rip));
    24122412
    2413     int rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);
     2413    int rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp);
    24142414    AssertRC(rc);
    24152415    if (    rc == VINF_SUCCESS
    2416         &&  Cpu.pCurInstr->opcode == OP_MOV)
     2416        &&  pDis->pCurInstr->opcode == OP_MOV)
    24172417    {
    24182418#if 0
    24192419        uint8_t szInstr[15];
    24202420        if (    cbOp == 10
    2421             &&  Cpu.param1.flags == USE_DISPLACEMENT32
    2422             &&  Cpu.param2.flags == USE_IMMEDIATE32)
     2421            &&  pDis->param1.flags == USE_DISPLACEMENT32
     2422            &&  pDis->param2.flags == USE_IMMEDIATE32)
    24232423        {
    24242424            /* Found:
     
    24312431             *
    24322432             */
    2433             uint32_t    u32tpr = (uint32_t)Cpu.param2.parval;
     2433            uint32_t    u32tpr = (uint32_t)pDis->param2.parval;
    24342434
    24352435            u32tpr = (u32tpr >> 4) & 0xf;
    24362436
    2437             /* Check if the next instruction overwrites a general purpose register. If 
     2437            /* Check if the next instruction overwrites a general purpose register. If
    24382438             * it does, then we can safely use it ourselves.
    24392439             */
    24402440            pCtx->rip += cbOp;
    2441             rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);
     2441            rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp);
    24422442            pCtx->rip = oldrip;
    24432443            if (    rc == VINF_SUCCESS
    2444                 &&  Cpu.pCurInstr->opcode == OP_MOV
    2445                 &&  Cpu.param1.flags == USE_REG_GEN32)
     2444                &&  pDis->pCurInstr->opcode == OP_MOV
     2445                &&  pDis->param1.flags == USE_REG_GEN32)
    24462446            {
    24472447                /* 0xB8, dword immediate  = mov eax, dword immediate */
    2448                 szInstr[0] = 0xB8 + Cpu.param1.base.reg_gen;
     2448                szInstr[0] = 0xB8 + pDis->param1.base.reg_gen;
    24492449                szInstr[1] = (uint8_t)u32tpr;
    24502450                szInstr[2] = 0;
     
    24562456                szInstr[6] = 0x0F;
    24572457                szInstr[7] = 0x22;
    2458                 szInstr[8] = 0xC0 | Cpu.param1.base.reg_gen;
     2458                szInstr[8] = 0xC0 | pDis->param1.base.reg_gen;
    24592459                szInstr[9] = 0x90; /* nop */
    24602460
     
    24682468        else
    24692469        {
    2470             if (    Cpu.param2.flags == USE_REG_GEN32
     2470            if (    pDis->param2.flags == USE_REG_GEN32
    24712471                &&  cbOp == 6)
    24722472            {
    2473                 RTGCPTR  GCPtrTpr = (uint32_t)Cpu.param1.disp32;
    2474                 uint32_t uMmioReg = Cpu.param2.base.reg_gen;
     2473                RTGCPTR  GCPtrTpr = (uint32_t)pDis->param1.disp32;
     2474                uint32_t uMmioReg = pDis->param2.base.reg_gen;
    24752475
    24762476                /* Found:
     
    24802480                 */
    24812481                pCtx->rip += cbOp;
    2482                 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);
     2482                rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp);
    24832483                pCtx->rip = oldrip;
    24842484                if (    rc == VINF_SUCCESS
    2485                     &&  Cpu.pCurInstr->opcode == OP_MOV
    2486                     &&  Cpu.param1.flags == USE_REG_GEN32
    2487                     &&  Cpu.param2.flags == USE_DISPLACEMENT32
    2488                     &&  Cpu.param2.disp32 == (uint32_t)GCPtrTpr
     2485                    &&  pDis->pCurInstr->opcode == OP_MOV
     2486                    &&  pDis->param1.flags == USE_REG_GEN32
     2487                    &&  pDis->param2.flags == USE_DISPLACEMENT32
     2488                    &&  pDis->param2.disp32 == (uint32_t)GCPtrTpr
    24892489                    &&  cbOp == 5)
    24902490                {
    24912491                    /* mov new_reg, uMmioReg */
    24922492                    szInstr[0] = 0x89;
    2493                     szInstr[1] = MAKE_MODRM(3, uMmioReg, Cpu.param1.base.reg_gen);
     2493                    szInstr[1] = MAKE_MODRM(3, uMmioReg, pDis->param1.base.reg_gen);
    24942494
    24952495                    /* Let's hope the guest won't mind us trashing the source register...
     
    25182518            }
    25192519            else
    2520             if (    Cpu.param1.flags == USE_REG_GEN32
     2520            if (    pDis->param1.flags == USE_REG_GEN32
    25212521                &&  cbOp == 5)
    25222522            {
    2523                 uint32_t uMmioReg = Cpu.param1.base.reg_gen;
     2523                uint32_t uMmioReg = pDis->param1.base.reg_gen;
    25242524
    25252525                /* Found:
     
    25292529                 */
    25302530                pCtx->rip += cbOp;
    2531                 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);
     2531                rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp);
    25322532                pCtx->rip = oldrip;
    25332533                if (    rc == VINF_SUCCESS
    2534                     &&  Cpu.pCurInstr->opcode == OP_SHR
    2535                     &&  Cpu.param1.flags == USE_REG_GEN32
    2536                     &&  Cpu.param1.base.reg_gen == uMmioReg
    2537                     &&  Cpu.param2.flags == USE_IMMEDIATE8
    2538                     &&  Cpu.param2.parval == 4)
     2534                    &&  pDis->pCurInstr->opcode == OP_SHR
     2535                    &&  pDis->param1.flags == USE_REG_GEN32
     2536                    &&  pDis->param1.base.reg_gen == uMmioReg
     2537                    &&  pDis->param2.flags == USE_IMMEDIATE8
     2538                    &&  pDis->param2.parval == 4)
    25392539                {
    25402540                    /* 0xF0, 0x0F, 0x20, 0xC0 = mov eax, cr8 */
     
    25422542                    szInstr[1] = 0x0F;
    25432543                    szInstr[2] = 0x20;
    2544                     szInstr[3] = 0xC0 | Cpu.param1.base.reg_gen;
     2544                    szInstr[3] = 0xC0 | pDis->param1.base.reg_gen;
    25452545                    for (unsigned i = 4; i < 5+cbOp; i++)
    25462546                        szInstr[i] = 0x90;  /* nop */
     
    25552555        }
    25562556#endif
    2557         rc = svmR0EmulateTprMov(pVCpu, &Cpu, pCtx, cbOp);
     2557        rc = svmR0EmulateTprMov(pVCpu, pDis, pCtx, cbOp);
    25582558        if (rc != VINF_SUCCESS)
    25592559            return rc;
     
    26832683        if (RT_SUCCESS(rc))
    26842684        {
    2685             uint32_t    cbOp;
    2686             DISCPUSTATE Cpu;
    2687 
    2688             Cpu.mode = enmMode;
    2689             rc = EMInterpretDisasOneEx(pVM, pVCpu, pbCode, pRegFrame, &Cpu, &cbOp);
    2690             Assert(RT_FAILURE(rc) || Cpu.pCurInstr->opcode == OP_INVLPG);
    2691             if (RT_SUCCESS(rc) && Cpu.pCurInstr->opcode == OP_INVLPG)
     2685            uint32_t     cbOp;
     2686            PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState;
     2687
     2688            pDis->mode = enmMode;
     2689            rc = EMInterpretDisasOneEx(pVM, pVCpu, pbCode, pRegFrame, pDis, &cbOp);
     2690            Assert(RT_FAILURE(rc) || pDis->pCurInstr->opcode == OP_INVLPG);
     2691            if (RT_SUCCESS(rc) && pDis->pCurInstr->opcode == OP_INVLPG)
    26922692            {
    2693                 Assert(cbOp == Cpu.opsize);
    2694                 rc = svmR0InterpretInvlPg(pVCpu, &Cpu, pRegFrame, uASID);
     2693                Assert(cbOp == pDis->opsize);
     2694                rc = svmR0InterpretInvlPg(pVCpu, pDis, pRegFrame, uASID);
    26952695                if (RT_SUCCESS(rc))
    26962696                {
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r20517 r20530  
    23152315    /* All done! Let's start VM execution. */
    23162316    STAM_PROFILE_ADV_START(&pVCpu->hwaccm.s.StatInGC, z);
    2317 #ifdef VBOX_STRICT
    23182317    Assert(idCpuCheck == RTMpCpuId());
    2319 #endif
    23202318
    23212319#ifdef VBOX_WITH_CRASHDUMP_MAGIC
     
    23282326    TMNotifyEndOfExecution(pVCpu);
    23292327    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED);
     2328    Assert(!(ASMGetFlags() & X86_EFL_IF));
    23302329    ASMSetFlags(uOldEFlags);
    23312330#ifndef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
     
    26762675            case X86_XCPT_GP:   /* General protection failure exception.*/
    26772676            {
    2678                 uint32_t    cbOp;
    2679                 uint32_t    cbSize;
    2680                 DISCPUSTATE Cpu;
     2677                uint32_t     cbOp;
     2678                uint32_t     cbSize;
     2679                PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState;
    26812680
    26822681                STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitGuestGP);
     
    26952694                LogFlow(("Real mode X86_XCPT_GP instruction emulation at %RGv\n", (RTGCPTR)pCtx->rip));
    26962695
    2697                 rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, &cbOp);
     2696                rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, &cbOp);
    26982697                if (RT_SUCCESS(rc))
    26992698                {
    27002699                    bool fUpdateRIP = true;
    27012700
    2702                     Assert(cbOp == Cpu.opsize);
    2703                     switch (Cpu.pCurInstr->opcode)
     2701                    Assert(cbOp == pDis->opsize);
     2702                    switch (pDis->pCurInstr->opcode)
    27042703                    {
    27052704                    case OP_CLI:
     
    27162715                        fUpdateRIP = false;
    27172716                        rc = VINF_EM_HALT;
    2718                         pCtx->rip += Cpu.opsize;
     2717                        pCtx->rip += pDis->opsize;
    27192718                        STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitHlt);
    27202719                        break;
     
    27272726                        X86EFLAGS eflags;
    27282727
    2729                         if (Cpu.prefix & PREFIX_OPSIZE)
     2728                        if (pDis->prefix & PREFIX_OPSIZE)
    27302729                        {
    27312730                            cbParm = 4;
     
    27692768                        X86EFLAGS eflags;
    27702769
    2771                         if (Cpu.prefix & PREFIX_OPSIZE)
     2770                        if (pDis->prefix & PREFIX_OPSIZE)
    27722771                        {
    27732772                            cbParm = 4;
     
    28102809                        uint16_t  aIretFrame[3];
    28112810
    2812                         if (Cpu.prefix & (PREFIX_OPSIZE | PREFIX_ADDRSIZE))
     2811                        if (pDis->prefix & (PREFIX_OPSIZE | PREFIX_ADDRSIZE))
    28132812                        {
    28142813                            rc = VERR_EM_INTERPRETER;
     
    28442843                        RTGCUINTPTR intInfo;
    28452844
    2846                         LogFlow(("Realmode: INT %x\n", Cpu.param1.parval & 0xff));
    2847                         intInfo  = Cpu.param1.parval & 0xff;
     2845                        LogFlow(("Realmode: INT %x\n", pDis->param1.parval & 0xff));
     2846                        intInfo  = pDis->param1.parval & 0xff;
    28482847                        intInfo |= (1 << VMX_EXIT_INTERRUPTION_INFO_VALID_SHIFT);
    28492848                        intInfo |= (VMX_EXIT_INTERRUPTION_INFO_TYPE_SW << VMX_EXIT_INTERRUPTION_INFO_TYPE_SHIFT);
     
    28922891
    28932892                    default:
    2894                         rc = EMInterpretInstructionCPU(pVM, pVCpu, &Cpu, CPUMCTX2CORE(pCtx), 0, &cbSize);
     2893                        rc = EMInterpretInstructionCPU(pVM, pVCpu, pDis, CPUMCTX2CORE(pCtx), 0, &cbSize);
    28952894                        break;
    28962895                    }
     
    33413340        {
    33423341            /* ins/outs */
    3343             DISCPUSTATE Cpu;
     3342            PDISCPUSTATE pDis = &pVCpu->hwaccm.s.DisState;
    33443343
    33453344            /* Disassemble manually to deal with segment prefixes. */
    33463345            /** @todo VMX_VMCS_EXIT_GUEST_LINEAR_ADDR contains the flat pointer operand of the instruction. */
    33473346            /** @todo VMX_VMCS32_RO_EXIT_INSTR_INFO also contains segment prefix info. */
    3348             rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), &Cpu, NULL);
     3347            rc = EMInterpretDisasOne(pVM, pVCpu, CPUMCTX2CORE(pCtx), pDis, NULL);
    33493348            if (rc == VINF_SUCCESS)
    33503349            {
     
    33533352                    Log2(("IOMInterpretOUTSEx %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, uPort, cbSize));
    33543353                    STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringWrite);
    3355                     rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), uPort, Cpu.prefix, cbSize);
     3354                    rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), uPort, pDis->prefix, cbSize);
    33563355                }
    33573356                else
     
    33593358                    Log2(("IOMInterpretINSEx  %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, uPort, cbSize));
    33603359                    STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringRead);
    3361                     rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), uPort, Cpu.prefix, cbSize);
     3360                    rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), uPort, pDis->prefix, cbSize);
    33623361                }
    33633362            }
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