summaryrefslogtreecommitdiff
path: root/src/VBox/VMM/VMMR3/PDMDevice.cpp
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2021-11-12 22:17:42 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2021-11-12 22:17:42 +0000
commitccc7f5f3c71a827310ac244d55afa2957d90c2f1 (patch)
treeed153df4f475e094a18094edf8c3d15605a9ec96 /src/VBox/VMM/VMMR3/PDMDevice.cpp
parent3c3d5811e588757cd01d32eb6778368833bcbafe (diff)
downloadVirtualBox-svn-ccc7f5f3c71a827310ac244d55afa2957d90c2f1.tar.gz
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
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@92409 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/VMM/VMMR3/PDMDevice.cpp')
-rw-r--r--src/VBox/VMM/VMMR3/PDMDevice.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/VBox/VMM/VMMR3/PDMDevice.cpp b/src/VBox/VMM/VMMR3/PDMDevice.cpp
index 8d79c7e8524..8b944d83cf2 100644
--- a/src/VBox/VMM/VMMR3/PDMDevice.cpp
+++ b/src/VBox/VMM/VMMR3/PDMDevice.cpp
@@ -277,7 +277,8 @@ int pdmR3DevInit(PVM pVM)
/* RZEnabled, R0Enabled, RCEnabled*/
bool fR0Enabled = false;
bool fRCEnabled = false;
- if (pReg->fFlags & (PDM_DEVREG_FLAGS_R0 | PDM_DEVREG_FLAGS_RC))
+ if ( (pReg->fFlags & (PDM_DEVREG_FLAGS_R0 | PDM_DEVREG_FLAGS_RC))
+ && !PGMR3IsNemModeEnabled(pVM) /* No ring-0 in simplified memory mode. */ )
{
if (pReg->fFlags & PDM_DEVREG_FLAGS_R0)
{
@@ -413,9 +414,15 @@ int pdmR3DevInit(PVM pVM)
pReg->szName, cb, PDM_MAX_DEVICE_INSTANCE_SIZE_R3),
VERR_ALLOCATION_TOO_BIG);
+#if 0 /* Several devices demands cacheline aligned data, if not page aligned. Real problem in NEM mode. */
rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_DEVICE, cb, (void **)&pDevIns);
AssertLogRelMsgRCReturn(rc, ("Failed to allocate %zu bytes of instance data for device '%s'. rc=%Rrc\n",
cb, pReg->szName, rc), rc);
+#else
+ pDevIns = (PPDMDEVINS)RTMemPageAllocZ(cb);
+ AssertLogRelMsgReturn(pDevIns, ("Failed to allocate %zu bytes of instance data for device '%s'\n", cb, pReg->szName),
+ VERR_NO_PAGE_MEMORY);
+#endif
/* Initialize it: */
pDevIns->u32Version = PDM_DEVINSR3_VERSION;