Skip to content

qemu: lock guest memory for x86_64 guests on Intel - #8049

Merged
osy merged 1 commit into
utmapp:mainfrom
nightness:macos/intel-hvf-memory-lock
Nov 12, 2026
Merged

osy merged 1 commit into
utmapp:mainfrom
nightness:macos/intel-hvf-memory-lock

Conversation

@nightness

Copy link
Copy Markdown
Contributor

Depends on utmapp/qemu#19. mlockall() returns ENOSYS on macOS, so without that QEMU change, -overcommit mem-lock=on makes QEMU exit with "locking memory failed". With it, QEMU locks each guest RAM mapping on HVF and only warns if a lock fails, so the VM still starts on a Mac without enough free memory. This is a draft until that lands.

Part of #8046.

Without a memory lock, macOS compresses and swaps guest RAM under memory pressure, and the guest then stalls on page faults when it touches that memory again. That shows up as stutter and audio dropouts in Windows, mostly on Macs with 8–16 GB.

For x86_64 guests that use the hypervisor on an Intel Mac, this passes -overcommit mem-lock=on. It is a per-VM setting, QEMU → Tweaks → Lock guest memory, stored as MemoryLock and on by default. The toggle is shown only for x86_64 guests that use the hypervisor in an Intel build.

Testing: Tested by a human on macOS 15.8.1, MacBook Pro 14,3 (2017, i7-7700HQ), with an 8 GB Windows 11 x64 guest, using a QEMU with utmapp/qemu#19. It was tested in a combined build with the other Intel changes from #8046. The VM starts with the lock in place, and the QEMU command line has -overcommit mem-lock=on. I didn't measure its effect on its own.

I have read the AI contribution guidelines and have followed them to the best of my ability.

The author acknowledges that this change has been tested and/or reviewed by a human in accordance with UTM's AI contribution guidelines.

@osy
osy marked this pull request as ready for review November 12, 2026 03:58
Without -overcommit mem-lock=on, macOS compresses and swaps guest RAM under
memory pressure, and the guest then stalls on page faults when it touches
that memory again.

For x86_64 guests that use the hypervisor on an Intel Mac, pass
-overcommit mem-lock=on. It is a per-VM setting under QEMU > Tweaks,
stored as MemoryLock and on by default.

This needs utmapp/qemu#19: mlockall() returns ENOSYS on macOS, so without
it QEMU exits with "locking memory failed". With it, QEMU locks each guest
RAM mapping on HVF and only warns if a lock fails.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Josh Guyette <joshguyette@yahoo.com>
@osy
osy force-pushed the macos/intel-hvf-memory-lock branch from e026c91 to 5a25d0a Compare November 12, 2026 03:59
@osy
osy merged commit e66b8bb into utmapp:main Nov 12, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants