]> git.ipfire.org Git - thirdparty/linux.git/commit
KVM: Use vCPU specific memslots in __kvm_vcpu_map()
authorSean Christopherson <seanjc@google.com>
Fri, 21 Nov 2025 22:34:40 +0000 (14:34 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 8 Jan 2026 19:58:21 +0000 (11:58 -0800)
commit44da6629d2820c8fd9ffa58cc7e46c2215828cb8
treeaa864e2f8df7c5eb0c718d5c4ad41f596bdc8ac9
parent9ace4753a5202b02191d54e9fdf7f9e3d02b85eb
KVM: Use vCPU specific memslots in __kvm_vcpu_map()

When establishing a "host access map", lookup the gfn in the vCPU specific
memslots, as the intent is that the mapping will be established for the
current vCPU context.  Specifically, using __kvm_vcpu_map() in x86's SMM
context should create mappings based on the SMM memslots, not the non-SMM
memslots.

Luckily, the bug is benign as x86 is the only architecture with multiple
memslot address spaces, and all of x86's usage is limited to non-SMM.  The
calls in (or reachable by) {svm,vmx}_enter_smm() are made before
enter_smm() sets HF_SMM_MASK, and the calls in {svm,vmx}_leave_smm() are
made after emulator_leave_smm() clears HF_SMM_MASK.

Note, kvm_vcpu_unmap() uses the vCPU specific memslots, only the map() side
of things is broken.

Fixes: 357a18ad230f ("KVM: Kill kvm_map_gfn() / kvm_unmap_gfn() and gfn_to_pfn_cache")
Link: https://patch.msgid.link/20251121223444.355422-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
virt/kvm/kvm_main.c