Index: /trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp	(revision 92433)
+++ /trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp	(revision 92434)
@@ -50,4 +50,5 @@
 #include <iprt/assert.h>
 #ifndef IN_SUP_HARDENED_R3
+# include <iprt/env.h>
 # include <iprt/x86.h>
 # include <iprt/ldr.h>
@@ -645,6 +646,6 @@
     return rc;
 }
+
 #endif /* !IN_SUP_HARDENED_R3 */
-
 
 DECLHIDDEN(int) suplibOsTerm(PSUPLIBDATA pThis)
@@ -662,5 +663,4 @@
     return VINF_SUCCESS;
 }
-
 
 #ifndef IN_SUP_HARDENED_R3
@@ -728,4 +728,75 @@
 {
     NOREF(pThis);
+
+    /*
+     * Do some one-time init here wrt large pages.
+     *
+     * Large pages requires the SeLockMemoryPrivilege, which by default (Win10,
+     * Win11) isn't even enabled and must be gpedit'ed to be adjustable here.
+     */
+    if (!(cPages & 511))
+    {
+        static int volatile s_fCanDoLargePages = -1;
+        int fCanDoLargePages = s_fCanDoLargePages;
+        if (s_fCanDoLargePages != -1)
+        { /* likely */ }
+        else if (RTEnvExistsUtf8("VBOX_DO_NOT_USE_LARGE_PAGES")) /** @todo add flag for this instead? */
+            s_fCanDoLargePages = fCanDoLargePages = 0;
+        else
+        {
+            HANDLE hToken = NULL;
+            if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken))
+            {
+                union
+                {
+                    TOKEN_PRIVILEGES s;
+                    uint8_t abPadding[RT_UOFFSETOF(TOKEN_PRIVILEGES, Privileges) + sizeof(LUID_AND_ATTRIBUTES)];
+                } Privileges;
+                RT_ZERO(Privileges);
+                Privileges.s.PrivilegeCount = 1;
+                Privileges.s.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+                if (LookupPrivilegeValueW(NULL, L"SeLockMemoryPrivilege", &Privileges.s.Privileges[0].Luid))
+                    AdjustTokenPrivileges(hToken, FALSE, &Privileges.s, 0, NULL, NULL);
+                else
+                    AssertFailed();
+                CloseHandle(hToken);
+            }
+            else
+                AssertFailed();
+            s_fCanDoLargePages = fCanDoLargePages = -2;
+        }
+
+        /*
+         * Try allocate with large pages.
+         */
+        if (fCanDoLargePages != 0)
+        {
+            *ppvPages = VirtualAlloc(NULL, (size_t)cPages << PAGE_SHIFT, MEM_COMMIT | MEM_LARGE_PAGES, PAGE_EXECUTE_READWRITE);
+            if (*ppvPages)
+            {
+                if (fCanDoLargePages == -2)
+                {
+                    s_fCanDoLargePages = 1;
+                    LogRel(("SUPLib: MEM_LARGE_PAGES works!\n"));
+                }
+                LogRel2(("SUPLib: MEM_LARGE_PAGES for %p LB %p\n", *ppvPages, (size_t)cPages << PAGE_SHIFT));
+                return VINF_SUCCESS;
+            }
+
+            /* This can happen if the above AdjustTokenPrivileges failed (non-admin
+               user), or if the privilege isn't present in the token (need gpedit). */
+            if (GetLastError() == ERROR_PRIVILEGE_NOT_HELD)
+            {
+                LogRel(("SUPLib: MEM_LARGE_PAGES privilege not held.\n"));
+                s_fCanDoLargePages = 0;
+            }
+            else
+                LogRel2(("SUPLib: MEM_LARGE_PAGES allocation failed with odd status: %u\n", GetLastError()));
+        }
+    }
+
+    /*
+     * Do a regular allocation w/o large pages.
+     */
     *ppvPages = VirtualAlloc(NULL, (size_t)cPages << PAGE_SHIFT, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
     if (*ppvPages)
Index: /trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp	(revision 92433)
+++ /trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp	(revision 92434)
@@ -2425,5 +2425,5 @@
  * and the CPU causing a natural VMEXIT, it is not known whether this still
  * causes extra work on subsequent WHvRunVirtualProcessor calls (it did in and
- * earlier 17134).
+ * earlier than 17134).
  *
  * Registers are retrieved and set via WHvGetVirtualProcessorRegisters and
@@ -2760,4 +2760,21 @@
  *   Update: All concerns have been addressed in build 17110.
  *
+ *
+ * @section sec_nem_win_large_pages     Large Pages
+ *
+ * We've got a standalone memory allocation and access testcase bs3-memalloc-1
+ * which was run with 48GiB of guest RAM configured on a NUC 11 box running
+ * Windows 11 GA.  In the simplified NEM memory mode no exits should be
+ * generated while the access tests are running.
+ *
+ * The bs3-memalloc-1 results kind of hints at some tiny speed-up if the guest
+ * RAM is allocated using the MEM_LARGE_PAGES flag, but only in the 3rd access
+ * check (typical 350 000 MiB/s w/o and around 400 000 MiB/s).  The result for
+ * the 2nd access varies a lot, perhaps hinting at some table optimizations
+ * going on.
+ *
+ * The initial access where the memory is locked/whatever has absolutely horrid
+ * results regardless of whether large pages are enabled or not. Typically
+ * bobbing close to 500 MiB/s, non-large pages a little faster.
  *
  *
