VirtualBox

Changeset 69930 in vbox


Ignore:
Timestamp:
Dec 5, 2017 10:12:57 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
119417
Message:

VMM/HMSVMR0: Nits.

Location:
trunk
Files:
3 edited

Legend:

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

    r69764 r69930  
    10021002    /** @name Nested-guest VMCB guest state.
    10031003     * @{ */
     1004    /** Cache of CR0. */
     1005    uint64_t            u64CR0;
    10041006    /** Cache of CR3. */
    10051007    uint64_t            u64CR3;
  • trunk/src/VBox/VMM/VMMAll/HMSVMAll.cpp

    r69764 r69930  
    359359        pVmcbNstGstCtrl->u32InterceptXcpt         = pNstGstVmcbCache->u32InterceptXcpt;
    360360        pVmcbNstGstCtrl->u64InterceptCtrl         = pNstGstVmcbCache->u64InterceptCtrl;
     361        pVmcbNstGstState->u64CR0                  = pNstGstVmcbCache->u64CR0;
    361362        pVmcbNstGstState->u64CR3                  = pNstGstVmcbCache->u64CR3;
    362363        pVmcbNstGstState->u64CR4                  = pNstGstVmcbCache->u64CR4;
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r69928 r69930  
    679679
    680680/**
     681 * Returns whether VMCB Clean Bits feature is supported.
     682 *
     683 * @param   pVCpu       The cross context virtual CPU structure.
     684 * @param   pCtx        Pointer to the guest-CPU context.
     685 */
     686DECLINLINE(bool) hmR0SvmSupportsVmcbCleanBits(PVMCPU pVCpu, PCPUMCTX pCtx)
     687{
     688    PVM pVM = pVCpu->CTX_SUFF(pVM);
     689#ifdef VBOX_WITH_NESTED_HWVIRT
     690    if (CPUMIsGuestInSvmNestedHwVirtMode(pCtx))
     691    {
     692        return    (pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_VMCB_CLEAN)
     693               && pVM->cpum.ro.GuestFeatures.fSvmVmcbClean;
     694    }
     695#else
     696    RT_NOREF(pCtx);
     697#endif
     698    return RT_BOOL(pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_VMCB_CLEAN);
     699}
     700
     701
     702/**
     703 * Returns whether decode-assist feature is supported.
     704 *
     705 * @param   pVCpu       The cross context virtual CPU structure.
     706 * @param   pCtx        Pointer to the guest-CPU context.
     707 */
     708DECLINLINE(bool) hmR0SvmSupportsDecodeAssist(PVMCPU pVCpu, PCPUMCTX pCtx)
     709{
     710    PVM pVM = pVCpu->CTX_SUFF(pVM);
     711#ifdef VBOX_WITH_NESTED_HWVIRT
     712    if (CPUMIsGuestInSvmNestedHwVirtMode(pCtx))
     713    {
     714        return    (pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_DECODE_ASSIST)
     715               &&  pVM->cpum.ro.GuestFeatures.fSvmDecodeAssist;
     716    }
     717#else
     718    RT_NOREF(pCtx);
     719#endif
     720    return RT_BOOL(pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_DECODE_ASSIST);
     721}
     722
     723
     724/**
     725 * Returns whether NRIP_SAVE feature is supported.
     726 *
     727 * @param   pVCpu       The cross context virtual CPU structure.
     728 * @param   pCtx        Pointer to the guest-CPU context.
     729 */
     730DECLINLINE(bool) hmR0SvmSupportsNextRipSave(PVMCPU pVCpu, PCPUMCTX pCtx)
     731{
     732    PVM pVM = pVCpu->CTX_SUFF(pVM);
     733#ifdef VBOX_WITH_NESTED_HWVIRT
     734    if (CPUMIsGuestInSvmNestedHwVirtMode(pCtx))
     735    {
     736        return    (pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_NRIP_SAVE)
     737               &&  pVM->cpum.ro.GuestFeatures.fSvmNextRipSave;
     738    }
     739#else
     740    RT_NOREF(pCtx);
     741#endif
     742    return RT_BOOL(pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_NRIP_SAVE);
     743}
     744
     745
     746/**
    681747 * Sets the permission bits for the specified MSR in the MSRPM.
    682748 *
     
    20782144        pNstGstVmcbCache->u32InterceptXcpt  = pVmcbNstGstCtrl->u32InterceptXcpt;
    20792145        pNstGstVmcbCache->u64InterceptCtrl  = pVmcbNstGstCtrl->u64InterceptCtrl;
     2146        pNstGstVmcbCache->u64CR0            = pVmcbNstGstState->u64CR0;
    20802147        pNstGstVmcbCache->u64CR3            = pVmcbNstGstState->u64CR3;
    20812148        pNstGstVmcbCache->u64CR4            = pVmcbNstGstState->u64CR4;
     
    39894056     * mark all state-bits as dirty indicating to the CPU to re-load from VMCB.
    39904057     */
    3991     if (   !(pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_VMCB_CLEAN)
    3992         || !(pVM->cpum.ro.GuestFeatures.fSvmVmcbClean))
     4058    bool const fSupportsVmcbCleanBits = hmR0SvmSupportsVmcbCleanBits(pVCpu, pCtx);
     4059    if (!fSupportsVmcbCleanBits)
    39934060        pVmcbNstGst->ctrl.u64VmcbCleanBits = 0;
    39944061}
     
    40984165
    40994166    /* If VMCB Clean bits isn't supported by the CPU, simply mark all state-bits as dirty, indicating (re)load-from-VMCB. */
    4100     if (!(pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_VMCB_CLEAN))
     4167    bool const fSupportsVmcbCleanBits = hmR0SvmSupportsVmcbCleanBits(pVCpu, pCtx);
     4168    if (!fSupportsVmcbCleanBits)
    41014169        pVmcb->ctrl.u64VmcbCleanBits = 0;
    41024170}
     
    58285896
    58295897/**
    5830  * Returns whether decode-assist feature is supported.
    5831  *
    5832  * @param   pVCpu       The cross context virtual CPU structure.
    5833  * @param   pCtx        Pointer to the guest-CPU context.
    5834  */
    5835 DECLINLINE(bool) hmR0SvmSupportsDecodeAssist(PVMCPU pVCpu, PCPUMCTX pCtx)
    5836 {
    5837     PVM pVM = pVCpu->CTX_SUFF(pVM);
    5838 #ifdef VBOX_WITH_NESTED_HWVIRT
    5839     if (CPUMIsGuestInSvmNestedHwVirtMode(pCtx))
    5840     {
    5841         return    (pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_DECODE_ASSIST)
    5842                &&  pVM->cpum.ro.GuestFeatures.fSvmDecodeAssist;
    5843     }
    5844 #else
    5845     RT_NOREF(pCtx);
    5846 #endif
    5847     return RT_BOOL(pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_DECODE_ASSIST);
    5848 }
    5849 
    5850 
    5851 /**
    5852  * Returns whether NRIP_SAVE feature is supported.
    5853  *
    5854  * @param   pVCpu       The cross context virtual CPU structure.
    5855  * @param   pCtx        Pointer to the guest-CPU context.
    5856  */
    5857 DECLINLINE(bool) hmR0SvmSupportsNextRipSave(PVMCPU pVCpu, PCPUMCTX pCtx)
    5858 {
    5859     PVM pVM = pVCpu->CTX_SUFF(pVM);
    5860 #ifdef VBOX_WITH_NESTED_HWVIRT
    5861     if (CPUMIsGuestInSvmNestedHwVirtMode(pCtx))
    5862     {
    5863         return    (pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_NRIP_SAVE)
    5864                &&  pVM->cpum.ro.GuestFeatures.fSvmNextRipSave;
    5865     }
    5866 #else
    5867     RT_NOREF(pCtx);
    5868 #endif
    5869     return RT_BOOL(pVM->hm.s.svm.u32Features & X86_CPUID_SVM_FEATURE_EDX_NRIP_SAVE);
    5870 }
    5871 
    5872 
    5873 /**
    58745898 * Advances the guest RIP making use of the CPU's NRIP_SAVE feature if
    58755899 * supported, otherwise advances the RIP by the number of bytes specified in
     
    63086332
    63096333            case 3:     /* CR3. */
    6310                 Assert(!pVM->hm.s.fNestedPaging);
    63116334                HMCPU_CF_SET(pVCpu, HM_CHANGED_GUEST_CR3);
    63126335                break;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette