VirtualBox

Changeset 77569 in vbox


Ignore:
Timestamp:
Mar 6, 2019 8:18:51 AM (6 years ago)
Author:
vboxsync
Message:

VMM/IEM: Nested VMX: bugref:9180 On-demand importing of externally kept guest-CPU state for VM-exits and tightening of importing externally kept guest-CPU state on VMLAUNCH/VMRESUME.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/iem.h

    r77380 r77569  
    225225
    226226#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
    227 /** @todo NSTVMX: Refine this mask later (probably some MSRs are not required). */
    228 # define IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK         CPUMCTX_EXTRN_ABSOLUTELY_ALL
    229 # define IEM_CPUMCTX_EXTRN_VMX_VMENTRY_MASK        IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK
     227# define IEM_CPUMCTX_EXTRN_VMX_VMENTRY_MASK        (  IEM_CPUMCTX_EXTRN_EXEC_DECODED_NO_MEM_MASK \
     228                                                    | CPUMCTX_EXTRN_HWVIRT )
    230229#endif
    231230
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r77382 r77569  
    1574615746VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVirtApicAccessMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t *pu64Value, bool fWrite)
    1574715747{
    15748     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_EXEC_DECODED_NO_MEM_MASK);
    1574915748    Assert(pu64Value);
    1575015749
     
    1578015779                                                       bool fWrite)
    1578115780{
    15782     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK);
    1578315781    Assert(pvData);
    1578415782
     
    1580415802VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitApicWrite(PVMCPU pVCpu)
    1580515803{
    15806     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK);
    15807 
    1580815804    VBOXSTRICTRC rcStrict = iemVmxApicWriteEmulation(pVCpu);
    1580915805    if (pVCpu->iem.s.cActiveMappings)
     
    1582215818VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitPreemptTimer(PVMCPU pVCpu)
    1582315819{
    15824     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK);
    1582515820    VBOXSTRICTRC rcStrict = iemVmxVmexitPreemptTimer(pVCpu);
    1582615821    if (pVCpu->iem.s.cActiveMappings)
     
    1584315838VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitExtInt(PVMCPU pVCpu, uint8_t uVector, bool fIntPending)
    1584415839{
    15845     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK);
    1584615840    VBOXSTRICTRC rcStrict = iemVmxVmexitExtInt(pVCpu, uVector, fIntPending);
    1584715841    if (pVCpu->iem.s.cActiveMappings)
     
    1586115855VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitStartupIpi(PVMCPU pVCpu, uint8_t uVector)
    1586215856{
    15863     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK);
    1586415857    VBOXSTRICTRC rcStrict = iemVmxVmexitStartupIpi(pVCpu, uVector);
    1586515858    if (pVCpu->iem.s.cActiveMappings)
     
    1587815871VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitInitIpi(PVMCPU pVCpu)
    1587915872{
    15880     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK);
    1588115873    VBOXSTRICTRC rcStrict = iemVmxVmexitInitIpi(pVCpu);
    1588215874    if (pVCpu->iem.s.cActiveMappings)
     
    1589515887VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitIntWindow(PVMCPU pVCpu)
    1589615888{
    15897     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK);
    1589815889    VBOXSTRICTRC rcStrict = iemVmxVmexitIntWindow(pVCpu);
    1589915890    if (pVCpu->iem.s.cActiveMappings)
     
    1591215903VMM_INT_DECL(VBOXSTRICTRC)  IEMExecVmxVmexitMtf(PVMCPU pVCpu)
    1591315904{
    15914     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK);
    1591515905    VBOXSTRICTRC rcStrict = iemVmxVmexitMtf(pVCpu);
    1591615906    if (pVCpu->iem.s.cActiveMappings)
     
    1609916089
    1610016090    iemInitExec(pVCpu, false /*fBypassHandlers*/);
    16101     VBOXSTRICTRC rcStrict = iemVmxVmlaunchVmresume(pVCpu, cbInstr,  uInstrId);
     16091    VBOXSTRICTRC rcStrict = iemVmxVmlaunchVmresume(pVCpu, cbInstr, uInstrId);
    1610216092    if (pVCpu->iem.s.cActiveMappings)
    1610316093        iemMemRollback(pVCpu);
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r77548 r77569  
    16681668     *    NewPt  = 2 - 2 = 0
    16691669     */
     1670    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_HWVIRT);
    16701671    uint64_t const uCurTick        = TMCpuTickGetNoCheck(pVCpu);
    16711672    uint64_t const uVmentryTick    = pVCpu->cpum.GstCtx.hwvirt.vmx.uVmentryTick;
     
    18471848         * See Intel spec. 24.4.2 "Guest Non-Register State".
    18481849         */
     1850        IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_DR6);
    18491851        uint64_t       fPendingDbgMask = pVCpu->cpum.GstCtx.dr[6];
    18501852        uint64_t const fBpHitMask = VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP0 | VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP1
     
    27682770    return VINF_EM_RAW_EMULATE_INSTR;
    27692771# else
    2770     IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK);
     2772    IEM_CTX_IMPORT_RET(pVCpu, CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_CR3 | CPUMCTX_EXTRN_CR4       /* Control registers */
     2773                            | CPUMCTX_EXTRN_DR7 | CPUMCTX_EXTRN_DR6                           /* Debug registers */
     2774                            | CPUMCTX_EXTRN_EFER                                              /* MSRs */
     2775                            | CPUMCTX_EXTRN_SYSENTER_MSRS
     2776                            | CPUMCTX_EXTRN_OTHER_MSRS    /* PAT */
     2777                            | CPUMCTX_EXTRN_RIP | CPUMCTX_EXTRN_RSP | CPUMCTX_EXTRN_RFLAGS    /* GPRs */
     2778                            | CPUMCTX_EXTRN_SREG_MASK                                         /* Segment registers */
     2779                            | CPUMCTX_EXTRN_TR                                                /* Task register */
     2780                            | CPUMCTX_EXTRN_LDTR | CPUMCTX_EXTRN_GDTR | CPUMCTX_EXTRN_IDTR    /* Table registers */
     2781                            | CPUMCTX_EXTRN_HWVIRT);                                          /* Hardware virtualization state */
    27712782
    27722783    PVMXVVMCS pVmcs = pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs);
     
    37893800    Assert(pVmcs);
    37903801
    3791     /* Check if the guest has enabled VMX-preemption timers in the first place. */
     3802    /* The VM-exit is subject to "Activate VMX-preemption timer" being set. */
    37923803    if (pVmcs->u32PinCtls & VMX_PIN_CTLS_PREEMPT_TIMER)
    37933804    {
     3805        /* Import the hardware virtualization state (for nested-guest VM-entry TSC-tick). */
     3806        IEM_CTX_IMPORT_RET(pVCpu, CPUMCTX_EXTRN_HWVIRT);
     3807
    37943808        /*
    37953809         * Calculate the current VMX-preemption timer value.
     
    38323846    Assert(fIntPending || uVector == 0);
    38333847
    3834     /* The VM-exit is subject to "External interrupt exiting" is being set. */
     3848    /** @todo NSTVMX: r=ramshankar: Consider standardizing check basic/blanket
     3849     *        intercepts for VM-exits. Right now it is not clear which iemVmxVmexitXXX()
     3850     *        functions require prior checking of a blanket intercept and which don't.
     3851     *        It is better for the caller to check a blanket intercept performance wise
     3852     *        than making a function call. Leaving this as a todo because it is more
     3853     *        a performance issue. */
     3854
     3855    /* The VM-exit is subject to "External interrupt exiting" being set. */
    38353856    if (pVmcs->u32PinCtls & VMX_PIN_CTLS_EXT_INT_EXIT)
    38363857    {
     
    40674088            else if (uVector == X86_XCPT_DB)
    40684089            {
    4069                 IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_DR6);
     4090                IEM_CTX_IMPORT_RET(pVCpu, CPUMCTX_EXTRN_DR6);
    40704091                uExitQual = pVCpu->cpum.GstCtx.dr[6] & VMX_VMCS_EXIT_QUAL_VALID_MASK;
    40714092            }
     
    42204241DECLINLINE(uint16_t) iemVmxVirtApicClearPendingWrite(PVMCPU pVCpu)
    42214242{
     4243    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_HWVIRT);
    42224244    uint8_t const offVirtApicWrite = pVCpu->cpum.GstCtx.hwvirt.vmx.offVirtApicWrite;
    42234245    pVCpu->cpum.GstCtx.hwvirt.vmx.offVirtApicWrite = 0;
     
    49925014    Assert(pVmcs);
    49935015
     5016    /* Import the virtual-APIC write offset (part of the hardware-virtualization state). */
     5017    IEM_CTX_IMPORT_RET(pVCpu, CPUMCTX_EXTRN_HWVIRT);
     5018
    49945019    /*
    49955020     * Perform APIC-write emulation based on the virtual-APIC register written.
     
    56565681 * @param   pszInstr        The VMX instruction name (for logging purposes).
    56575682 */
    5658 IEM_STATIC int iemVmxVmentryCheckGuestRipRFlags(PVMCPU pVCpu,  const char *pszInstr)
     5683IEM_STATIC int iemVmxVmentryCheckGuestRipRFlags(PVMCPU pVCpu, const char *pszInstr)
    56595684{
    56605685    /*
     
    67636788     */
    67646789    PCVMXVVMCS pVmcs = pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs);
     6790
     6791    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR0);
    67656792    uint64_t const uGstCr0 = (pVmcs->u64GuestCr0.u   & ~VMX_ENTRY_CR0_IGNORE_MASK)
    67666793                           | (pVCpu->cpum.GstCtx.cr0 &  VMX_ENTRY_CR0_IGNORE_MASK);
     
    67836810        if (!(pVmcs->u32EntryCtls & VMX_ENTRY_CTLS_LOAD_EFER_MSR))
    67846811        {
    6785             bool const fGstInLongMode = RT_BOOL(pVmcs->u32EntryCtls & VMX_ENTRY_CTLS_IA32E_MODE_GUEST);
    6786             bool const fGstPaging     = RT_BOOL(uGstCr0 & X86_CR0_PG);
    6787             uint64_t const uHostEfer  = pVCpu->cpum.GstCtx.msrEFER;
     6812            IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_EFER);
     6813            uint64_t const uHostEfer      = pVCpu->cpum.GstCtx.msrEFER;
     6814            bool const     fGstInLongMode = RT_BOOL(pVmcs->u32EntryCtls & VMX_ENTRY_CTLS_IA32E_MODE_GUEST);
     6815            bool const     fGstPaging     = RT_BOOL(uGstCr0 & X86_CR0_PG);
    67886816            if (fGstInLongMode)
    67896817            {
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