Changeset 92434 in vbox
- Timestamp:
- Nov 15, 2021 5:12:43 PM (3 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
-
HostDrivers/Support/win/SUPLib-win.cpp (modified) (4 diffs)
-
VMM/VMMR3/NEMR3Native-win.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp
r85129 r92434 50 50 #include <iprt/assert.h> 51 51 #ifndef IN_SUP_HARDENED_R3 52 # include <iprt/env.h> 52 53 # include <iprt/x86.h> 53 54 # include <iprt/ldr.h> … … 645 646 return rc; 646 647 } 648 647 649 #endif /* !IN_SUP_HARDENED_R3 */ 648 649 650 650 651 DECLHIDDEN(int) suplibOsTerm(PSUPLIBDATA pThis) … … 662 663 return VINF_SUCCESS; 663 664 } 664 665 665 666 666 #ifndef IN_SUP_HARDENED_R3 … … 728 728 { 729 729 NOREF(pThis); 730 731 /* 732 * Do some one-time init here wrt large pages. 733 * 734 * Large pages requires the SeLockMemoryPrivilege, which by default (Win10, 735 * Win11) isn't even enabled and must be gpedit'ed to be adjustable here. 736 */ 737 if (!(cPages & 511)) 738 { 739 static int volatile s_fCanDoLargePages = -1; 740 int fCanDoLargePages = s_fCanDoLargePages; 741 if (s_fCanDoLargePages != -1) 742 { /* likely */ } 743 else if (RTEnvExistsUtf8("VBOX_DO_NOT_USE_LARGE_PAGES")) /** @todo add flag for this instead? */ 744 s_fCanDoLargePages = fCanDoLargePages = 0; 745 else 746 { 747 HANDLE hToken = NULL; 748 if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken)) 749 { 750 union 751 { 752 TOKEN_PRIVILEGES s; 753 uint8_t abPadding[RT_UOFFSETOF(TOKEN_PRIVILEGES, Privileges) + sizeof(LUID_AND_ATTRIBUTES)]; 754 } Privileges; 755 RT_ZERO(Privileges); 756 Privileges.s.PrivilegeCount = 1; 757 Privileges.s.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 758 if (LookupPrivilegeValueW(NULL, L"SeLockMemoryPrivilege", &Privileges.s.Privileges[0].Luid)) 759 AdjustTokenPrivileges(hToken, FALSE, &Privileges.s, 0, NULL, NULL); 760 else 761 AssertFailed(); 762 CloseHandle(hToken); 763 } 764 else 765 AssertFailed(); 766 s_fCanDoLargePages = fCanDoLargePages = -2; 767 } 768 769 /* 770 * Try allocate with large pages. 771 */ 772 if (fCanDoLargePages != 0) 773 { 774 *ppvPages = VirtualAlloc(NULL, (size_t)cPages << PAGE_SHIFT, MEM_COMMIT | MEM_LARGE_PAGES, PAGE_EXECUTE_READWRITE); 775 if (*ppvPages) 776 { 777 if (fCanDoLargePages == -2) 778 { 779 s_fCanDoLargePages = 1; 780 LogRel(("SUPLib: MEM_LARGE_PAGES works!\n")); 781 } 782 LogRel2(("SUPLib: MEM_LARGE_PAGES for %p LB %p\n", *ppvPages, (size_t)cPages << PAGE_SHIFT)); 783 return VINF_SUCCESS; 784 } 785 786 /* This can happen if the above AdjustTokenPrivileges failed (non-admin 787 user), or if the privilege isn't present in the token (need gpedit). */ 788 if (GetLastError() == ERROR_PRIVILEGE_NOT_HELD) 789 { 790 LogRel(("SUPLib: MEM_LARGE_PAGES privilege not held.\n")); 791 s_fCanDoLargePages = 0; 792 } 793 else 794 LogRel2(("SUPLib: MEM_LARGE_PAGES allocation failed with odd status: %u\n", GetLastError())); 795 } 796 } 797 798 /* 799 * Do a regular allocation w/o large pages. 800 */ 730 801 *ppvPages = VirtualAlloc(NULL, (size_t)cPages << PAGE_SHIFT, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 731 802 if (*ppvPages) -
trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
r92177 r92434 2425 2425 * and the CPU causing a natural VMEXIT, it is not known whether this still 2426 2426 * causes extra work on subsequent WHvRunVirtualProcessor calls (it did in and 2427 * earlier 17134).2427 * earlier than 17134). 2428 2428 * 2429 2429 * Registers are retrieved and set via WHvGetVirtualProcessorRegisters and … … 2760 2760 * Update: All concerns have been addressed in build 17110. 2761 2761 * 2762 * 2763 * @section sec_nem_win_large_pages Large Pages 2764 * 2765 * We've got a standalone memory allocation and access testcase bs3-memalloc-1 2766 * which was run with 48GiB of guest RAM configured on a NUC 11 box running 2767 * Windows 11 GA. In the simplified NEM memory mode no exits should be 2768 * generated while the access tests are running. 2769 * 2770 * The bs3-memalloc-1 results kind of hints at some tiny speed-up if the guest 2771 * RAM is allocated using the MEM_LARGE_PAGES flag, but only in the 3rd access 2772 * check (typical 350 000 MiB/s w/o and around 400 000 MiB/s). The result for 2773 * the 2nd access varies a lot, perhaps hinting at some table optimizations 2774 * going on. 2775 * 2776 * The initial access where the memory is locked/whatever has absolutely horrid 2777 * results regardless of whether large pages are enabled or not. Typically 2778 * bobbing close to 500 MiB/s, non-large pages a little faster. 2762 2779 * 2763 2780 *
Note:
See TracChangeset
for help on using the changeset viewer.

