VirtualBox

Changeset 92409 in vbox


Ignore:
Timestamp:
Nov 12, 2021 10:17:42 PM (3 years ago)
Author:
vboxsync
Message:

VMM/PDM,PGM: Added PGMR3IsNemModeEnabled and made PDM not put devices in ring-0 when the simplified memory mode is active as it is implied that we won't be running anything from ring-0 (at least not on windows and mac, I think). PDM must use RTMemAllocZ instead of MMR3HeapAllocZEx for allocating device instance data to get proper alignment. bugref:10122

Location:
trunk
Files:
3 edited

Legend:

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

    r92368 r92409  
    695695 */
    696696VMMR3_INT_DECL(void)    PGMR3EnableNemMode(PVM pVM);
     697VMMR3_INT_DECL(bool)    PGMR3IsNemModeEnabled(PVM pVM);
    697698VMMR3DECL(int)      PGMR3Init(PVM pVM);
    698699VMMR3DECL(int)      PGMR3InitFinalize(PVM pVM);
  • trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp

    r91895 r92409  
    278278        bool fR0Enabled = false;
    279279        bool fRCEnabled = false;
    280         if (pReg->fFlags & (PDM_DEVREG_FLAGS_R0 | PDM_DEVREG_FLAGS_RC))
     280        if (   (pReg->fFlags & (PDM_DEVREG_FLAGS_R0 | PDM_DEVREG_FLAGS_RC))
     281            && !PGMR3IsNemModeEnabled(pVM) /* No ring-0 in simplified memory mode. */ )
    281282        {
    282283            if (pReg->fFlags & PDM_DEVREG_FLAGS_R0)
     
    414415                                  VERR_ALLOCATION_TOO_BIG);
    415416
     417#if 0  /* Several devices demands cacheline aligned data, if not page aligned. Real problem in NEM mode. */
    416418            rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_DEVICE, cb, (void **)&pDevIns);
    417419            AssertLogRelMsgRCReturn(rc, ("Failed to allocate %zu bytes of instance data for device '%s'. rc=%Rrc\n",
    418420                                         cb, pReg->szName, rc), rc);
     421#else
     422            pDevIns = (PPDMDEVINS)RTMemPageAllocZ(cb);
     423            AssertLogRelMsgReturn(pDevIns, ("Failed to allocate %zu bytes of instance data for device '%s'\n", cb, pReg->szName),
     424                                  VERR_NO_PAGE_MEMORY);
     425#endif
    419426
    420427            /* Initialize it: */
  • trunk/src/VBox/VMM/VMMR3/PGM.cpp

    r92385 r92409  
    712712#endif
    713713
    714 
    715714#ifdef VBOX_WITH_PGM_NEM_MODE
     715
    716716/**
    717717 * Interface that NEM uses to switch PGM into simplified memory managment mode.
     
    726726    pVM->pgm.s.fNemMode = true;
    727727}
    728 #endif
    729 
     728
     729
     730/**
     731 * Checks whether the simplificed memory management mode for NEM is enabled.
     732 *
     733 * @returns true if enabled, false if not.
     734 * @param   pVM     The cross context VM structure.
     735 */
     736VMMR3_INT_DECL(bool)    PGMR3IsNemModeEnabled(PVM pVM)
     737{
     738    return pVM->pgm.s.fNemMode;
     739}
     740
     741#endif /* VBOX_WITH_PGM_NEM_MODE */
    730742
    731743/**
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