VirtualBox

Changeset 78638 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 21, 2019 4:15:58 PM (6 years ago)
Author:
vboxsync
Message:

VMM/IEM: Nested VMX: bugref:9180 Added IEMExecVmxVmexitTaskSwitch interface for handling VM-exits with decode info. from HM.

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

Legend:

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

    r78592 r78638  
    1593415934 * @returns Strict VBox status code.
    1593515935 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
    15936  * @param   pExitInfo   Pointer to the VM-exit information struct.
     15936 * @param   pExitInfo   Pointer to the VM-exit information.
    1593715937 * @thread  EMT(pVCpu)
    1593815938 */
     
    1595415954 * @returns Strict VBox status code.
    1595515955 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
    15956  * @param   pExitInfo   The VM-exit reason.
     15956 * @param   pExitInfo   Pointer to the VM-exit information.
    1595715957 * @param   cbInstr     The instruction length in bytes.
    1595815958 * @thread  EMT(pVCpu)
     
    1596815968
    1596915969/**
    15970  * Interface for HM and EM to emulate the VMREAD instruction.
     15970 * Interface for HM and EM to emulate a VM-exit due to a task switch.
    1597115971 *
    1597215972 * @returns Strict VBox status code.
    1597315973 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
    15974  * @param   pExitInfo       Pointer to the VM-exit information struct.
     15974 * @param   pExitInfo       Pointer to the VM-exit information.
     15975 * @param   pExitEventInfo  Pointer to the VM-exit event information.
     15976 * @thread  EMT(pVCpu)
     15977 */
     15978VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitTaskSwitch(PVMCPU pVCpu, PVMXVEXITINFO pExitInfo, PVMXVEXITEVENTINFO pExitEventInfo)
     15979{
     15980    VBOXSTRICTRC rcStrict = iemVmxVmexitTaskSwitchWithInfo(pVCpu, pExitInfo, pExitEventInfo);
     15981    if (pVCpu->iem.s.cActiveMappings)
     15982        iemMemRollback(pVCpu);
     15983    return iemExecStatusCodeFiddling(pVCpu, rcStrict);
     15984}
     15985
     15986
     15987/**
     15988 * Interface for HM and EM to emulate the VMREAD instruction.
     15989 *
     15990 * @returns Strict VBox status code.
     15991 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
     15992 * @param   pExitInfo       Pointer to the VM-exit information.
    1597515993 * @thread  EMT(pVCpu)
    1597615994 */
     
    1601816036 * @returns Strict VBox status code.
    1601916037 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
    16020  * @param   pExitInfo       Pointer to the VM-exit information struct.
     16038 * @param   pExitInfo       Pointer to the VM-exit information.
    1602116039 * @thread  EMT(pVCpu)
    1602216040 */
     
    1605616074 * @returns Strict VBox status code.
    1605716075 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
    16058  * @param   pExitInfo       Pointer to the VM-exit information struct.
     16076 * @param   pExitInfo       Pointer to the VM-exit information.
    1605916077 * @thread  EMT(pVCpu)
    1606016078 */
     
    1608116099 * @returns Strict VBox status code.
    1608216100 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
    16083  * @param   pExitInfo       Pointer to the VM-exit information struct.
     16101 * @param   pExitInfo       Pointer to the VM-exit information.
    1608416102 * @thread  EMT(pVCpu)
    1608516103 */
     
    1610616124 * @returns Strict VBox status code.
    1610716125 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
    16108  * @param   pExitInfo       Pointer to the VM-exit information struct.
     16126 * @param   pExitInfo       Pointer to the VM-exit information.
    1610916127 * @thread  EMT(pVCpu)
    1611016128 */
     
    1615316171 * @returns Strict VBox status code.
    1615416172 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
    16155  * @param   pExitInfo       Pointer to the VM-exit information struct.
     16173 * @param   pExitInfo       Pointer to the VM-exit information.
    1615616174 * @thread  EMT(pVCpu)
    1615716175 */
     
    1619816216 * @returns Strict VBox status code.
    1619916217 * @param   pVCpu           The cross context virtual CPU structure of the calling EMT.
    16200  * @param   pExitInfo       Pointer to the VM-exit information struct.
     16218 * @param   pExitInfo       Pointer to the VM-exit information.
    1620116219 * @thread  EMT(pVCpu)
    1620216220 */
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r78621 r78638  
    27912791        bool const fInEventDelivery = IEMGetCurrentXcpt(pVCpu, &uVector, &fFlags,  &uErrCode, NULL /* uCr2 */);
    27922792        if (!fInEventDelivery)
     2793        {
    27932794            iemVmxVmcsSetIdtVectoringInfo(pVCpu, 0);
     2795            iemVmxVmcsSetIdtVectoringErrCode(pVCpu, 0);  /* Not strictly needed but do it for consistency. */
     2796        }
    27942797        /* else: Caller would have updated IDT-vectoring information already, see iemVmxVmexitEvent(). */
    27952798    }
     
    29002903 * @returns Strict VBox status code.
    29012904 * @param   pVCpu           The cross context virtual CPU structure.
    2902  * @param   pExitInfo       Pointer to the VM-exit instruction information struct.
     2905 * @param   pExitInfo       Pointer to the VM-exit information.
    29032906 */
    29042907IEM_STATIC VBOXSTRICTRC iemVmxVmexitInstrWithInfo(PVMCPU pVCpu, PCVMXVEXITINFO pExitInfo)
     
    37393742    iemVmxVmcsSetExitQual(pVCpu, uExitQual);
    37403743    iemVmxVmcsSetExitInstrLen(pVCpu, cbInstr);
     3744    return iemVmxVmexit(pVCpu, VMX_EXIT_TASK_SWITCH);
     3745}
     3746
     3747
     3748/**
     3749 * VMX VM-exit handler for VM-exits due to task switches.
     3750 *
     3751 * This is intended for task switches where the caller provides all the relevant
     3752 * VM-exit information.
     3753 *
     3754 * @returns VBox strict status code.
     3755 * @param   pVCpu               The cross context virtual CPU structure.
     3756 * @param   pExitInfo           Pointer to the VM-exit information.
     3757 * @param   pExitEventInfo      Pointer to the VM-exit event information.
     3758 */
     3759IEM_STATIC VBOXSTRICTRC iemVmxVmexitTaskSwitchWithInfo(PVMCPU pVCpu, PVMXVEXITINFO pExitInfo, PVMXVEXITEVENTINFO pExitEventInfo)
     3760{
     3761    Assert(pExitInfo);
     3762    Assert(pExitEventInfo);
     3763
     3764    /* The VM-exit qualification is mandatory for all task-switch VM-exits. */
     3765    uint64_t const u64ExitQual = pExitInfo->u64Qual;
     3766    iemVmxVmcsSetExitQual(pVCpu, u64ExitQual);
     3767
     3768    /*
     3769     * Figure out if an instruction was the source of the task switch.
     3770     *
     3771     * If the task-switch was due to CALL/IRET/JMP instruction or due to the delivery
     3772     * of an event generated by a software interrupt (INT-N), privileged software
     3773     * interrupt (INT1/ICEBP) or software exception (INT3/INTO) then the CPU provides
     3774     * the instruction length.
     3775     */
     3776    bool fHasInstrLen;
     3777    if (VMX_EXIT_QUAL_TASK_SWITCH_TYPE(u64ExitQual) == VMX_EXIT_QUAL_TASK_SWITCH_TYPE_IDT)
     3778    {
     3779        /* Check if an event delivery through IDT caused a task switch VM-exit. */
     3780        uint32_t const uIdtVectInfo      = pExitEventInfo->uIdtVectoringInfo;
     3781        bool const     fIdtVectInfoValid = VMX_IDT_VECTORING_INFO_IS_VALID(uIdtVectInfo);
     3782        if (fIdtVectInfoValid)
     3783        {
     3784            iemVmxVmcsSetIdtVectoringInfo(pVCpu, uIdtVectInfo);
     3785            if (VMX_IDT_VECTORING_INFO_IS_ERROR_CODE_VALID(uIdtVectInfo))
     3786                iemVmxVmcsSetIdtVectoringErrCode(pVCpu, pExitEventInfo->uIdtVectoringErrCode);
     3787
     3788            uint8_t const fIdtVectType = VMX_IDT_VECTORING_INFO_TYPE(uIdtVectInfo);
     3789            if (   fIdtVectType == VMX_IDT_VECTORING_INFO_TYPE_SW_INT
     3790                || fIdtVectType == VMX_IDT_VECTORING_INFO_TYPE_PRIV_SW_XCPT
     3791                || fIdtVectType == VMX_IDT_VECTORING_INFO_TYPE_SW_XCPT)
     3792                fHasInstrLen = true;
     3793            else
     3794                fHasInstrLen = false;
     3795        }
     3796        else
     3797            fHasInstrLen = false;
     3798    }
     3799    else
     3800    {
     3801        /* CALL, IRET or JMP instruction caused the task switch VM-exit. */
     3802        fHasInstrLen = true;
     3803    }
     3804
     3805    if (fHasInstrLen)
     3806    {
     3807        Assert(pExitInfo->cbInstr > 0);
     3808        iemVmxVmcsSetExitInstrLen(pVCpu, pExitInfo->cbInstr);
     3809    }
    37413810    return iemVmxVmexit(pVCpu, VMX_EXIT_TASK_SWITCH);
    37423811}
     
    78027871 *                          VINF_SUCCESS is returned).
    78037872 * @param   u64FieldEnc     The VMCS field encoding.
    7804  * @param   pExitInfo       Pointer to the VM-exit information struct. Optional, can
    7805  *                          be NULL.
     7873 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
     7874 *                          NULL.
    78067875 */
    78077876IEM_STATIC VBOXSTRICTRC iemVmxVmreadCommon(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64FieldEnc,
     
    79167985 * @param   pu64Dst         Where to store the VMCS field's value.
    79177986 * @param   u64FieldEnc     The VMCS field encoding.
    7918  * @param   pExitInfo       Pointer to the VM-exit information struct. Optional, can
    7919  *                          be NULL.
     7987 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
     7988 *                          NULL.
    79207989 */
    79217990IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg64(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64FieldEnc,
     
    79428011 * @param   pu32Dst         Where to store the VMCS field's value.
    79438012 * @param   u32FieldEnc     The VMCS field encoding.
    7944  * @param   pExitInfo       Pointer to the VM-exit information struct. Optional, can
    7945  *                          be NULL.
     8013 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
     8014 *                          NULL.
    79468015 */
    79478016IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg32(PVMCPU pVCpu, uint8_t cbInstr, uint32_t *pu32Dst, uint64_t u32FieldEnc,
     
    79738042 *                          value.
    79748043 * @param   u64FieldEnc     The VMCS field encoding.
    7975  * @param   pExitInfo       Pointer to the VM-exit information struct. Optional, can
    7976  *                          be NULL.
     8044 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
     8045 *                          NULL.
    79778046 */
    79788047IEM_STATIC VBOXSTRICTRC iemVmxVmreadMem(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrDst, uint64_t u64FieldEnc,
     
    80188087 *                          operand.
    80198088 * @param   u64FieldEnc     The VMCS field encoding.
    8020  * @param   pExitInfo       Pointer to the VM-exit information struct. Optional, can
    8021  *                          be NULL.
     8089 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
     8090 *                          NULL.
    80228091 */
    80238092IEM_STATIC VBOXSTRICTRC iemVmxVmwrite(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, uint64_t u64Val, uint64_t u64FieldEnc,
     
    81708239 * @param   iEffSeg         The effective segment register to use with @a GCPtrVmcs.
    81718240 * @param   GCPtrVmcs       The linear address of the VMCS pointer.
    8172  * @param   pExitInfo       Pointer to the VM-exit information struct. Optional, can
    8173  *                          be NULL.
     8241 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
     8242 *                          NULL.
    81748243 *
    81758244 * @remarks Common VMX instruction checks are already expected to by the caller,
     
    83018370 * @param   GCPtrVmcs       The linear address of where to store the current VMCS
    83028371 *                          pointer.
    8303  * @param   pExitInfo       Pointer to the VM-exit information struct. Optional, can
    8304  *                          be NULL.
     8372 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
     8373 *                          NULL.
    83058374 *
    83068375 * @remarks Common VMX instruction checks are already expected to by the caller,
     
    83538422 * @param   cbInstr         The instruction length in bytes.
    83548423 * @param   GCPtrVmcs       The linear address of the current VMCS pointer.
    8355  * @param   pExitInfo       Pointer to the VM-exit information struct. Optional, can
    8356  *                          be NULL.
     8424 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
     8425 *                          NULL.
    83578426 *
    83588427 * @remarks Common VMX instruction checks are already expected to by the caller,
     
    85348603 * @param   GCPtrInvvpidDesc    The address of invvpid descriptor.
    85358604 * @param   u64InvvpidType      The invalidation type.
    8536  * @param   pExitInfo           Pointer to the VM-exit information struct. Optional,
    8537  *                              can be NULL.
     8605 * @param   pExitInfo           Pointer to the VM-exit information. Optional, can be
     8606 *                              NULL.
    85388607 *
    85398608 * @remarks Common VMX instruction checks are already expected to by the caller,
     
    87048773 *                          GCPtrVmxon.
    87058774 * @param   GCPtrVmxon      The linear address of the VMXON pointer.
    8706  * @param   pExitInfo       Pointer to the VM-exit instruction information struct.
    8707  *                          Optional, can  be NULL.
     8775 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
     8776 *                          NULL.
    87088777 *
    87098778 * @remarks Common VMX instruction checks are already expected to by the caller,
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