VirtualBox

Changeset 78861 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
May 30, 2019 4:56:34 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
130973
Message:

VMM/CPUM: Nested VMX: bugref:9180 Add CPUMIsGuestVmxVmreadVmwriteInterceptSet.

File:
1 edited

Legend:

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

    r78840 r78861  
    32533253
    32543254/**
     3255 * Checks whether a VMREAD or VMWRITE instruction for the given VMCS field causes a
     3256 * VM-exit or not.
     3257 *
     3258 * @returns @c true if the VMREAD/VMWRITE is intercepted, @c false otherwise.
     3259 * @param   pVCpu           The cross context virtual CPU structure.
     3260 * @param   uExitReason     The VM-exit reason (VMX_EXIT_VMREAD or
     3261 *                          VMX_EXIT_VMREAD).
     3262 * @param   u64FieldEnc     The VMCS field encoding.
     3263 */
     3264VMM_INT_DECL(bool) CPUMIsGuestVmxVmreadVmwriteInterceptSet(PCVMCPU pVCpu, uint32_t uExitReason, uint64_t u64FieldEnc)
     3265{
     3266#ifndef IN_RC
     3267    Assert(CPUMIsGuestInVmxNonRootMode(&pVCpu->cpum.s.Guest));
     3268    Assert(   uExitReason == VMX_EXIT_VMREAD
     3269           || uExitReason == VMX_EXIT_VMWRITE);
     3270
     3271    /*
     3272     * Without VMCS shadowing, all VMREAD and VMWRITE instructions are intercepted.
     3273     */
     3274    if (!pVCpu->CTX_SUFF(pVM)->cpum.s.GuestFeatures.fVmxVmcsShadowing)
     3275        return true;
     3276
     3277    /*
     3278     * If any reserved bit in the 64-bit VMCS field encoding is set, the VMREAD/VMWRITE
     3279     * is intercepted. This excludes any reserved bits in the valid parts of the field
     3280     * encoding (i.e. bit 12).
     3281     */
     3282    if (u64FieldEnc & VMX_VMCS_ENC_RSVD_MASK)
     3283        return true;
     3284
     3285    /*
     3286     * Finally, consult the VMREAD/VMWRITE bitmap whether to intercept the instruction or not.
     3287     */
     3288    uint32_t const u32FieldEnc = RT_LO_U32(u64FieldEnc);
     3289    Assert(u32FieldEnc >> 3 < VMX_V_VMREAD_VMWRITE_BITMAP_SIZE);
     3290    Assert(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvVmreadBitmap));
     3291    uint8_t const *pbBitmap = uExitReason == VMX_EXIT_VMREAD
     3292                            ? (uint8_t const *)pVCpu->cpum.s.Guest.hwvirt.vmx.CTX_SUFF(pvVmreadBitmap)
     3293                            : (uint8_t const *)pVCpu->cpum.s.Guest.hwvirt.vmx.CTX_SUFF(pvVmwriteBitmap);
     3294    Assert(pbBitmap);
     3295    pbBitmap += (u32FieldEnc >> 3);
     3296    if (*pbBitmap & RT_BIT(u32FieldEnc & 7))
     3297        return true;
     3298
     3299    return false;
     3300
     3301#else
     3302    RT_NOREF3(pVCpu, uExitReason, u64FieldEnc);
     3303    return false;
     3304#endif
     3305}
     3306
     3307
     3308
     3309/**
    32553310 * Determines whether the given I/O access should cause a nested-guest \#VMEXIT.
    32563311 *
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