Index: /trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp	(revision 22744)
+++ /trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp	(revision 22745)
@@ -1383,5 +1383,11 @@
 {
     unsigned cErrors = 0;
-    for (unsigned i = 0; i < RT_ELEMENTS(pShwPT->a); i++)
+#ifdef VBOX_STRICT
+    for (unsigned i = 0; i < pPage->iFirstPresent; i++)
+    {
+        Assert(!pShwPT->a[i].n.u1Present);
+    }
+#endif
+    for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pShwPT->a); i++)
     {
         if (pShwPT->a[i].n.u1Present)
@@ -1439,5 +1445,11 @@
     unsigned cChanged = 0;
 
-    for (unsigned i = 0; i < RT_ELEMENTS(pShwPT->a); i++)
+#ifdef VBOX_STRICT
+    for (unsigned i = 0; i < pPage->iFirstPresent; i++)
+    {
+        Assert(!pShwPT->a[i].n.u1Present);
+    }
+#endif
+    for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pShwPT->a); i++)
     {
         if (pShwPT->a[i].n.u1Present)
@@ -2475,4 +2487,8 @@
     pgmLock(pVM);
 
+#ifdef PGMPOOL_WITH_OPTIMIZED_DIRTY_PT
+    pgmPoolResetDirtyPages(pVM, true /* force removal. */);
+#endif
+
     /*
      * Iterate all the pages until we've encountered all that in use.
@@ -2499,8 +2515,4 @@
                 case PGMPOOLKIND_PAE_PT_FOR_PAE_2MB:
                 {
-#ifdef PGMPOOL_WITH_OPTIMIZED_DIRTY_PT
-                    if (pPage->fDirty)
-                        pgmPoolFlushDirtyPage(pVM, pPool, pPage->idxDirty, true /* force removal */);
-#endif
 #ifdef PGMPOOL_WITH_USER_TRACKING
                     if (pPage->cPresent)
