VirtualBox

Changeset 82576 in vbox


Ignore:
Timestamp:
Dec 13, 2019 10:01:00 AM (5 years ago)
Author:
vboxsync
Message:

VMM/HMSVMR0: Padding and verify size of SVMTRANSIENT. Avoid function call in hmR0SvmSupportsVmcbCleanBits, it's in the hot path.

File:
1 edited

Legend:

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

    r81277 r82576  
    293293    /** The host's rflags/eflags. */
    294294    RTCCUINTREG     fEFlags;
    295 
    296295    /** The \#VMEXIT exit code (the EXITCODE field in the VMCB). */
    297296    uint64_t        u64ExitCode;
     297
    298298    /** The guest's TPR value used for TPR shadowing. */
    299299    uint8_t         u8GuestTpr;
     
    303303    /** Pointer to the currently executing VMCB. */
    304304    PSVMVMCB        pVmcb;
     305
    305306    /** Whether we are currently executing a nested-guest. */
    306307    bool            fIsNestedGuest;
    307 
    308308    /** Whether the guest debug state was active at the time of \#VMEXIT. */
    309309    bool            fWasGuestDebugStateActive;
     
    320320     *  external interrupt or NMI. */
    321321    bool            fVectoringPF;
     322    /** Padding. */
     323    bool            afPadding0;
    322324} SVMTRANSIENT;
    323325/** Pointer to SVM transient state. */
     
    326328typedef const SVMTRANSIENT *PCSVMTRANSIENT;
    327329
     330AssertCompileSizeAlignment(SVMTRANSIENT, sizeof(uint64_t));
    328331AssertCompileMemberAlignment(SVMTRANSIENT, u64ExitCode, sizeof(uint64_t));
    329332AssertCompileMemberAlignment(SVMTRANSIENT, pVmcb,       sizeof(uint64_t));
     
    803806 *
    804807 * @returns @c true if supported, @c false otherwise.
    805  * @param   pVCpu       The cross context virtual CPU structure.
    806  */
    807 DECLINLINE(bool) hmR0SvmSupportsVmcbCleanBits(PVMCPUCC pVCpu)
    808 {
    809     PVMCC pVM = pVCpu->CTX_SUFF(pVM);
    810 #ifdef VBOX_WITH_NESTED_HWVIRT_SVM
    811     if (CPUMIsGuestInSvmNestedHwVirtMode(&pVCpu->cpum.GstCtx))
    812     {
    813         return (pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_VMCB_CLEAN)
    814             &&  pVM->cpum.ro.GuestFeatures.fSvmVmcbClean;
    815     }
    816 #endif
    817     return RT_BOOL(pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_VMCB_CLEAN);
     808 * @param   pVCpu           The cross context virtual CPU structure.
     809 * @param   fIsNestedGuest  Whether we are currently executing the nested-guest.
     810 */
     811DECL_FORCE_INLINE(bool) hmR0SvmSupportsVmcbCleanBits(PVMCPUCC pVCpu, bool fIsNestedGuest)
     812{
     813    PCVMCC pVM = pVCpu->CTX_SUFF(pVM);
     814    bool const fHostVmcbCleanBits = RT_BOOL(pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_VMCB_CLEAN);
     815    if (!fIsNestedGuest)
     816        return fHostVmcbCleanBits;
     817    return fHostVmcbCleanBits && pVM->cpum.ro.GuestFeatures.fSvmVmcbClean;
    818818}
    819819
     
    42374237     * from the VMCB.
    42384238     */
    4239     bool const fSupportsVmcbCleanBits = hmR0SvmSupportsVmcbCleanBits(pVCpu);
     4239    bool const fSupportsVmcbCleanBits = hmR0SvmSupportsVmcbCleanBits(pVCpu, pSvmTransient->fIsNestedGuest);
    42404240    if (!fSupportsVmcbCleanBits)
    42414241        pVmcb->ctrl.u32VmcbCleanBits = 0;
     
    43374337
    43384338    pSvmTransient->u64ExitCode        = pVmcbCtrl->u64ExitCode; /* Save the #VMEXIT reason. */
    4339     pVmcbCtrl->u32VmcbCleanBits       = HMSVM_VMCB_CLEAN_ALL;   /* Mark the VMCB-state cache as unmodified by VMM. */
    43404339    pSvmTransient->fVectoringDoublePF = false;                  /* Vectoring double page-fault needs to be determined later. */
    43414340    pSvmTransient->fVectoringPF       = false;                  /* Vectoring page-fault needs to be determined later. */
     4341    pVmcbCtrl->u32VmcbCleanBits       = HMSVM_VMCB_CLEAN_ALL;   /* Mark the VMCB-state cache as unmodified by VMM. */
    43424342
    43434343#ifdef HMSVM_SYNC_FULL_GUEST_STATE
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