KVM: nSVM: Access MSRPM in 4-byte chunks only for merging L0 and L1 bitmaps
authorSean Christopherson <seanjc@google.com>
Tue, 10 Jun 2025 22:57:32 +0000 (15:57 -0700)
committerSean Christopherson <seanjc@google.com>
Fri, 20 Jun 2025 20:07:34 +0000 (13:07 -0700)
commit52f82177429e0631afebb676e57d05e621153b0d
treefe32dddedb41e22bb4568ccca3f0d20065710acf
parent7fe0578041188d63207f17335e8c0d10e19c7515
KVM: nSVM: Access MSRPM in 4-byte chunks only for merging L0 and L1 bitmaps

Access the MSRPM using u32/4-byte chunks (and appropriately adjusted
offsets) only when merging L0 and L1 bitmaps as part of emulating VMRUN.
The only reason to batch accesses to MSRPMs is to avoid the overhead of
uaccess operations (e.g. STAC/CLAC and bounds checks) when reading L1's
bitmap pointed at by vmcb12.  For all other uses, either per-bit accesses
are more than fast enough (no uaccess), or KVM is only accessing a single
bit (nested_svm_exit_handled_msr()) and so there's nothing to batch.

In addition to (hopefully) documenting the uniqueness of the merging code,
restricting chunked access to _just_ the merging code will allow for
increasing the chunk size (to unsigned long) with minimal risk.

Link: https://lore.kernel.org/r/20250610225737.156318-28-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/nested.c