]> git.ipfire.org Git - thirdparty/qemu.git/commit
i386/kvm: Prefault memory on page state change
authorTom Lendacky <thomas.lendacky@amd.com>
Fri, 28 Mar 2025 20:30:24 +0000 (15:30 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 6 Jun 2025 12:32:54 +0000 (14:32 +0200)
commit4cdc489eb9c25f76255a550a4a0b19cda3435a76
treead01a6baaecfae5f1001bdee2b69e4f43f14f7d0
parentbc2a48d647752e4f99247184f5dfe00e67a2de8f
i386/kvm: Prefault memory on page state change

A page state change is typically followed by an access of the page(s) and
results in another VMEXIT in order to map the page into the nested page
table. Depending on the size of page state change request, this can
generate a number of additional VMEXITs. For example, under SNP, when
Linux is utilizing lazy memory acceptance, memory is typically accepted in
4M chunks. A page state change request is submitted to mark the pages as
private, followed by validation of the memory. Since the guest_memfd
currently only supports 4K pages, each page validation will result in
VMEXIT to map the page, resulting in 1024 additional exits.

When performing a page state change, invoke KVM_PRE_FAULT_MEMORY for the
size of the page state change in order to pre-map the pages and avoid the
additional VMEXITs. This helps speed up boot times.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/f5411c42340bd2f5c14972551edb4e959995e42b.1743193824.git.thomas.lendacky@amd.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
accel/kvm/kvm-all.c
include/system/kvm.h
target/i386/kvm/kvm.c