Index: /trunk/src/VBox/Main/include/PlatformPropertiesImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/PlatformPropertiesImpl.h	(revision 104818)
+++ /trunk/src/VBox/Main/include/PlatformPropertiesImpl.h	(revision 104819)
@@ -67,4 +67,5 @@
     static ULONG s_getMaxNetworkAdapters(ChipsetType_T aChipset);
     static ULONG s_getMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType);
+    static HRESULT s_getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled, ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB);
 
 private:
Index: /trunk/src/VBox/Main/src-all/PlatformPropertiesImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-all/PlatformPropertiesImpl.cpp	(revision 104818)
+++ /trunk/src/VBox/Main/src-all/PlatformPropertiesImpl.cpp	(revision 104819)
@@ -822,6 +822,17 @@
 }
 
-HRESULT PlatformProperties::getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled,
-                                                  ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB)
+/**
+ * Returns the [minimum, maximum] VRAM range and stride size for a given graphics controller.
+ *
+ * @returns HRESULT
+ * @param   aGraphicsControllerType Graphics controller type to return values for.
+ * @param   fAccelerate3DEnabled    whether 3D acceleration is enabled / disabled for the selected graphics controller.
+ * @param   aMinMB                  Where to return the minimum VRAM (in MB).
+ * @param   aMaxMB                  Where to return the maximum VRAM (in MB).
+ * @param   aStrideSizeMB           Where to return stride size (in MB). Optional, can be NULL.
+ */
+/* static */
+HRESULT PlatformProperties::s_getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled,
+                                                    ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB)
 {
 #if !defined(VBOX_WITH_VMSVGA) || !defined(VBOX_WITH_VMSVGA3D)
@@ -860,5 +871,5 @@
             cbMax = SVGA_VRAM_MAX_SIZE;
 #else
-            return setError(VBOX_E_NOT_SUPPORTED, tr("Support for SVGA not available in this version"));
+            return VBOX_E_NOT_SUPPORTED;
 #endif
             break;
@@ -874,10 +885,11 @@
 
         default:
-            return setError(E_INVALIDARG, tr("The graphics controller type (%d) is invalid"), aGraphicsControllerType);
-    }
-
-    *aMinMB        = (ULONG)(RT_ALIGN_64(cbMin, cbStride) / _1M);
-    *aMaxMB        = (ULONG)(RT_ALIGN_64(cbMax, cbStride) / _1M);
-    *aStrideSizeMB = (ULONG)cbStride / _1M;
+            return E_INVALIDARG;
+    }
+
+    /* Convert bytes -> MB, align to stride. */
+    cbMin    = (ULONG)(RT_ALIGN_64(cbMin, cbStride) / _1M);
+    cbMax    = (ULONG)(RT_ALIGN_64(cbMax, cbStride) / _1M);
+    cbStride = (ULONG)cbStride / _1M;
 
 #define MAKE_POWER_OF_TWO(a_MB) \
@@ -885,9 +897,38 @@
         a_MB = a_MB + 1; \
 
-    MAKE_POWER_OF_TWO(*aMinMB);
-    MAKE_POWER_OF_TWO(*aMaxMB);
-    MAKE_POWER_OF_TWO(*aStrideSizeMB);
+    MAKE_POWER_OF_TWO(cbMin);
+    MAKE_POWER_OF_TWO(cbMax);
+    MAKE_POWER_OF_TWO(cbStride);
 
 #undef MAKE_POWER_OF_TWO
+
+    /* Finally, clamp the values to our schema definitions before returning. */
+    cbMin = RT_CLAMP(cbMin, (size_t)SchemaDefs::MinGuestVRAM, (size_t)SchemaDefs::MaxGuestVRAM);
+    cbMax = RT_CLAMP(cbMax, (size_t)SchemaDefs::MinGuestVRAM, (size_t)SchemaDefs::MaxGuestVRAM);
+
+    *aMinMB = (ULONG)cbMin;
+    *aMaxMB = (ULONG)cbMax;
+    if (aStrideSizeMB)
+        *aStrideSizeMB = (ULONG)cbStride;
+
+    return S_OK;
+}
+
+HRESULT PlatformProperties::getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled,
+                                                  ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB)
+{
+    HRESULT hrc = PlatformProperties::s_getSupportedVRAMRange(aGraphicsControllerType, fAccelerate3DEnabled, aMinMB, aMaxMB,
+                                                              aStrideSizeMB);
+    switch (hrc)
+    {
+        case VBOX_E_NOT_SUPPORTED:
+            return setError(VBOX_E_NOT_SUPPORTED, tr("Selected graphics controller not supported in this version"));
+
+        case E_INVALIDARG:
+            return setError(E_INVALIDARG, tr("The graphics controller type (%d) is invalid"), aGraphicsControllerType);
+
+        default:
+            break;
+    }
 
     return S_OK;
Index: /trunk/src/VBox/Main/src-server/GraphicsAdapterImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/GraphicsAdapterImpl.cpp	(revision 104818)
+++ /trunk/src/VBox/Main/src-server/GraphicsAdapterImpl.cpp	(revision 104819)
@@ -229,13 +229,21 @@
 HRESULT GraphicsAdapter::setVRAMSize(ULONG aVRAMSize)
 {
-    /* check VRAM limits */
-    if (aVRAMSize > SchemaDefs::MaxGuestVRAM)
-        return setError(E_INVALIDARG,
-                        tr("Invalid VRAM size: %lu MB (must be in range [%lu, %lu] MB)"),
-                        aVRAMSize, SchemaDefs::MinGuestVRAM, SchemaDefs::MaxGuestVRAM);
-
     /* the machine needs to be mutable */
     AutoMutableStateDependency adep(mParent);
     if (FAILED(adep.hrc())) return adep.hrc();
+
+    ULONG uMin, uMax;
+    HRESULT hrc = PlatformProperties::s_getSupportedVRAMRange(mData->graphicsControllerType, mData->fAccelerate3D,
+                                                              &uMin, &uMax, NULL /* aStrideSizeMB */);
+    if (FAILED(hrc))
+        return setError(hrc,
+                        tr("Error getting VRAM range for selected graphics controller"));
+
+    /* check VRAM limits */
+    if (   aVRAMSize < uMin
+        || aVRAMSize > uMax)
+        return setError(E_INVALIDARG,
+                        tr("Invalid VRAM size: %lu MB (must be in range [%lu, %lu] MB)"),
+                        aVRAMSize, uMin, uMax);
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
