VirtualBox

Changeset 58014 in vbox


Ignore:
Timestamp:
Oct 2, 2015 5:33:16 PM (9 years ago)
Author:
vboxsync
Message:

VMM/GIM: Fix Hyper-V hypercall vs hypercall page confusion.

Location:
trunk/src/VBox/VMM
Files:
5 edited

Legend:

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

    r58007 r58014  
    124124     * Verify that hypercalls are enabled.
    125125     */
    126     if (!MSR_GIM_HV_HYPERCALL_IS_ENABLED(pVM->gim.s.u.Hv.u64HypercallMsr))
     126    if (!gimHvAreHypercallsEnabled(pVCpu))
    127127        return VERR_GIM_HYPERCALLS_NOT_ENABLED;
    128128
     
    275275VMM_INT_DECL(bool) gimHvAreHypercallsEnabled(PVMCPU pVCpu)
    276276{
    277     return MSR_GIM_HV_HYPERCALL_IS_ENABLED(pVCpu->CTX_SUFF(pVM)->gim.s.u.Hv.u64HypercallMsr);
     277    return RT_BOOL(pVCpu->CTX_SUFF(pVM)->gim.s.u.Hv.u64GuestOsIdMsr != 0);
    278278}
    279279
     
    481481            return VINF_CPUM_R3_MSR_WRITE;
    482482#else
    483             /* Disable the hypercall-page if 0 is written to this MSR. */
     483            /* Disable the hypercall-page and hypercalls if 0 is written to this MSR. */
    484484            if (!uRawValue)
    485485            {
    486                 gimR3HvDisableHypercallPage(pVM);
    487                 pHv->u64HypercallMsr &= ~MSR_GIM_HV_HYPERCALL_ENABLE_BIT;
    488                 LogRel(("GIM: HyperV: Hypercalls disabled via Guest OS ID Msr\n"));
     486                if (MSR_GIM_HV_HYPERCALL_PAGE_IS_ENABLED(pHv->u64HypercallMsr))
     487                {
     488                    gimR3HvDisableHypercallPage(pVM);
     489                    pHv->u64HypercallMsr &= ~MSR_GIM_HV_HYPERCALL_PAGE_ENABLE_BIT;
     490                    LogRel(("GIM: HyperV: Hypercall page disabled via Guest OS ID MSR\n"));
     491                }
    489492            }
    490493            else
     
    510513                AssertRC(rc2);
    511514            }
     515
    512516            pHv->u64GuestOsIdMsr = uRawValue;
     517
     518            /*
     519             * Notify VMM that hypercalls are now disabled/enabled.
     520             */
     521            for (VMCPUID i = 0; i < pVM->cCpus; i++)
     522            {
     523                if (uRawValue)
     524                    VMMHypercallsEnable(&pVM->aCpus[i]);
     525                else
     526                    VMMHypercallsDisable(&pVM->aCpus[i]);
     527            }
     528
    513529            return VINF_SUCCESS;
    514530#endif /* IN_RING3 */
     
    528544            return VINF_SUCCESS;
    529545# else
    530             /* First, update all but the hypercall enable bit. */
    531             pHv->u64HypercallMsr = (uRawValue & ~MSR_GIM_HV_HYPERCALL_ENABLE_BIT);
    532 
    533             /* Hypercalls can only be enabled when the guest has set the Guest-OS Id Msr. */
    534             bool fEnable = RT_BOOL(uRawValue & MSR_GIM_HV_HYPERCALL_ENABLE_BIT);
     546            /* First, update all but the hypercall page enable bit. */
     547            pHv->u64HypercallMsr = (uRawValue & ~MSR_GIM_HV_HYPERCALL_PAGE_ENABLE_BIT);
     548
     549            /* Hypercall page can only be enabled when the guest has enabled hypercalls. */
     550            bool fEnable = RT_BOOL(uRawValue & MSR_GIM_HV_HYPERCALL_PAGE_ENABLE_BIT);
    535551            if (   fEnable
    536                 && !pHv->u64GuestOsIdMsr)
     552                && !gimHvAreHypercallsEnabled(pVCpu))
    537553            {
    538554                return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r57989 r58014  
    51655165            }
    51665166        }
     5167        else
     5168            Log4(("hmR0SvmExitVmmCall: Hypercalls not enabled\n"));
    51675169    }
    51685170
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r57989 r58014  
    1016210162        }
    1016310163    }
     10164    else
     10165        Log4(("hmR0VmxExitVmcall: Hypercalls not enabled\n"));
    1016410166
    1016510167    hmR0VmxSetPendingXcptUD(pVCpu, pMixedCtx);
  • trunk/src/VBox/VMM/VMMR3/GIMHv.cpp

    r58008 r58014  
    297297        rc = gimR3HvInitDebugSupport(pVM);
    298298        AssertLogRelRCReturn(rc, rc);
    299 
    300         /*
    301          * Pretend that hypercalls are enabled unconditionally when posing as Microsoft,
    302          * as Windows guests invoke debug hypercalls before enabling them via the hypercall MSR.
    303          */
    304         if (pHv->fIsVendorMsHv)
    305         {
    306             pHv->u64HypercallMsr |= MSR_GIM_HV_HYPERCALL_ENABLE_BIT;
    307             for (VMCPUID i = 0; i < pVM->cCpus; i++)
    308                 VMMHypercallsEnable(&pVM->aCpus[i]);
    309         }
    310299    }
    311300
     
    442431    pHv->uCrashP3        = 0;
    443432    pHv->uCrashP4        = 0;
    444 
    445     /* Extra faking required while posing as Microsoft, see gimR3HvInit(). */
    446     if (   (pHv->uMiscFeat & GIM_HV_MISC_FEAT_GUEST_DEBUGGING)
    447         && pHv->fIsVendorMsHv)
    448     {
    449         pHv->u64HypercallMsr |= MSR_GIM_HV_HYPERCALL_ENABLE_BIT;
    450         for (VMCPUID i = 0; i < pVM->cCpus; i++)
    451             VMMHypercallsEnable(&pVM->aCpus[i]);
    452     }
    453433}
    454434
     
    596576                                pRegion->cbRegion, PAGE_SIZE);
    597577
    598     if (MSR_GIM_HV_HYPERCALL_IS_ENABLED(pHv->u64HypercallMsr))
     578    if (MSR_GIM_HV_HYPERCALL_PAGE_IS_ENABLED(pHv->u64HypercallMsr))
    599579    {
    600580        Assert(pRegion->GCPhysPage != NIL_RTGCPHYS);
     
    805785        pRegion->fMapped = false;
    806786#endif
    807         for (VMCPUID i = 0; i < pVM->cCpus; i++)
    808             VMMHypercallsDisable(&pVM->aCpus[i]);
    809787        LogRel(("GIM: HyperV: Disabled Hypercall-page\n"));
    810788        return VINF_SUCCESS;
     
    873851                VMMHypercallsEnable(&pVM->aCpus[i]);
    874852
    875             LogRel(("GIM: HyperV: Enabled hypercalls at %#RGp\n", GCPhysHypercallPage));
     853            LogRel(("GIM: HyperV: Enabled hypercall page at %#RGp\n", GCPhysHypercallPage));
    876854            return VINF_SUCCESS;
    877855        }
     
    911889        if (RT_SUCCESS(rc))
    912890        {
    913             /*
    914              * Notify VMM that hypercalls are now enabled for all VCPUs.
    915              */
    916             for (VMCPUID i = 0; i < pVM->cCpus; i++)
    917                 VMMHypercallsEnable(&pVM->aCpus[i]);
    918 
    919891            pRegion->GCPhysPage = GCPhysHypercallPage;
    920892            pRegion->fMapped = true;
    921             LogRel(("GIM: HyperV: Enabled hypercalls at %#RGp\n", GCPhysHypercallPage));
     893            LogRel(("GIM: HyperV: Enabled hypercall page at %#RGp\n", GCPhysHypercallPage));
    922894        }
    923895        else
  • trunk/src/VBox/VMM/include/GIMHvInternal.h

    r57989 r58014  
    413413#define MSR_GIM_HV_HYPERCALL_GUEST_PFN(a)         ((a) >> 12)
    414414/** The hypercall enable bit. */
    415 #define MSR_GIM_HV_HYPERCALL_ENABLE_BIT           RT_BIT_64(0)
     415#define MSR_GIM_HV_HYPERCALL_PAGE_ENABLE_BIT      RT_BIT_64(0)
    416416/** Whether the hypercall-page is enabled or not. */
    417 #define MSR_GIM_HV_HYPERCALL_IS_ENABLED(a)        RT_BOOL((a) & MSR_GIM_HV_HYPERCALL_ENABLE_BIT)
     417#define MSR_GIM_HV_HYPERCALL_PAGE_IS_ENABLED(a)   RT_BOOL((a) & MSR_GIM_HV_HYPERCALL_PAGE_ENABLE_BIT)
    418418/** @} */
    419419
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