VirtualBox

Changeset 91692 in vbox for trunk


Ignore:
Timestamp:
Oct 12, 2021 1:31:34 PM (3 years ago)
Author:
vboxsync
Message:

VMM/NEM: Made it build without NEM_WIN_USE_HYPERCALLS_FOR_PAGES again. #ifdef'ed a lot more based on NEM_WIN_USE_HYPERCALLS_FOR_PAGES (basically ring-0 ends up as a stub if it's not defined). bugref:10118

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h

    r91688 r91692  
    15891589#endif /* IN_RING3 && !NEM_WIN_TEMPLATE_MODE_OWN_RUN_API */
    15901590
    1591 
     1591#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3)
    15921592
    15931593NEM_TMPL_STATIC DECLCALLBACK(int)
     
    15951595{
    15961596    RT_NOREF_PV(pvUser);
    1597 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1597# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    15981598    int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
    15991599    AssertRC(rc);
    16001600    if (RT_SUCCESS(rc))
    1601 #else
     1601# else
    16021602    RT_NOREF_PV(pVCpu);
    16031603    HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE);
    16041604    if (SUCCEEDED(hrc))
    1605 #endif
     1605# endif
    16061606    {
    16071607        Log5(("NEM GPA unmap all: %RGp (cMappedPages=%u)\n", GCPhys, pVM->nem.s.cMappedPages - 1));
     
    16101610    else
    16111611    {
    1612 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    1613         LogRel(("nemR3WinUnmapOnePageCallback: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
    1614 #else
    1615         LogRel(("nemR3WinUnmapOnePageCallback: GCPhys=%RGp %s hrc=%Rhrc (%#x) Last=%#x/%u (cMappedPages=%u)\n",
     1612# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1613        LogRel(("nemHCWinUnmapOnePageCallback: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
     1614# else
     1615        LogRel(("nemHCWinUnmapOnePageCallback: GCPhys=%RGp %s hrc=%Rhrc (%#x) Last=%#x/%u (cMappedPages=%u)\n",
    16161616                GCPhys, g_apszPageStates[*pu2NemState], hrc, hrc, RTNtLastStatusValue(),
    16171617                RTNtLastErrorValue(), pVM->nem.s.cMappedPages));
    1618 #endif
     1618# endif
    16191619        *pu2NemState = NEM_WIN_PAGE_STATE_NOT_SET;
    16201620    }
     
    16731673     * We don't really consider downgrades here, as they shouldn't happen.
    16741674     */
    1675 #ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1675# ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    16761676    /** @todo Someone at microsoft please explain:
    16771677     * I'm not sure WTF was going on, but I ended up in a loop if I remapped a
     
    16821682     * with new protection or backing.
    16831683     */
    1684 #endif
     1684# endif
    16851685    int rc;
    16861686    switch (u2State)
     
    17251725            }
    17261726
    1727 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1727# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    17281728            /* Upgrade page to writable. */
    17291729/** @todo test this*/
     
    17511751            }
    17521752            return rc;
    1753 #else
     1753# else
    17541754            break;
    1755 #endif
     1755# endif
    17561756
    17571757        case NEM_WIN_PAGE_STATE_WRITABLE:
     
    17681768                return VINF_SUCCESS;
    17691769            }
    1770 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1770# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    17711771            AssertFailed(); /* There should be no downgrades. */
    1772 #endif
     1772# endif
    17731773            break;
    17741774
     
    17811781     * If this fails, which it does every so often, just unmap everything for now.
    17821782     */
    1783 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1783# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    17841784    rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
    17851785    AssertRC(rc);
    17861786    if (RT_SUCCESS(rc))
    1787 #else
     1787# else
    17881788    /** @todo figure out whether we mess up the state or if it's WHv.   */
    17891789    HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE);
    17901790    if (SUCCEEDED(hrc))
    1791 #endif
     1791# endif
    17921792    {
    17931793        pState->fDidSomething = true;
     
    17981798        return VINF_SUCCESS;
    17991799    }
    1800 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1800# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    18011801    LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhys, rc));
    18021802    return rc;
    1803 #else
     1803# else
    18041804    LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp %s hrc=%Rhrc (%#x) Last=%#x/%u (cMappedPages=%u)\n",
    18051805            GCPhys, g_apszPageStates[u2State], hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue(),
    18061806            pVM->nem.s.cMappedPages));
    18071807
    1808     PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nemR3WinUnmapOnePageCallback, NULL);
     1808    PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nemHCWinUnmapOnePageCallback, NULL);
    18091809    Log(("nemHCWinHandleMemoryAccessPageCheckerCallback: Unmapped all (cMappedPages=%u)\n", pVM->nem.s.cMappedPages));
    18101810
     
    18131813    pInfo->u2NemState = NEM_WIN_PAGE_STATE_UNMAPPED;
    18141814    return VINF_SUCCESS;
    1815 #endif
    1816 }
    1817 
     1815# endif
     1816}
     1817
     1818#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */
    18181819
    18191820
     
    45134514
    45144515#endif /* defined(NEM_WIN_TEMPLATE_MODE_OWN_RUN_API) || defined(IN_RING3) */
     4516#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3)
    45154517
    45164518/**
     
    45234525    if (pInfo->u2NemState > NEM_WIN_PAGE_STATE_UNMAPPED)
    45244526    {
    4525 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     4527# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    45264528        int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys);
    45274529        AssertRC(rc);
    45284530        if (RT_SUCCESS(rc))
    4529 #else
     4531# else
    45304532        HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE);
    45314533        if (SUCCEEDED(hrc))
    4532 #endif
     4534# endif
    45334535        {
    45344536            uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages);
     
    45384540        else
    45394541        {
    4540 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     4542# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    45414543            LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));
    45424544            return rc;
    4543 #else
     4545# else
    45444546            LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n",
    45454547                    GCPhys, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
    45464548            return VERR_NEM_IPE_2;
    4547 #endif
     4549# endif
    45484550        }
    45494551    }
     
    45684570}
    45694571
     4572#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */
    45704573
    45714574void nemHCNativeNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb)
     
    45944597
    45954598
     4599#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3)
    45964600/**
    45974601 * Worker that maps pages into Hyper-V.
     
    46154619                                           uint32_t fPageProt, uint8_t *pu2State, bool fBackingChanged)
    46164620{
    4617 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     4621# ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    46184622    /*
    46194623     * When using the hypercalls instead of the ring-3 APIs, we don't need to
     
    46854689    return VINF_SUCCESS;
    46864690
    4687 #else
     4691# else /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
    46884692    /*
    46894693     * Looks like we need to unmap a page before we can change the backing
     
    46914695     * PGM lends us two bits to keep track of the state here.
    46924696     */
     4697    RT_NOREF(pVCpu);
    46934698    uint8_t const u2OldState = *pu2State;
    46944699    uint8_t const u2NewState = fPageProt & NEM_PAGE_PROT_WRITE ? NEM_WIN_PAGE_STATE_WRITABLE
     
    46994704        if (u2OldState > NEM_WIN_PAGE_STATE_UNMAPPED)
    47004705        {
    4701 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     4706#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    47024707            int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhysDst);
    47034708            AssertRC(rc);
     
    47184723                return rc;
    47194724            }
    4720 # else
     4725#  else
    47214726            HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst, X86_PAGE_SIZE);
    47224727            if (SUCCEEDED(hrc))
     
    47374742                return VERR_NEM_INIT_FAILED;
    47384743            }
    4739 # endif
     4744#  endif
    47404745        }
    47414746    }
     
    47464751    if (fPageProt & NEM_PAGE_PROT_WRITE)
    47474752    {
    4748 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     4753#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    47494754        int rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhysDst,
    47504755                                            HV_MAP_GPA_READABLE   | HV_MAP_GPA_WRITABLE
     
    47614766        LogRel(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
    47624767        return rc;
    4763 # else
     4768#  else
    47644769        void *pvPage;
    47654770        int rc = nemR3NativeGCPhys2R3PtrWriteable(pVM, GCPhysSrc, &pvPage);
     
    47824787        LogRel(("nemHCNativeSetPhysPage/writable: GCPhysSrc=%RGp rc=%Rrc\n", GCPhysSrc, rc));
    47834788        return rc;
    4784 # endif
     4789#  endif
    47854790    }
    47864791
    47874792    if (fPageProt & NEM_PAGE_PROT_READ)
    47884793    {
    4789 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     4794#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    47904795        int rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhysDst,
    47914796                                          HV_MAP_GPA_READABLE | HV_MAP_GPA_EXECUTABLE | HV_MAP_GPA_EXECUTABLE_AGAIN);
     
    48014806        LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
    48024807        return rc;
    4803 # else
     4808#  else
    48044809        const void *pvPage;
    48054810        int rc = nemR3NativeGCPhys2R3PtrReadOnly(pVM, GCPhysSrc, &pvPage);
     
    48224827        LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysSrc=%RGp rc=%Rrc\n", GCPhysSrc, rc));
    48234828        return rc;
    4824 # endif
     4829#  endif
    48254830    }
    48264831
     
    48284833    *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED;
    48294834    return VINF_SUCCESS;
    4830 #endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
    4831 }
     4835# endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
     4836}
     4837#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */
    48324838
    48334839
     
    48414847    }
    48424848
    4843 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)
     4849#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
    48444850    PVMCPUCC pVCpu = VMMGetCpu(pVM);
    48454851    int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhysDst);
     
    48544860    LogRel(("nemHCJustUnmapPageFromHyperV/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc));
    48554861    return rc;
    4856 #else
     4862#elif defined(IN_RING3)
    48574863    HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK, X86_PAGE_SIZE);
    48584864    if (SUCCEEDED(hrc))
     
    48664872            GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue()));
    48674873    return VERR_NEM_IPE_6;
     4874#else
     4875    RT_NOREF(pVM, GCPhysDst, pu2State);
     4876    LogRel(("nemHCJustUnmapPageFromHyperV(%RGp): Why are we here?!?\n", GCPhysDst));
     4877    return VERR_NEM_IPE_6;
    48684878#endif
    48694879}
     
    48784888
    48794889    int rc;
    4880 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)
     4890#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    48814891    PVMCPUCC pVCpu = VMMGetCpu(pVM);
    48824892    if (   pVM->nem.s.fA20Enabled
     
    48954905    if (   pVM->nem.s.fA20Enabled
    48964906        || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
    4897         rc = nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     4907        rc = nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
    48984908    else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
    4899         rc = nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     4909        rc = nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
    49004910    else
    49014911        rc = VINF_SUCCESS; /* ignore since we've got the alias page at this address. */
     
    49124922    RT_NOREF_PV(HCPhys); RT_NOREF_PV(enmType);
    49134923
    4914 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)
     4924#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    49154925    PVMCPUCC pVCpu = VMMGetCpu(pVM);
    49164926    if (   pVM->nem.s.fA20Enabled
     
    49284938    if (   pVM->nem.s.fA20Enabled
    49294939        || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
    4930         nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     4940        nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
    49314941    else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
    4932         nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     4942        nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
    49334943    /* else: ignore since we've got the alias page at this address. */
    49344944#endif
     
    49434953    RT_NOREF_PV(HCPhysPrev); RT_NOREF_PV(HCPhysNew); RT_NOREF_PV(enmType);
    49444954
    4945 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)
     4955#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    49464956    PVMCPUCC pVCpu = VMMGetCpu(pVM);
    49474957    if (   pVM->nem.s.fA20Enabled
     
    49594969    if (   pVM->nem.s.fA20Enabled
    49604970        || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys))
    4961         nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     4971        nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
    49624972    else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys))
    4963         nemR3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
     4973        nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State);
    49644974    /* else: ignore since we've got the alias page at this address. */
    49654975#endif
  • trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp

    r91688 r91692  
    6868*   Global Variables                                                                                                             *
    6969*********************************************************************************************************************************/
     70#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    7071static uint64_t (*g_pfnHvlInvokeHypercall)(uint64_t uCallInfo, uint64_t HCPhysInput, uint64_t HCPhysOutput);
    7172
     
    9192decltype(WinHvGetPartitionProperty) *g_pfnWinHvGetPartitionProperty;
    9293RT_C_DECLS_END
     94#endif
    9395
    9496/** @name VID.SYS image details.
    9597 * @{ */
     98#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    9699static uint8_t                                 *g_pbVidSys                            = NULL;
    97100static uintptr_t                                g_cbVidSys                            = 0;
     
    102105/** Critical section protecting the WinHvGetPartitionProperty hacking. */
    103106static RTCRITSECT                               g_VidSysCritSect;
     107#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
    104108RT_C_DECLS_BEGIN
    105109/** The partition ID passed to WinHvGetPartitionProperty by VID.SYS.   */
     
    392396    AssertRCReturn(rc, rc);
    393397
     398#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    394399    /*
    395400     * We want to perform hypercalls here.  The NT kernel started to expose a very low
     
    464469        }
    465470    }
     471#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
    466472
    467473    return rc;
    468474}
    469475
     476#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    470477
    471478/**
     
    490497                                             void *pvOutput, uint32_t cbOutput)
    491498{
    492 #ifdef RT_STRICT
     499# ifdef RT_STRICT
    493500    /*
    494501     * Input and output parameters are part of the VM CPU structure.
     
    499506    if (pvOutput)
    500507        AssertReturn(((uintptr_t)pvOutput + cbOutput) - (uintptr_t)pGVCpu <= sizeof(*pGVCpu), VERR_INVALID_PARAMETER);
    501 #endif
     508# endif
    502509
    503510    int32_t rcNt = STATUS_UNSUCCESSFUL;
     
    795802}
    796803
     804#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
    797805
    798806/**
     
    808816    AssertRCReturn(rc, rc);
    809817    SUPR0Printf("NEMR0InitVMPart2\n"); LogRel(("2: NEMR0InitVMPart2\n"));
    810 #ifdef NEM_WIN_WITH_RING0_RUNLOOP
     818#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     819# ifdef NEM_WIN_WITH_RING0_RUNLOOP
    811820    Assert(pGVM->nemr0.s.fMayUseRing0Runloop == false);
    812 #endif
     821# endif
    813822
    814823    /*
     
    827836    pGVM->nemr0.s.IoCtlGetPartitionProperty = Copy;
    828837
    829 #ifdef NEM_WIN_WITH_RING0_RUNLOOP
     838# ifdef NEM_WIN_WITH_RING0_RUNLOOP
    830839    pGVM->nemr0.s.fMayUseRing0Runloop = pGVM->nem.s.fUseRing0Runloop;
    831840
     
    858867    if (RT_SUCCESS(rc))
    859868        pGVM->nemr0.s.IoCtlMessageSlotHandleAndGetNext = Copy;
    860 #endif
     869# endif
    861870
    862871    if (   RT_SUCCESS(rc)
     
    880889        NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pVCpu0, pGVM->nemr0.s.IoCtlGetHvPartitionId.uFunction, NULL, 0,
    881890                                                &pVCpu0->nem.s.uIoCtlBuf.idPartition, sizeof(pVCpu0->nem.s.uIoCtlBuf.idPartition));
    882 #if 0
     891# if 0
    883892        AssertLogRelMsgReturn(NT_SUCCESS(rcNt), ("IoCtlGetHvPartitionId failed: %#x\n", rcNt), VERR_NEM_INIT_FAILED);
    884893        pGVM->nemr0.s.idHvPartition = pVCpu0->nem.s.uIoCtlBuf.idPartition;
    885 #else
     894# else
    886895        /*
    887896         * Since 2021 (Win11) the above I/O control doesn't work on exo-partitions
     
    903912        if (pGVM->nem.s.idHvPartition == HV_PARTITION_ID_INVALID)
    904913            pGVM->nem.s.idHvPartition = pGVM->nemr0.s.idHvPartition;
    905 #endif
     914# endif
    906915        AssertLogRelMsgReturn(pGVM->nemr0.s.idHvPartition == pGVM->nem.s.idHvPartition,
    907916                              ("idHvPartition mismatch: r0=%#RX64, r3=%#RX64\n", pGVM->nemr0.s.idHvPartition, pGVM->nem.s.idHvPartition),
     
    910919            rc = VERR_NEM_INIT_FAILED;
    911920    }
     921#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
    912922
    913923    return rc;
     
    925935VMMR0_INT_DECL(void) NEMR0CleanupVM(PGVM pGVM)
    926936{
     937#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    927938    pGVM->nemr0.s.idHvPartition = HV_PARTITION_ID_INVALID;
    928939
     
    944955        RTCritSectDelete(&pGVM->nemr0.s.HypercallDataCritSect);
    945956    nemR0DeleteHypercallData(&pGVM->nemr0.s.HypercallData);
     957#else
     958    RT_NOREF(pGVM);
     959#endif
    946960}
    947961
     
    970984
    971985
     986#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    972987/**
    973988 * Worker for NEMR0MapPages and others.
     
    10421057    }
    10431058}
     1059#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
    10441060
    10451061
     
    10581074VMMR0_INT_DECL(int) NEMR0MapPages(PGVM pGVM, VMCPUID idCpu)
    10591075{
     1076#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    10601077    /*
    10611078     * Unpack the call.
     
    10771094    }
    10781095    return rc;
     1096#else
     1097    RT_NOREF(pGVM, idCpu);
     1098    return  VERR_NOT_IMPLEMENTED;
     1099#endif
    10791100}
    10801101
    10811102
     1103#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    10821104/**
    10831105 * Worker for NEMR0UnmapPages and others.
     
    11091131    if (uResult == ((uint64_t)cPages << 32))
    11101132    {
    1111 #if 1       /* Do we need to do this? Hopefully not... */
     1133# if 1       /* Do we need to do this? Hopefully not... */
    11121134        uint64_t volatile uR = g_pfnHvlInvokeHypercall(HvCallUncommitGpaPages | ((uint64_t)cPages << 32),
    11131135                                                       pGVCpu->nemr0.s.HypercallData.HCPhysPage, 0);
    11141136        AssertMsg(uR == ((uint64_t)cPages << 32), ("uR=%#RX64\n", uR)); NOREF(uR);
    1115 #endif
     1137# endif
    11161138        return VINF_SUCCESS;
    11171139    }
     
    11201142    return VERR_NEM_UNMAP_PAGES_FAILED;
    11211143}
     1144#endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
    11221145
    11231146
     
    11361159VMMR0_INT_DECL(int) NEMR0UnmapPages(PGVM pGVM, VMCPUID idCpu)
    11371160{
     1161#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    11381162    /*
    11391163     * Unpack the call.
     
    11531177    }
    11541178    return rc;
     1179#else
     1180    RT_NOREF(pGVM, idCpu);
     1181    return  VERR_NOT_IMPLEMENTED;
     1182#endif
    11551183}
    11561184
     
    30063034VMMR0_INT_DECL(int)  NEMR0UpdateStatistics(PGVM pGVM, VMCPUID idCpu)
    30073035{
     3036#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    30083037    /*
    30093038     * Validate the call.
     
    30653094    }
    30663095    return rc;
     3096#else
     3097    RT_NOREF(pGVM, idCpu);
     3098    return VINF_SUCCESS;
     3099#endif
    30673100}
    30683101
    30693102
    3070 #if 1 && defined(DEBUG_bird)
    30713103/**
    30723104 * Debug only interface for poking around and exploring Hyper-V stuff.
     
    30783110VMMR0_INT_DECL(int) NEMR0DoExperiment(PGVM pGVM, VMCPUID idCpu, uint64_t u64Arg)
    30793111{
     3112#if defined(DEBUG_bird) && defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
    30803113    /*
    30813114     * Resolve CPU structures.
     
    31643197    }
    31653198    return rc;
     3199#else   /* !DEBUG_bird */
     3200    RT_NOREF(pGVM, idCpu, u64Arg);
     3201    return VERR_NOT_SUPPORTED;
     3202#endif /* !DEBUG_bird */
    31663203}
    3167 #endif /* DEBUG_bird */
    3168 
     3204
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp

    r91688 r91692  
    174174/** Pointer to the NtDeviceIoControlFile import table entry. */
    175175static decltype(NtDeviceIoControlFile) **g_ppfnVidNtDeviceIoControlFile;
     176#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED)
    176177/** Info about the VidGetHvPartitionId I/O control interface. */
    177178static NEMWINIOCTL g_IoCtlGetHvPartitionId;
    178179/** Info about the VidGetPartitionProperty I/O control interface. */
    179180static NEMWINIOCTL g_IoCtlGetPartitionProperty;
     181#endif
    180182#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED)
    181183/** Info about the VidStartVirtualProcessor I/O control interface. */
     
    241243*   Internal Functions                                                                                                           *
    242244*********************************************************************************************************************************/
     245DECLINLINE(int) nemR3NativeGCPhys2R3PtrReadOnly(PVM pVM, RTGCPHYS GCPhys, const void **ppv);
     246DECLINLINE(int) nemR3NativeGCPhys2R3PtrWriteable(PVM pVM, RTGCPHYS GCPhys, void **ppv);
    243247
    244248/*
     
    791795}
    792796
     797#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED)
    793798
    794799/**
     
    845850}
    846851
     852#endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED) */
    847853#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED)
    848854
     
    985991static int nemR3WinInitDiscoverIoControlProperties(PVM pVM, PRTERRINFO pErrInfo)
    986992{
     993    RT_NOREF(pVM, pErrInfo);
     994
    987995    /*
    988996     * Probe the I/O control information for select VID APIs so we can use
     
    990998     *
    991999     */
     1000#if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED)
    9921001    decltype(NtDeviceIoControlFile) * const pfnOrg = *g_ppfnVidNtDeviceIoControlFile;
    9931002
     
    10191028            g_IoCtlGetPartitionProperty.uFunction, g_IoCtlGetPartitionProperty.cbInput, g_IoCtlGetPartitionProperty.cbOutput));
    10201029
     1030#endif
    10211031    int rcRet = VINF_SUCCESS;
    10221032#if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED)
     
    11031113
    11041114    /* Done. */
     1115#ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    11051116    pVM->nem.s.IoCtlGetHvPartitionId            = g_IoCtlGetHvPartitionId;
    11061117    pVM->nem.s.IoCtlGetPartitionProperty        = g_IoCtlGetPartitionProperty;
     1118#endif
    11071119#ifdef NEM_WIN_WITH_RING0_RUNLOOP
    11081120    pVM->nem.s.IoCtlStartVirtualProcessor       = g_IoCtlStartVirtualProcessor;
  • trunk/src/VBox/VMM/include/NEMInternal.h

    r91688 r91692  
    4848 */
    4949# define NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    50 //# define NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS /**< Applies to ring-3 code only. Useful for testing VID API. */
    51 //# define NEM_WIN_USE_OUR_OWN_RUN_API          /**< Applies to ring-3 code only. Useful for testing VID API. */
     50//# define NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS   /**< Applies to ring-3 code only. Useful for testing VID API. */
     51//# define NEM_WIN_USE_OUR_OWN_RUN_API            /**< Applies to ring-3 code only. Useful for testing VID API. */
    5252//# define NEM_WIN_WITH_RING0_RUNLOOP             /**< Enables the ring-0 runloop. */
    5353//# define NEM_WIN_USE_RING0_RUNLOOP_BY_DEFAULT   /**< For quickly testing ring-3 API without messing with CFGM. */
     
    193193    uint32_t volatile           cMappedPages;
    194194
     195#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    195196    /** Info about the VidGetHvPartitionId I/O control interface. */
    196197    NEMWINIOCTL                 IoCtlGetHvPartitionId;
    197198    /** Info about the VidGetPartitionProperty I/O control interface. */
    198199    NEMWINIOCTL                 IoCtlGetPartitionProperty;
     200#  endif
    199201#  ifdef NEM_WIN_WITH_RING0_RUNLOOP
    200202    /** Info about the VidStartVirtualProcessor I/O control interface. */
     
    371373typedef struct NEMR0PERVCPU
    372374{
    373 # ifdef RT_OS_WINDOWS
     375# if defined(RT_OS_WINDOWS) && defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES)
    374376    /** Hypercall input/ouput page. */
    375377    NEMR0HYPERCALLDATA          HypercallData;
     
    387389{
    388390# ifdef RT_OS_WINDOWS
     391#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    389392    /** The partition ID. */
    390393    uint64_t                    idHvPartition;
     
    395398    /** Info about the VidGetPartitionProperty I/O control interface. */
    396399    NEMWINIOCTL                 IoCtlGetPartitionProperty;
     400#  endif
    397401#  ifdef NEM_WIN_WITH_RING0_RUNLOOP
    398402    /** Info about the VidStartVirtualProcessor I/O control interface. */
     
    406410#  endif
    407411
     412#  ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    408413    /** Hypercall input/ouput page for non-EMT. */
    409414    NEMR0HYPERCALLDATA          HypercallData;
    410415    /** Critical section protecting use of HypercallData. */
    411416    RTCRITSECT                  HypercallDataCritSect;
     417#  endif
    412418
    413419# else
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