VirtualBox

Ignore:
Timestamp:
Feb 28, 2022 8:39:08 AM (3 years ago)
Author:
vboxsync
Message:

VMM: Nested VMX: bugref:10092 Add HM ring-0 API for querying transient VMX/SVM info.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r93931 r93963  
    287287                                                 | HMSVM_VMCB_CLEAN_AVIC)
    288288/** @} */
    289 
    290 /** @name SVM transient.
    291  *
    292  * A state structure for holding miscellaneous information across AMD-V
    293  * VMRUN/\#VMEXIT operation, restored after the transition.
    294  *
    295  * @{ */
    296 typedef struct SVMTRANSIENT
    297 {
    298     /** The host's rflags/eflags. */
    299     RTCCUINTREG     fEFlags;
    300     /** The \#VMEXIT exit code (the EXITCODE field in the VMCB). */
    301     uint64_t        u64ExitCode;
    302 
    303     /** The guest's TPR value used for TPR shadowing. */
    304     uint8_t         u8GuestTpr;
    305     /** Alignment. */
    306     uint8_t         abAlignment0[7];
    307 
    308     /** Pointer to the currently executing VMCB. */
    309     PSVMVMCB        pVmcb;
    310 
    311     /** Whether we are currently executing a nested-guest. */
    312     bool            fIsNestedGuest;
    313     /** Whether the guest debug state was active at the time of \#VMEXIT. */
    314     bool            fWasGuestDebugStateActive;
    315     /** Whether the hyper debug state was active at the time of \#VMEXIT. */
    316     bool            fWasHyperDebugStateActive;
    317     /** Whether the TSC offset mode needs to be updated. */
    318     bool            fUpdateTscOffsetting;
    319     /** Whether the TSC_AUX MSR needs restoring on \#VMEXIT. */
    320     bool            fRestoreTscAuxMsr;
    321     /** Whether the \#VMEXIT was caused by a page-fault during delivery of a
    322      *  contributary exception or a page-fault. */
    323     bool            fVectoringDoublePF;
    324     /** Whether the \#VMEXIT was caused by a page-fault during delivery of an
    325      *  external interrupt or NMI. */
    326     bool            fVectoringPF;
    327     /** Padding. */
    328     bool            afPadding0;
    329 } SVMTRANSIENT;
    330 /** Pointer to SVM transient state. */
    331 typedef SVMTRANSIENT *PSVMTRANSIENT;
    332 /** Pointer to a const SVM transient state. */
    333 typedef const SVMTRANSIENT *PCSVMTRANSIENT;
    334 
    335 AssertCompileSizeAlignment(SVMTRANSIENT, sizeof(uint64_t));
    336 AssertCompileMemberAlignment(SVMTRANSIENT, u64ExitCode, sizeof(uint64_t));
    337 AssertCompileMemberAlignment(SVMTRANSIENT, pVmcb,       sizeof(uint64_t));
    338 /** @}  */
    339289
    340290/**
     
    29592909
    29602910/**
     2911 * Gets SVM \#VMEXIT auxiliary information.
     2912 *
     2913 * @returns VBox status code.
     2914 * @param   pVCpu           The cross context virtual CPU structure.
     2915 * @param   pSvmExitAux     Where to store the auxiliary info.
     2916 */
     2917VMMR0DECL(int) SVMR0GetExitAuxInfo(PVMCPUCC pVCpu, PSVMEXITAUX pSvmExitAux)
     2918{
     2919    PCSVMTRANSIENT pSvmTransient = pVCpu->hmr0.s.svm.pSvmTransient;
     2920    if (RT_LIKELY(pSvmTransient))
     2921    {
     2922        PCSVMVMCB pVmcb = pSvmTransient->pVmcb;
     2923        if (RT_LIKELY(pVmcb))
     2924        {
     2925            pSvmExitAux->u64ExitCode  = pVmcb->ctrl.u64ExitCode;
     2926            pSvmExitAux->u64ExitInfo1 = pVmcb->ctrl.u64ExitInfo1;
     2927            pSvmExitAux->u64ExitInfo2 = pVmcb->ctrl.u64ExitInfo2;
     2928            pSvmExitAux->ExitIntInfo  = pVmcb->ctrl.ExitIntInfo;
     2929            return VINF_SUCCESS;
     2930        }
     2931        return VERR_SVM_IPE_5;
     2932    }
     2933    return VERR_NOT_AVAILABLE;
     2934}
     2935
     2936
     2937/**
    29612938 * Does the necessary state syncing before returning to ring-3 for any reason
    29622939 * (longjmp, preemption, voluntary exits to ring-3) from AMD-V.
     
    45564533    SvmTransient.fIsNestedGuest = true;
    45574534
     4535    /* Setup pointer so PGM/IEM can query #VMEXIT auxiliary info. on demand in ring-0. */
     4536    pVCpu->hmr0.s.svm.pSvmTransient = &SvmTransient;
     4537
    45584538    VBOXSTRICTRC rc = VERR_INTERNAL_ERROR_4;
    45594539    for (;;)
     
    46264606        /** @todo NSTSVM: handle single-stepping. */
    46274607    }
     4608
     4609    /* Ensure #VMEXIT auxiliary info. is no longer available. */
     4610    pVCpu->hmr0.s.svm.pSvmTransient = NULL;
    46284611
    46294612    STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatEntry, x);
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