VirtualBox

Changeset 73752 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Aug 18, 2018 4:04:56 AM (6 years ago)
Author:
vboxsync
Message:

VMM/IEM: Nested VMX: bugref:9180 Implement VMPTRST, added decoded interface for VMPTRLD as well.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
4 edited

Legend:

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

    r73745 r73752  
    8282    VMX_INSTR_DIAG_DESC(kVmxVInstrDiag_Vmptrld_Success     , "Success"      ),
    8383    VMX_INSTR_DIAG_DESC(kVmxVInstrDiag_Vmptrld_VmcsRevId   , "VmcsRevId"    )
     84    /* VMPTRST. */
     85    VMX_INSTR_DIAG_DESC(kVmxVInstrDiag_Vmptrst_Cpl         , "Cpl"          ),
     86    VMX_INSTR_DIAG_DESC(kVmxVInstrDiag_Vmptrst_PtrMap      , "PtrMap"       )
    8487    /* kVmxVInstrDiag_Last */
    8588};
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r73745 r73752  
    1553115531
    1553215532/**
    15533  * Interface for HM and EM to emulate the VMXOFF instruction.
     15533 * Interface for HM and EM to emulate the VMPTRLD instruction.
    1553415534 *
    1553515535 * @returns Strict VBox status code.
    15536  * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
    15537  * @param   cbInstr     The instruction length in bytes.
     15536 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
     15537 * @param   cbInstr         The instruction length in bytes.
     15538 * @param   GCPtrVmxon      The linear address of the VMCS pointer.
     15539 * @param   uExitInstrInfo  The VM-exit instruction information field.
     15540 * @param   GCPtrDisp       The displacement field for @a GCPtrVmcs if any.
    1553815541 * @thread  EMT(pVCpu)
    1553915542 */
    15540 VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmxoff(PVMCPU pVCpu, uint8_t cbInstr)
     15543VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmptrld(PVMCPU pVCpu, uint8_t cbInstr, RTGCPHYS GCPtrVmcs, uint32_t uExitInstrInfo,
     15544                                                 RTGCPTR GCPtrDisp)
    1554115545{
    1554215546    IEMEXEC_ASSERT_INSTR_LEN_RETURN(cbInstr, 3);
     15547    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_HWVIRT);
    1554315548
    1554415549    iemInitExec(pVCpu, false /*fBypassHandlers*/);
    15545     VBOXSTRICTRC rcStrict = IEM_CIMPL_CALL_0(iemCImpl_vmxoff);
    15546     Assert(!pVCpu->iem.s.cActiveMappings);
    15547     return iemUninitExecAndFiddleStatusAndMaybeReenter(pVCpu, rcStrict);
     15550    PCVMXEXITINSTRINFO pExitInstrInfo = (PCVMXEXITINSTRINFO)&uExitInstrInfo;
     15551    VBOXSTRICTRC rcStrict = iemVmxVmptrld(pVCpu, cbInstr, GCPtrVmcs, pExitInstrInfo, GCPtrDisp);
     15552    if (pVCpu->iem.s.cActiveMappings)
     15553        iemMemRollback(pVCpu);
     15554    return iemExecStatusCodeFiddling(pVCpu, rcStrict);
     15555}
     15556
     15557
     15558/**
     15559 * Interface for HM and EM to emulate the VMPTRST instruction.
     15560 *
     15561 * @returns Strict VBox status code.
     15562 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
     15563 * @param   cbInstr         The instruction length in bytes.
     15564 * @param   GCPtrVmxon      The linear address of where to store the VMCS pointer.
     15565 * @param   uExitInstrInfo  The VM-exit instruction information field.
     15566 * @param   GCPtrDisp       The displacement field for @a GCPtrVmcs if any.
     15567 * @thread  EMT(pVCpu)
     15568 */
     15569VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmptrst(PVMCPU pVCpu, uint8_t cbInstr, RTGCPHYS GCPtrVmcs, uint32_t uExitInstrInfo,
     15570                                                 RTGCPTR GCPtrDisp)
     15571{
     15572    IEMEXEC_ASSERT_INSTR_LEN_RETURN(cbInstr, 3);
     15573    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_HWVIRT);
     15574
     15575    iemInitExec(pVCpu, false /*fBypassHandlers*/);
     15576    PCVMXEXITINSTRINFO pExitInstrInfo = (PCVMXEXITINSTRINFO)&uExitInstrInfo;
     15577    VBOXSTRICTRC rcStrict = iemVmxVmptrst(pVCpu, cbInstr, GCPtrVmcs, pExitInstrInfo, GCPtrDisp);
     15578    if (pVCpu->iem.s.cActiveMappings)
     15579        iemMemRollback(pVCpu);
     15580    return iemExecStatusCodeFiddling(pVCpu, rcStrict);
    1554815581}
    1554915582
     
    1557215605        iemMemRollback(pVCpu);
    1557315606    return iemExecStatusCodeFiddling(pVCpu, rcStrict);
     15607}
     15608
     15609
     15610/**
     15611 * Interface for HM and EM to emulate the VMXOFF instruction.
     15612 *
     15613 * @returns Strict VBox status code.
     15614 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
     15615 * @param   cbInstr     The instruction length in bytes.
     15616 * @thread  EMT(pVCpu)
     15617 */
     15618VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmxoff(PVMCPU pVCpu, uint8_t cbInstr)
     15619{
     15620    IEMEXEC_ASSERT_INSTR_LEN_RETURN(cbInstr, 3);
     15621
     15622    iemInitExec(pVCpu, false /*fBypassHandlers*/);
     15623    VBOXSTRICTRC rcStrict = IEM_CIMPL_CALL_0(iemCImpl_vmxoff);
     15624    Assert(!pVCpu->iem.s.cActiveMappings);
     15625    return iemUninitExecAndFiddleStatusAndMaybeReenter(pVCpu, rcStrict);
    1557415626}
    1557515627
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r73745 r73752  
    481481
    482482/**
     483 * VMPTRST instruction execution worker.
     484 *
     485 * @param   pVCpu           The cross context virtual CPU structure.
     486 * @param   cbInstr         The instruction length.
     487 * @param   GCPtrVmcs       The linear address of where to store the current VMCS
     488 *                          pointer.
     489 * @param   pExitInstrInfo  Pointer to the VM-exit instruction information field.
     490 * @param   GCPtrDisp       The displacement field for @a GCPtrVmcs if any.
     491 *
     492 * @remarks Common VMX instruction checks are already expected to by the caller,
     493 *          i.e. VMX operation, CR4.VMXE, Real/V86 mode, EFER/CS.L checks.
     494 */
     495IEM_STATIC VBOXSTRICTRC iemVmxVmptrst(PVMCPU pVCpu, uint8_t cbInstr, RTGCPHYS GCPtrVmcs, PCVMXEXITINSTRINFO pExitInstrInfo,
     496                                      RTGCPTR GCPtrDisp)
     497{
     498    if (IEM_IS_VMX_NON_ROOT_MODE(pVCpu))
     499    {
     500        RT_NOREF(GCPtrDisp);
     501        /** @todo NSTVMX: intercept. */
     502    }
     503    Assert(IEM_IS_VMX_ROOT_MODE(pVCpu));
     504
     505    /* CPL. */
     506    if (CPUMGetGuestCPL(pVCpu) > 0)
     507    {
     508        Log(("vmptrst: CPL %u -> #GP(0)\n", pVCpu->iem.s.uCpl));
     509        pVCpu->cpum.GstCtx.hwvirt.vmx.enmInstrDiag = kVmxVInstrDiag_Vmptrst_Cpl;
     510        return iemRaiseGeneralProtectionFault0(pVCpu);
     511    }
     512
     513    /* Set the VMCS pointer to the location specified by the destination memory operand. */
     514    Assert(NIL_RTGCPHYS == ~(RTGCPHYS)0U);
     515    VBOXSTRICTRC rcStrict = iemMemStoreDataU64(pVCpu, pExitInstrInfo->VmxXsave.iSegReg, GCPtrVmcs,
     516                                               pVCpu->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs);
     517    if (RT_LIKELY(rcStrict == VINF_SUCCESS))
     518    {
     519        iemVmxVmSucceed(pVCpu);
     520        iemRegAddToRipAndClearRF(pVCpu, cbInstr);
     521        return rcStrict;
     522    }
     523
     524    Log(("vmptrld: Failed to store VMCS pointer to memory at destination operand %#Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
     525    pVCpu->cpum.GstCtx.hwvirt.vmx.enmInstrDiag = kVmxVInstrDiag_Vmptrst_PtrMap;
     526    return rcStrict;
     527}
     528
     529
     530/**
    483531 * VMPTRLD instruction execution worker.
    484532 *
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsTwoByte0f.cpp.h

    r73745 r73752  
    84618461
    84628462/** Opcode [0xf3] 0x0f 0xc7 !11/7. */
     8463#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
     8464FNIEMOP_DEF_1(iemOp_Grp9_vmptrst_Mq, uint8_t, bRm)
     8465{
     8466    IEMOP_MNEMONIC(vmptrst, "vmptrst");
     8467    IEMOP_HLP_IN_VMX_OPERATION();
     8468    IEMOP_HLP_VMX_INSTR();
     8469    IEM_MC_BEGIN(1, 0);
     8470    IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 0);
     8471    IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
     8472    IEMOP_HLP_DONE_DECODING_NO_LOCK_REPZ_OR_REPNZ_PREFIXES();
     8473    IEM_MC_CALL_CIMPL_1(iemCImpl_vmptrld, GCPtrEffDst);
     8474    IEM_MC_END();
     8475    return VINF_SUCCESS;
     8476}
     8477#else
    84638478FNIEMOP_UD_STUB_1(iemOp_Grp9_vmptrst_Mq, uint8_t, bRm);
     8479#endif
    84648480
    84658481/** Opcode 0x0f 0xc7 11/7. */
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