VirtualBox

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


Ignore:
Timestamp:
Jan 15, 2019 4:51:22 AM (6 years ago)
Author:
vboxsync
Message:

VMM: Nested VMX: bugref:9180 Do the injection from IEM itself.

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

Legend:

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

    r76798 r76821  
    821821
    822822/**
    823  * Injects an event using TRPM given a VM-entry interruption info. and related
    824  * fields.
    825  *
    826  * @returns VBox status code.
    827  * @param   pVCpu               The cross context virtual CPU structure.
    828  * @param   uEntryIntInfo       The VM-entry interruption info.
    829  * @param   uErrCode            The error code associated with the event if any.
    830  * @param   cbInstr             The VM-entry instruction length (for software
    831  *                              interrupts and software exceptions). Pass 0
    832  *                              otherwise.
    833  * @param   GCPtrFaultAddress   The guest CR2 if this is a \#PF event.
    834  */
    835 VMM_INT_DECL(int) HMVmxEntryIntInfoInjectTrpmEvent(PVMCPU pVCpu, uint32_t uEntryIntInfo, uint32_t uErrCode, uint32_t cbInstr,
    836                                                    RTGCUINTPTR GCPtrFaultAddress)
    837 {
    838     Assert(VMX_ENTRY_INT_INFO_IS_VALID(uEntryIntInfo));
    839 
    840     uint8_t const uType         = VMX_ENTRY_INT_INFO_TYPE(uEntryIntInfo);
    841     uint8_t const uVector       = VMX_ENTRY_INT_INFO_VECTOR(uEntryIntInfo);
    842     bool const    fErrCodeValid = VMX_ENTRY_INT_INFO_IS_ERROR_CODE_VALID(uEntryIntInfo);
    843 
    844     TRPMEVENT enmTrapType;
    845     switch (uType)
    846     {
    847         case VMX_ENTRY_INT_INFO_TYPE_EXT_INT:
    848            enmTrapType = TRPM_HARDWARE_INT;
    849            break;
    850 
    851         case VMX_ENTRY_INT_INFO_TYPE_SW_INT:
    852             enmTrapType = TRPM_SOFTWARE_INT;
    853             break;
    854 
    855         case VMX_ENTRY_INT_INFO_TYPE_NMI:
    856         case VMX_ENTRY_INT_INFO_TYPE_PRIV_SW_XCPT:  /* ICEBP. */
    857         case VMX_ENTRY_INT_INFO_TYPE_SW_XCPT:       /* #BP and #OF */
    858         case VMX_ENTRY_INT_INFO_TYPE_HW_XCPT:
    859             enmTrapType = TRPM_TRAP;
    860             break;
    861 
    862         default:
    863             /* Shouldn't really happen. */
    864             AssertMsgFailedReturn(("Invalid trap type %#x\n", uType), VERR_VMX_IPE_4);
    865             break;
    866     }
    867 
    868     int rc = TRPMAssertTrap(pVCpu, uVector, enmTrapType);
    869     AssertRCReturn(rc, rc);
    870 
    871     if (fErrCodeValid)
    872         TRPMSetErrorCode(pVCpu, uErrCode);
    873 
    874     if (   uType   == VMX_ENTRY_INT_INFO_TYPE_HW_XCPT
    875         && uVector == X86_XCPT_PF)
    876         TRPMSetFaultAddress(pVCpu, GCPtrFaultAddress);
    877     else if (   uType == VMX_ENTRY_INT_INFO_TYPE_SW_INT
    878              || uType == VMX_ENTRY_INT_INFO_TYPE_SW_XCPT
    879              || uType == VMX_ENTRY_INT_INFO_TYPE_PRIV_SW_XCPT)
    880     {
    881         AssertMsg(   uType == VMX_IDT_VECTORING_INFO_TYPE_SW_INT
    882                   || (uVector == X86_XCPT_BP || uVector == X86_XCPT_OF),
    883                   ("Invalid vector: uVector=%#x uVectorType=%#x\n", uVector, uType));
    884         TRPMSetInstrLength(pVCpu, cbInstr);
    885     }
    886 
    887     return VINF_SUCCESS;
    888 }
    889 
    890 
    891 /**
    892823 * Gets the permission bits for the specified MSR in the specified MSR bitmap.
    893824 *
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r76810 r76821  
    70837083
    70847084/**
     7085 * Injects an event using TRPM given a VM-entry interruption info. and related
     7086 * fields.
     7087 *
     7088 * @returns VBox status code.
     7089 * @param   pVCpu               The cross context virtual CPU structure.
     7090 * @param   uEntryIntInfo       The VM-entry interruption info.
     7091 * @param   uErrCode            The error code associated with the event if any.
     7092 * @param   cbInstr             The VM-entry instruction length (for software
     7093 *                              interrupts and software exceptions). Pass 0
     7094 *                              otherwise.
     7095 * @param   GCPtrFaultAddress   The guest CR2 if this is a \#PF event.
     7096 */
     7097IEM_STATIC int iemVmxVmentryInjectTrpmEvent(PVMCPU pVCpu, uint32_t uEntryIntInfo, uint32_t uErrCode, uint32_t cbInstr,
     7098                                            RTGCUINTPTR GCPtrFaultAddress)
     7099{
     7100    Assert(VMX_ENTRY_INT_INFO_IS_VALID(uEntryIntInfo));
     7101
     7102    uint8_t const uType         = VMX_ENTRY_INT_INFO_TYPE(uEntryIntInfo);
     7103    uint8_t const uVector       = VMX_ENTRY_INT_INFO_VECTOR(uEntryIntInfo);
     7104    bool const    fErrCodeValid = VMX_ENTRY_INT_INFO_IS_ERROR_CODE_VALID(uEntryIntInfo);
     7105
     7106    TRPMEVENT enmTrapType;
     7107    switch (uType)
     7108    {
     7109        case VMX_ENTRY_INT_INFO_TYPE_EXT_INT:
     7110           enmTrapType = TRPM_HARDWARE_INT;
     7111           break;
     7112
     7113        case VMX_ENTRY_INT_INFO_TYPE_SW_INT:
     7114            enmTrapType = TRPM_SOFTWARE_INT;
     7115            break;
     7116
     7117        case VMX_ENTRY_INT_INFO_TYPE_NMI:
     7118        case VMX_ENTRY_INT_INFO_TYPE_PRIV_SW_XCPT:  /* ICEBP. */
     7119        case VMX_ENTRY_INT_INFO_TYPE_SW_XCPT:       /* #BP and #OF */
     7120        case VMX_ENTRY_INT_INFO_TYPE_HW_XCPT:
     7121            enmTrapType = TRPM_TRAP;
     7122            break;
     7123
     7124        default:
     7125            /* Shouldn't really happen. */
     7126            AssertMsgFailedReturn(("Invalid trap type %#x\n", uType), VERR_VMX_IPE_4);
     7127            break;
     7128    }
     7129
     7130    int rc = TRPMAssertTrap(pVCpu, uVector, enmTrapType);
     7131    AssertRCReturn(rc, rc);
     7132
     7133    if (fErrCodeValid)
     7134        TRPMSetErrorCode(pVCpu, uErrCode);
     7135
     7136    if (   uType   == VMX_ENTRY_INT_INFO_TYPE_HW_XCPT
     7137        && uVector == X86_XCPT_PF)
     7138        TRPMSetFaultAddress(pVCpu, GCPtrFaultAddress);
     7139    else if (   uType == VMX_ENTRY_INT_INFO_TYPE_SW_INT
     7140             || uType == VMX_ENTRY_INT_INFO_TYPE_SW_XCPT
     7141             || uType == VMX_ENTRY_INT_INFO_TYPE_PRIV_SW_XCPT)
     7142    {
     7143        AssertMsg(   uType == VMX_IDT_VECTORING_INFO_TYPE_SW_INT
     7144                  || (uVector == X86_XCPT_BP || uVector == X86_XCPT_OF),
     7145                  ("Invalid vector: uVector=%#x uVectorType=%#x\n", uVector, uType));
     7146        TRPMSetInstrLength(pVCpu, cbInstr);
     7147    }
     7148
     7149    return VINF_SUCCESS;
     7150}
     7151
     7152
     7153/**
    70857154 * Performs event injection (if any) as part of VM-entry.
    70867155 *
     
    71147183        }
    71157184
    7116         return HMVmxEntryIntInfoInjectTrpmEvent(pVCpu, uEntryIntInfo, pVmcs->u32EntryXcptErrCode, pVmcs->u32EntryInstrLen,
    7117                                                 pVCpu->cpum.GstCtx.cr2);
     7185        return iemVmxVmentryInjectTrpmEvent(pVCpu, uEntryIntInfo, pVmcs->u32EntryXcptErrCode, pVmcs->u32EntryInstrLen,
     7186                                            pVCpu->cpum.GstCtx.cr2);
    71187187    }
    71197188
     
    71297198                                    | RT_BF_MAKE(VMX_BF_ENTRY_INT_INFO_TYPE, VMX_ENTRY_INT_INFO_TYPE_HW_XCPT)
    71307199                                    | RT_BF_MAKE(VMX_BF_ENTRY_INT_INFO_VALID, 1);
    7131         return HMVmxEntryIntInfoInjectTrpmEvent(pVCpu, uDbgXcptInfo, 0 /* uErrCode */, pVmcs->u32EntryInstrLen,
    7132                                                 0 /* GCPtrFaultAddress */);
     7200        return iemVmxVmentryInjectTrpmEvent(pVCpu, uDbgXcptInfo, 0 /* uErrCode */, pVmcs->u32EntryInstrLen,
     7201                                            0 /* GCPtrFaultAddress */);
    71337202    }
    71347203
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