VirtualBox

Ignore:
Timestamp:
Jun 7, 2018 11:35:23 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
122954
Message:

GIM,IEM: Correctly hook up hypercalls thru IEM. bugref:9044

  • IEM: Pass opcode and instruction length to GIM so it can do patching.
  • GIM: Introduced GIMHypercallEx API for receiving hypercalls with instruction opcode+length. Hooking this into the exiting #UD code paths.
  • GIM: Move the VMMPatchHypercall API into GIM and corrected the name to GIMQueryHypercallOpcodeBytes.
  • GIM/KVM: Use GIMQueryHypercallOpcodeBytes to decide which instruction is native and cache the opcode bytes for patching.
  • GIM/KVM: Check the VMCALL instruction encoding length rather than assuming its always 3 bytes when patching.
File:
1 edited

Legend:

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

    r72462 r72469  
    13811381
    13821382/**
    1383  * Checks the currently disassembled instruction and executes the hypercall if
    1384  * it's a hypercall instruction.
     1383 * Checks the instruction and executes the hypercall if it's a valid hypercall
     1384 * instruction.
     1385 *
     1386 * This interface is used by \#UD handlers and IEM.
    13851387 *
    13861388 * @returns Strict VBox status code.
    13871389 * @param   pVCpu       The cross context virtual CPU structure.
    13881390 * @param   pCtx        Pointer to the guest-CPU context.
    1389  * @param   pDis        Pointer to the disassembled instruction state at RIP.
     1391 * @param   uDisOpcode  The disassembler opcode.
     1392 * @param   cbInstr     The instruction length.
    13901393 *
    13911394 * @thread  EMT(pVCpu).
    1392  *
    1393  * @todo    Make this function static when @bugref{7270#c168} is addressed.
    1394  */
    1395 VMM_INT_DECL(VBOXSTRICTRC) gimHvExecHypercallInstr(PVMCPU pVCpu, PCPUMCTX pCtx, PDISCPUSTATE pDis)
     1395 */
     1396VMM_INT_DECL(VBOXSTRICTRC) gimHvHypercallEx(PVMCPU pVCpu, PCPUMCTX pCtx, unsigned uDisOpcode, uint8_t cbInstr)
    13961397{
    13971398    Assert(pVCpu);
    13981399    Assert(pCtx);
    1399     Assert(pDis);
    14001400    VMCPU_ASSERT_EMT(pVCpu);
    14011401
    14021402    PVM pVM = pVCpu->CTX_SUFF(pVM);
    1403     CPUMCPUVENDOR const enmGuestCpuVendor = CPUMGetGuestCpuVendor(pVM);
    1404     if (   (   pDis->pCurInstr->uOpcode == OP_VMCALL
     1403    CPUMCPUVENDOR const enmGuestCpuVendor = (CPUMCPUVENDOR)pVM->cpum.ro.GuestFeatures.enmCpuVendor;
     1404    if (   (   uDisOpcode == OP_VMCALL
    14051405            && (   enmGuestCpuVendor == CPUMCPUVENDOR_INTEL
    14061406                || enmGuestCpuVendor == CPUMCPUVENDOR_VIA))
    1407         || (   pDis->pCurInstr->uOpcode == OP_VMMCALL
     1407        || (   uDisOpcode == OP_VMMCALL
    14081408            && enmGuestCpuVendor == CPUMCPUVENDOR_AMD))
    1409     {
    14101409        return gimHvHypercall(pVCpu, pCtx);
    1411     }
    1412 
     1410
     1411    RT_NOREF_PV(cbInstr);
    14131412    return VERR_GIM_INVALID_HYPERCALL_INSTR;
    14141413}
     
    14601459            if (pcbInstr)
    14611460                *pcbInstr = (uint8_t)cbInstr;
    1462             return gimHvExecHypercallInstr(pVCpu, pCtx, &Dis);
     1461            return gimHvHypercallEx(pVCpu, pCtx, Dis.pCurInstr->uOpcode, Dis.cbInstr);
    14631462        }
    14641463
     
    14671466    }
    14681467
    1469     return gimHvExecHypercallInstr(pVCpu, pCtx, pDis);
     1468    return gimHvHypercallEx(pVCpu, pCtx, pDis->pCurInstr->uOpcode, pDis->cbInstr);
    14701469}
    14711470
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