Index: /trunk/src/VBox/VMM/VMMR3/NEMR3Native-linux.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/NEMR3Native-linux.cpp	(revision 92554)
+++ /trunk/src/VBox/VMM/VMMR3/NEMR3Native-linux.cpp	(revision 92555)
@@ -535,4 +535,8 @@
                         STAMR3RegisterF(pVM, &pNemCpu->StatExportPendingInterrupt, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of times an interrupt was pending when exporting to KVM", "/NEM/CPU%u/ExportPendingInterrupt", idCpu);
                         STAMR3RegisterF(pVM, &pNemCpu->StatFlushExitOnReturn,   STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of times a KVM_EXIT_IO or KVM_EXIT_MMIO was flushed before returning to EM", "/NEM/CPU%u/FlushExitOnReturn", idCpu);
+                        STAMR3RegisterF(pVM, &pNemCpu->StatFlushExitOnReturn1Loop, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of times a KVM_EXIT_IO or KVM_EXIT_MMIO was flushed before returning to EM", "/NEM/CPU%u/FlushExitOnReturn-01-loop", idCpu);
+                        STAMR3RegisterF(pVM, &pNemCpu->StatFlushExitOnReturn2Loops, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of times a KVM_EXIT_IO or KVM_EXIT_MMIO was flushed before returning to EM", "/NEM/CPU%u/FlushExitOnReturn-02-loops", idCpu);
+                        STAMR3RegisterF(pVM, &pNemCpu->StatFlushExitOnReturn3Loops, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of times a KVM_EXIT_IO or KVM_EXIT_MMIO was flushed before returning to EM", "/NEM/CPU%u/FlushExitOnReturn-03-loops", idCpu);
+                        STAMR3RegisterF(pVM, &pNemCpu->StatFlushExitOnReturn4PlusLoops, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of times a KVM_EXIT_IO or KVM_EXIT_MMIO was flushed before returning to EM", "/NEM/CPU%u/FlushExitOnReturn-04-to-7-loops", idCpu);
                         STAMR3RegisterF(pVM, &pNemCpu->StatQueryCpuTick,        STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of TSC queries",                  "/NEM/CPU%u/QueryCpuTick", idCpu);
                         STAMR3RegisterF(pVM, &pNemCpu->StatExitTotal,           STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "All exits",                  "/NEM/CPU%u/Exit", idCpu);
@@ -2559,14 +2563,51 @@
      * If the last exit was stateful, commit the state we provided before
      * returning to the EM loop so we have a consistent state and can safely
-     * be rescheduled and whatnot.  (There is no 'ing way to reset the kernel
-     * side completion callback for these stateful i/o exits.)
-     */
-    if (fStatefulExit)
-    {
-        pRun->immediate_exit = 1;
-        int rcLnx = ioctl(pVCpu->nem.s.fdVCpu, KVM_RUN, 0UL);
+     * be rescheduled and whatnot.  This may require us to make multiple runs
+     * for larger MMIO and I/O operations. Sigh^3.
+     *
+     * Note! There is no 'ing way to reset the kernel side completion callback
+     *       for these stateful i/o exits.  Very annoying interface.
+     */
+    /** @todo check how this works with string I/O and string MMIO. */
+    if (fStatefulExit && RT_SUCCESS(rcStrict))
+    {
+        STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatFlushExitOnReturn);
+        uint32_t const uOrgExit = pRun->exit_reason;
+        for (uint32_t i = 0; ; i++)
+        {
+            pRun->immediate_exit = 1;
+            int rcLnx = ioctl(pVCpu->nem.s.fdVCpu, KVM_RUN, 0UL);
+            Log(("NEM/%u: Flushed stateful exit -> %d/%d exit_reason=%d\n", pVCpu->idCpu, rcLnx, errno, pRun->exit_reason));
+            if (rcLnx == -1 && errno == EINTR)
+            {
+                switch (i)
+                {
+                    case 0: STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatFlushExitOnReturn1Loop); break;
+                    case 1: STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatFlushExitOnReturn2Loops); break;
+                    case 2: STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatFlushExitOnReturn3Loops); break;
+                    default: STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatFlushExitOnReturn4PlusLoops); break;
+                }
+                break;
+            }
+            AssertLogRelMsgBreakStmt(rcLnx == 0 && pRun->exit_reason == uOrgExit,
+                                     ("rcLnx=%d errno=%d exit_reason=%d uOrgExit=%d\n", rcLnx, errno, pRun->exit_reason, uOrgExit),
+                                     rcStrict = VERR_NEM_IPE_6);
+            VBOXSTRICTRC rcStrict2 = nemHCLnxHandleExit(pVM, pVCpu, pRun, &fStatefulExit);
+            if (rcStrict2 == VINF_SUCCESS || rcStrict2 == rcStrict)
+            { /* likely */ }
+            else if (RT_FAILURE(rcStrict2))
+            {
+                rcStrict = rcStrict2;
+                break;
+            }
+            else
+            {
+                AssertLogRelMsgBreakStmt(rcStrict == VINF_SUCCESS,
+                                         ("rcStrict=%Rrc rcStrict2=%Rrc\n", VBOXSTRICTRC_VAL(rcStrict), VBOXSTRICTRC_VAL(rcStrict2)),
+                                         rcStrict = VERR_NEM_IPE_7);
+                rcStrict = rcStrict2;
+            }
+        }
         pRun->immediate_exit = 0;
-        Log(("NEM/%u: Flushed stateful exit -> %d/%d exit_reason=%d\n", pVCpu->idCpu, rcLnx, errno, pRun->exit_reason)); RT_NOREF(rcLnx);
-        STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatFlushExitOnReturn);
     }
 
Index: /trunk/src/VBox/VMM/include/NEMInternal.h
===================================================================
--- /trunk/src/VBox/VMM/include/NEMInternal.h	(revision 92554)
+++ /trunk/src/VBox/VMM/include/NEMInternal.h	(revision 92555)
@@ -382,4 +382,8 @@
     STAMCOUNTER                 StatBreakOnStatus;
     STAMCOUNTER                 StatFlushExitOnReturn;
+    STAMCOUNTER                 StatFlushExitOnReturn1Loop;
+    STAMCOUNTER                 StatFlushExitOnReturn2Loops;
+    STAMCOUNTER                 StatFlushExitOnReturn3Loops;
+    STAMCOUNTER                 StatFlushExitOnReturn4PlusLoops;
     STAMCOUNTER                 StatImportOnDemand;
     STAMCOUNTER                 StatImportOnReturn;
