VirtualBox

Changeset 87493 in vbox


Ignore:
Timestamp:
Jan 30, 2021 1:57:34 AM (4 years ago)
Author:
vboxsync
Message:

VMM/HMVMX: Moving more stuff to HMR0PERVCPU. bugref:9217

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

Legend:

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

    r87487 r87493  
    63526352        else
    63536353        {
    6354             PDISCPUSTATE pDis = &pVCpu->hm.s.DisState;
     6354            PDISCPUSTATE pDis = &pVCpu->hmr0.s.svm.DisState;
    63556355            int rc = EMInterpretDisasCurrent(pVCpu->CTX_SUFF(pVM), pVCpu, pDis, &cbInstr);
    63566356            if (   rc == VINF_SUCCESS
     
    70507050        else
    70517051        {
    7052             PDISCPUSTATE pDis = &pVCpu->hm.s.DisState;
     7052            PDISCPUSTATE pDis = &pVCpu->hmr0.s.svm.DisState;
    70537053            int rc = EMInterpretDisasCurrent(pVCpu->CTX_SUFF(pVM), pVCpu, pDis, &cbInstr);
    70547054            if (   rc == VINF_SUCCESS
     
    70947094    else
    70957095    {
    7096         PDISCPUSTATE pDis = &pVCpu->hm.s.DisState;
     7096        PDISCPUSTATE pDis = &pVCpu->hmr0.s.svm.DisState;
    70977097        int rc = EMInterpretDisasCurrent(pVCpu->CTX_SUFF(pVM), pVCpu, pDis, &cbInstr);
    70987098        if (   rc == VINF_SUCCESS
     
    74077407    if (!(pCtx->cr0 & X86_CR0_NE))
    74087408    {
    7409         PVMCC       pVM  = pVCpu->CTX_SUFF(pVM);
    7410         PDISSTATE pDis = &pVCpu->hm.s.DisState;
     7409        PVMCC     pVM  = pVCpu->CTX_SUFF(pVM);
     7410        PDISSTATE pDis = &pVCpu->hmr0.s.svm.DisState;
    74117411        unsigned  cbInstr;
    74127412        int rc = EMInterpretDisasCurrent(pVM, pVCpu, pDis, &cbInstr);
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r87491 r87493  
    22722272     */
    22732273    DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, "hmR3ReplaceTprInstr");
    2274     PDISCPUSTATE    pDis = &pVCpu->hm.s.DisState;
     2274    DISCPUSTATE     Dis;
    22752275    uint32_t        cbOp;
    2276     int rc = EMInterpretDisasCurrent(pVM, pVCpu, pDis, &cbOp);
     2276    int rc = EMInterpretDisasCurrent(pVM, pVCpu, &Dis, &cbOp);
    22772277    AssertRC(rc);
    22782278    if (    rc == VINF_SUCCESS
    2279         &&  pDis->pCurInstr->uOpcode == OP_MOV
     2279        &&  Dis.pCurInstr->uOpcode == OP_MOV
    22802280        &&  cbOp >= 3)
    22812281    {
     
    22872287        pPatch->cbOp = cbOp;
    22882288
    2289         if (pDis->Param1.fUse == DISUSE_DISPLACEMENT32)
     2289        if (Dis.Param1.fUse == DISUSE_DISPLACEMENT32)
    22902290        {
    22912291            /* write. */
    2292             if (pDis->Param2.fUse == DISUSE_REG_GEN32)
     2292            if (Dis.Param2.fUse == DISUSE_REG_GEN32)
    22932293            {
    22942294                pPatch->enmType     = HMTPRINSTR_WRITE_REG;
    2295                 pPatch->uSrcOperand = pDis->Param2.Base.idxGenReg;
    2296                 Log(("hmR3ReplaceTprInstr: HMTPRINSTR_WRITE_REG %u\n", pDis->Param2.Base.idxGenReg));
     2295                pPatch->uSrcOperand = Dis.Param2.Base.idxGenReg;
     2296                Log(("hmR3ReplaceTprInstr: HMTPRINSTR_WRITE_REG %u\n", Dis.Param2.Base.idxGenReg));
    22972297            }
    22982298            else
    22992299            {
    2300                 Assert(pDis->Param2.fUse == DISUSE_IMMEDIATE32);
     2300                Assert(Dis.Param2.fUse == DISUSE_IMMEDIATE32);
    23012301                pPatch->enmType     = HMTPRINSTR_WRITE_IMM;
    2302                 pPatch->uSrcOperand = pDis->Param2.uValue;
    2303                 Log(("hmR3ReplaceTprInstr: HMTPRINSTR_WRITE_IMM %#llx\n", pDis->Param2.uValue));
     2302                pPatch->uSrcOperand = Dis.Param2.uValue;
     2303                Log(("hmR3ReplaceTprInstr: HMTPRINSTR_WRITE_IMM %#llx\n", Dis.Param2.uValue));
    23042304            }
    23052305            rc = PGMPhysSimpleWriteGCPtr(pVCpu, pCtx->rip, s_abVMMCall, sizeof(s_abVMMCall));
     
    23202320             *   shr eax, 4
    23212321             */
    2322             Assert(pDis->Param1.fUse == DISUSE_REG_GEN32);
    2323 
    2324             uint8_t  const idxMmioReg = pDis->Param1.Base.idxGenReg;
     2322            Assert(Dis.Param1.fUse == DISUSE_REG_GEN32);
     2323
     2324            uint8_t  const idxMmioReg = Dis.Param1.Base.idxGenReg;
    23252325            uint8_t  const cbOpMmio   = cbOp;
    23262326            uint64_t const uSavedRip  = pCtx->rip;
    23272327
    23282328            pCtx->rip += cbOp;
    2329             rc = EMInterpretDisasCurrent(pVM, pVCpu, pDis, &cbOp);
     2329            rc = EMInterpretDisasCurrent(pVM, pVCpu, &Dis, &cbOp);
    23302330            DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, "Following read");
    23312331            pCtx->rip = uSavedRip;
    23322332
    23332333            if (    rc == VINF_SUCCESS
    2334                 &&  pDis->pCurInstr->uOpcode == OP_SHR
    2335                 &&  pDis->Param1.fUse == DISUSE_REG_GEN32
    2336                 &&  pDis->Param1.Base.idxGenReg == idxMmioReg
    2337                 &&  pDis->Param2.fUse == DISUSE_IMMEDIATE8
    2338                 &&  pDis->Param2.uValue == 4
     2334                &&  Dis.pCurInstr->uOpcode == OP_SHR
     2335                &&  Dis.Param1.fUse == DISUSE_REG_GEN32
     2336                &&  Dis.Param1.Base.idxGenReg == idxMmioReg
     2337                &&  Dis.Param2.fUse == DISUSE_IMMEDIATE8
     2338                &&  Dis.Param2.uValue == 4
    23392339                &&  cbOpMmio + cbOp < sizeof(pVM->hm.s.aPatches[idx].aOpcode))
    23402340            {
     
    23522352                abInstr[1] = 0x0f;
    23532353                abInstr[2] = 0x20;
    2354                 abInstr[3] = 0xc0 | pDis->Param1.Base.idxGenReg;
     2354                abInstr[3] = 0xc0 | Dis.Param1.Base.idxGenReg;
    23552355                for (unsigned i = 4; i < pPatch->cbOp; i++)
    23562356                    abInstr[i] = 0x90;  /* nop */
     
    24482448     * Disassemble the instruction and get cracking.
    24492449     */
    2450     PDISCPUSTATE    pDis   = &pVCpu->hm.s.DisState;
     2450    DISCPUSTATE     Dis;
    24512451    uint32_t        cbOp;
    2452     int rc = EMInterpretDisasCurrent(pVM, pVCpu, pDis, &cbOp);
     2452    int rc = EMInterpretDisasCurrent(pVM, pVCpu, &Dis, &cbOp);
    24532453    AssertRC(rc);
    24542454    if (    rc == VINF_SUCCESS
    2455         &&  pDis->pCurInstr->uOpcode == OP_MOV
     2455        &&  Dis.pCurInstr->uOpcode == OP_MOV
    24562456        &&  cbOp >= 5)
    24572457    {
     
    24652465        pPatch->enmType = HMTPRINSTR_JUMP_REPLACEMENT;
    24662466
    2467         if (pDis->Param1.fUse == DISUSE_DISPLACEMENT32)
     2467        if (Dis.Param1.fUse == DISUSE_DISPLACEMENT32)
    24682468        {
    24692469            /*
     
    24842484             * jmp return_address            [E9 return_address]
    24852485             */
    2486             bool fUsesEax = (pDis->Param2.fUse == DISUSE_REG_GEN32 && pDis->Param2.Base.idxGenReg == DISGREG_EAX);
     2486            bool fUsesEax = (Dis.Param2.fUse == DISUSE_REG_GEN32 && Dis.Param2.Base.idxGenReg == DISGREG_EAX);
    24872487
    24882488            aPatch[off++] = 0x51;    /* push ecx */
     
    24922492            aPatch[off++] = 0x31;    /* xor edx, edx */
    24932493            aPatch[off++] = 0xd2;
    2494             if (pDis->Param2.fUse == DISUSE_REG_GEN32)
     2494            if (Dis.Param2.fUse == DISUSE_REG_GEN32)
    24952495            {
    24962496                if (!fUsesEax)
    24972497                {
    24982498                    aPatch[off++] = 0x89;    /* mov eax, src_reg */
    2499                     aPatch[off++] = MAKE_MODRM(3, pDis->Param2.Base.idxGenReg, DISGREG_EAX);
     2499                    aPatch[off++] = MAKE_MODRM(3, Dis.Param2.Base.idxGenReg, DISGREG_EAX);
    25002500                }
    25012501            }
    25022502            else
    25032503            {
    2504                 Assert(pDis->Param2.fUse == DISUSE_IMMEDIATE32);
     2504                Assert(Dis.Param2.fUse == DISUSE_IMMEDIATE32);
    25052505                aPatch[off++] = 0xb8;    /* mov eax, immediate */
    2506                 *(uint32_t *)&aPatch[off] = pDis->Param2.uValue;
     2506                *(uint32_t *)&aPatch[off] = Dis.Param2.uValue;
    25072507                off += sizeof(uint32_t);
    25082508            }
     
    25342534             * jmp return_address            [E9 return_address]
    25352535             */
    2536             Assert(pDis->Param1.fUse == DISUSE_REG_GEN32);
    2537 
    2538             if (pDis->Param1.Base.idxGenReg != DISGREG_ECX)
     2536            Assert(Dis.Param1.fUse == DISUSE_REG_GEN32);
     2537
     2538            if (Dis.Param1.Base.idxGenReg != DISGREG_ECX)
    25392539                aPatch[off++] = 0x51;    /* push ecx */
    2540             if (pDis->Param1.Base.idxGenReg != DISGREG_EDX )
     2540            if (Dis.Param1.Base.idxGenReg != DISGREG_EDX )
    25412541                aPatch[off++] = 0x52;    /* push edx */
    2542             if (pDis->Param1.Base.idxGenReg != DISGREG_EAX)
     2542            if (Dis.Param1.Base.idxGenReg != DISGREG_EAX)
    25432543                aPatch[off++] = 0x50;    /* push eax */
    25442544
     
    25532553            aPatch[off++] = 0x32;
    25542554
    2555             if (pDis->Param1.Base.idxGenReg != DISGREG_EAX)
     2555            if (Dis.Param1.Base.idxGenReg != DISGREG_EAX)
    25562556            {
    25572557                aPatch[off++] = 0x89;    /* mov dst_reg, eax */
    2558                 aPatch[off++] = MAKE_MODRM(3, DISGREG_EAX, pDis->Param1.Base.idxGenReg);
     2558                aPatch[off++] = MAKE_MODRM(3, DISGREG_EAX, Dis.Param1.Base.idxGenReg);
    25592559            }
    25602560
    2561             if (pDis->Param1.Base.idxGenReg != DISGREG_EAX)
     2561            if (Dis.Param1.Base.idxGenReg != DISGREG_EAX)
    25622562                aPatch[off++] = 0x58;    /* pop eax */
    2563             if (pDis->Param1.Base.idxGenReg != DISGREG_EDX )
     2563            if (Dis.Param1.Base.idxGenReg != DISGREG_EDX )
    25642564                aPatch[off++] = 0x5a;    /* pop edx */
    2565             if (pDis->Param1.Base.idxGenReg != DISGREG_ECX)
     2565            if (Dis.Param1.Base.idxGenReg != DISGREG_ECX)
    25662566                aPatch[off++] = 0x59;    /* pop ecx */
    25672567        }
  • trunk/src/VBox/VMM/include/HMInternal.h

    r87491 r87493  
    10991099     *  VMCPU_FF_HM_UPDATE_PAE_PDPES is set). */
    11001100    X86PDPE                 aPdpes[4];
    1101 
    1102     /** For saving stack space, the disassembler state is allocated here instead of
    1103      * on the stack. */
    1104     DISCPUSTATE             DisState;
    11051101
    11061102    /* These two comes because they are accessed from assembly and we don't
     
    13551351            /** Ring 0 handlers for VT-x. */
    13561352            PFNHMSVMVMRUN               pfnVMRun;
     1353
     1354            /** For saving stack space, the disassembler state is allocated here
     1355             * instead of on the stack. */
     1356            DISCPUSTATE                 DisState;
    13571357        } svm;
    13581358    } HM_UNION_NM(u);
  • trunk/src/VBox/VMM/include/HMInternal.mac

    r87491 r87493  
    193193    .aPdpes                         resq    4
    194194
    195     .DisState                       resb    0d8h
    196 
    197195    .StatVmxWriteHostRip            resq    1
    198196    .StatVmxWriteHostRsp            resq    1
     
    223221struc HMR0CPUSVM
    224222    .pfnVMRun                       RTR0PTR_RES  1
     223
     224    .DisState                       resb    0d8h
    225225endstruc
    226226
  • trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp

    r87469 r87493  
    384384    CHECK_MEMBER_ALIGNMENT(HMCPU, Event, 8);
    385385    CHECK_MEMBER_ALIGNMENT(HMCPU, Event.u64IntInfo, 8);
    386     CHECK_MEMBER_ALIGNMENT(HMCPU, DisState, 8);
     386    CHECK_MEMBER_ALIGNMENT(HMR0PERVCPU, svm.DisState, 8);
    387387    CHECK_MEMBER_ALIGNMENT(HMCPU, StatEntry, 8);
    388388
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