VirtualBox

Changeset 73140 in vbox


Ignore:
Timestamp:
Jul 16, 2018 9:06:51 AM (6 years ago)
Author:
vboxsync
Message:

VMM/HMSVM: Sort out state syncing on #VMEXIT, VMRUN transitions. We need to swap the full state as we use dedicated VMCBs for
guest and nested-guest.

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

Legend:

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

    r72967 r73140  
    164164     * However, with nested-guests, the state -can- change on trips to ring-3 for we might
    165165     * try to inject a nested-guest physical interrupt and cause a SVM_EXIT_INTR #VMEXIT for
    166      * the nested-guest from ring-3. Hence we signal the required CPU state change here.
     166     * the nested-guest from ring-3. Import the complete state here as we will be swapping
     167     * to the guest VMCB after the #VMEXIT.
    167168     */
    168     /** @todo Figure out why using HM_CHANGED_SVM_VMEXIT_MASK instead of
    169      *        HM_CHANGED_ALL_GUEST breaks nested guests (XP Pro, DSL etc.), see also
    170      *        hmR0SvmHandleExitNested(). */
    171     AssertMsg(!(pVCpu->cpum.GstCtx.fExtrn & IEM_CPUMCTX_EXTRN_SVM_VMEXIT_MASK),
    172               ("fExtrn=%#RX64 fExtrnMbz=%#RX64\n", pVCpu->cpum.GstCtx.fExtrn, IEM_CPUMCTX_EXTRN_SVM_VMEXIT_MASK));
     169    CPUMImportGuestStateOnDemand(pVCpu, CPUMCTX_EXTRN_ALL);
     170    AssertMsg(!(pVCpu->cpum.GstCtx.fExtrn & CPUMCTX_EXTRN_ALL),
     171              ("fExtrn=%#RX64 fExtrnMbz=%#RX64\n", pVCpu->cpum.GstCtx.fExtrn, CPUMCTX_EXTRN_ALL));
    173172    ASMAtomicUoOrU64(&pVCpu->hm.s.fCtxChanged, HM_CHANGED_ALL_GUEST);
    174173}
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r73115 r73140  
    158158                 &&   CPUMIsGuestSvmCtrlInterceptSet((a_pVCpu), &(a_pVCpu)->cpum.GstCtx, SVM_CTRL_INTERCEPT_SHUTDOWN)) \
    159159        { \
    160             HMSVM_CPUMCTX_IMPORT_STATE((a_pVCpu), IEM_CPUMCTX_EXTRN_SVM_VMEXIT_MASK); \
     160            HMSVM_CPUMCTX_IMPORT_STATE((a_pVCpu), HMSVM_CPUMCTX_EXTRN_ALL); \
    161161            return VBOXSTRICTRC_TODO(IEMExecSvmVmexit((a_pVCpu), SVM_EXIT_SHUTDOWN, 0, 0)); \
    162162        } \
     
    32653265    pVCpu->hm.s.rcLastExitToR3 = rcExit;
    32663266
    3267     /* On our way back from ring-3 reload the guest state if there is a possibility of it being changed. */
    3268     if (rcExit != VINF_EM_RAW_INTERRUPT)
     3267    /* On our way back from ring-3, reload the guest-CPU state if it may change while in ring-3. */
     3268    if (   rcExit != VINF_EM_RAW_INTERRUPT
     3269        || CPUMIsGuestInSvmNestedHwVirtMode(&pVCpu->cpum.GstCtx))
    32693270    {
    32703271        Assert(!(pVCpu->cpum.GstCtx.fExtrn & HMSVM_CPUMCTX_EXTRN_ALL));
     
    37553756            {
    37563757                Log4(("Intercepting NMI -> #VMEXIT\n"));
    3757                 HMSVM_CPUMCTX_IMPORT_STATE(pVCpu, IEM_CPUMCTX_EXTRN_SVM_VMEXIT_MASK);
     3758                HMSVM_CPUMCTX_IMPORT_STATE(pVCpu, HMSVM_CPUMCTX_EXTRN_ALL);
    37583759                return IEMExecSvmVmexit(pVCpu, SVM_EXIT_NMI, 0, 0);
    37593760            }
     
    37963797            {
    37973798                Log4(("Intercepting INTR -> #VMEXIT\n"));
    3798                 HMSVM_CPUMCTX_IMPORT_STATE(pVCpu, IEM_CPUMCTX_EXTRN_SVM_VMEXIT_MASK);
     3799                HMSVM_CPUMCTX_IMPORT_STATE(pVCpu, HMSVM_CPUMCTX_EXTRN_ALL);
    37993800                return IEMExecSvmVmexit(pVCpu, SVM_EXIT_INTR, 0, 0);
    38003801            }
     
    51735174    Assert(pSvmTransient->u64ExitCode <= SVM_EXIT_MAX);
    51745175
    5175     /** @todo Figure out why using IEM_CPUMCTX_EXTRN_SVM_VMEXIT_MASK instead of
    5176      *        HMSVM_CPUMCTX_EXTRN_ALL breaks nested guests (XP Pro, DSL etc.), see
    5177      *        also HMSvmNstGstVmExitNotify(). */
     5176    /*
     5177     * We import the complete state here because we use separate VMCBs for the guest and the
     5178     * nested-guest, and the guest's VMCB is used after the #VMEXIT. We can only save/restore
     5179     * the #VMEXIT specific state if we used the same VMCB for both guest and nested-guest.
     5180     */
    51785181#define NST_GST_VMEXIT_CALL_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2) \
    51795182    do { \
     
    53995402             * get an SMI #VMEXIT here so simply ignore rather than causing a corresponding
    54005403             * nested-guest #VMEXIT.
     5404             *
     5405             * We shall import the complete state here as we may cause #VMEXITs from ring-3
     5406             * while trying to inject interrupts, see comment at the top of this function.
    54015407             */
    5402             HMSVM_CPUMCTX_IMPORT_STATE(pVCpu, IEM_CPUMCTX_EXTRN_SVM_VMEXIT_MASK);
     5408            HMSVM_CPUMCTX_IMPORT_STATE(pVCpu, CPUMCTX_EXTRN_ALL);
    54035409            return hmR0SvmExitIntr(pVCpu, pSvmTransient);
    54045410        }
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