]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: x86: Add lockdep-guarded asserts on register cache usage
authorSean Christopherson <seanjc@google.com>
Wed, 9 Oct 2024 17:50:01 +0000 (10:50 -0700)
committerSean Christopherson <seanjc@google.com>
Fri, 1 Nov 2024 16:22:22 +0000 (09:22 -0700)
commit1c932fc7620ddb9f5005fd4b0cf7f0ff47ecaaa4
tree11800e8d5149f4d64ac9bb6054b6522776a84935
parentf0e7012c4b938606c7ca230154f181f8eed683eb
KVM: x86: Add lockdep-guarded asserts on register cache usage

When lockdep is enabled, assert that KVM accesses the register caches if
and only if cache fills are guaranteed to consume fresh data, i.e. when
KVM when KVM is in control of the code sequence.  Concretely, the caches
can only be used from task context (synchronous) or when handling a PMI
VM-Exit (asynchronous, but only in specific windows where the caches are
in a known, stable state).

Generally speaking, there are very few flows where reading register state
from an asynchronous context is correct or even necessary.  So, rather
than trying to figure out a generic solution, simply disallow using the
caches outside of task context by default, and deal with any future
exceptions on a case-by-case basis _if_ they arise.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Link: https://lore.kernel.org/r/20241009175002.1118178-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/kvm_cache_regs.h