VirtualBox

Changeset 78716 in vbox


Ignore:
Timestamp:
May 24, 2019 11:17:08 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
130795
Message:

VMM/IEM: Nested VMX: bugref:9180 Use CPUMIsGuestVmxLmswInterceptSet.

File:
1 edited

Legend:

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

    r78689 r78716  
    30503050                                              uint8_t cbInstr)
    30513051{
    3052     /*
    3053      * LMSW VM-exits are subject to the CR0 guest/host mask and the CR0 read shadow.
    3054      *
    3055      * See Intel spec. 24.6.6 "Guest/Host Masks and Read Shadows for CR0 and CR4".
    3056      * See Intel spec. 25.1.3 "Instructions That Cause VM Exits Conditionally".
    3057      */
    3058     PCVMXVVMCS pVmcs = pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs);
    3059     Assert(pVmcs);
    3060     Assert(pu16NewMsw);
    3061 
    3062     bool fIntercept = false;
    3063     uint32_t const fGstHostMask = pVmcs->u64Cr0Mask.u;
    3064     uint32_t const fReadShadow  = pVmcs->u64Cr0ReadShadow.u;
    3065 
    3066     /*
    3067      * LMSW can never clear CR0.PE but it may set it. Hence, we handle the
    3068      * CR0.PE case first, before the rest of the bits in the MSW.
    3069      *
    3070      * If CR0.PE is owned by the host and CR0.PE differs between the
    3071      * MSW (source operand) and the read-shadow, we must cause a VM-exit.
    3072      */
    3073     if (    (fGstHostMask & X86_CR0_PE)
    3074         &&  (*pu16NewMsw  & X86_CR0_PE)
    3075         && !(fReadShadow  & X86_CR0_PE))
    3076         fIntercept = true;
    3077 
    3078     /*
    3079      * If CR0.MP, CR0.EM or CR0.TS is owned by the host, and the corresponding
    3080      * bits differ between the MSW (source operand) and the read-shadow, we must
    3081      * cause a VM-exit.
    3082      */
    3083     uint32_t fGstHostLmswMask = fGstHostMask & (X86_CR0_MP | X86_CR0_EM | X86_CR0_TS);
    3084     if ((fReadShadow & fGstHostLmswMask) != (*pu16NewMsw & fGstHostLmswMask))
    3085         fIntercept = true;
    3086 
    3087     if (fIntercept)
     3052    if (CPUMIsGuestVmxLmswInterceptSet(pVCpu, &pVCpu->cpum.GstCtx, *pu16NewMsw))
    30883053    {
    30893054        Log2(("lmsw: Guest intercept -> VM-exit\n"));
     
    31153080     * See Intel Spec. 25.3 "Changes To Instruction Behavior In VMX Non-root Operation".
    31163081     */
    3117     fGstHostLmswMask = fGstHostMask & (X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS);
    3118     *pu16NewMsw = (uGuestCr0 & fGstHostLmswMask) | (*pu16NewMsw & ~fGstHostLmswMask);
     3082    PCVMXVVMCS pVmcs = pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs);
     3083    Assert(pVmcs);
     3084    uint32_t const fGstHostMask     = pVmcs->u64Cr0Mask.u;
     3085    uint32_t const fGstHostLmswMask = fGstHostMask & (X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS);
     3086
     3087    *pu16NewMsw      = (uGuestCr0 & fGstHostLmswMask) | (*pu16NewMsw & ~fGstHostLmswMask);
    31193088
    31203089    return VINF_VMX_INTERCEPT_NOT_ACTIVE;
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