]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: x86: Funnel all fancy MSR return value handling into a common helper
authorSean Christopherson <seanjc@google.com>
Fri, 2 Aug 2024 18:19:32 +0000 (11:19 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 22 Aug 2024 19:07:36 +0000 (12:07 -0700)
commit1cec2034980ad03ebf8ce0f187a8f3101c33e611
tree033105292c59c7035ba4de0ecce2c8f6722d23e2
parent7075f163615072a74bae7c5344210adec5f9ea2a
KVM: x86: Funnel all fancy MSR return value handling into a common helper

Add a common helper, kvm_do_msr_access(), to invoke the "leaf" APIs that
are type and access specific, and more importantly to handle errors that
are returned from the leaf APIs.  I.e. turn kvm_msr_ignored_check() from a
a helper that is called on an error, into a trampoline that detects errors
*and* applies relevant side effects, e.g. logging unimplemented accesses.

Because the leaf APIs are used for guest accesses, userspace accesses, and
KVM accesses, and because KVM supports restricting access to MSRs from
userspace via filters, the error handling is subtly non-trivial.  E.g. KVM
has had at least one bug escape due to making each "outer" function handle
errors.  See commit 3376ca3f1a20 ("KVM: x86: Fix KVM_GET_MSRS stack info
leak").

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