From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Oliver Upton <oliver.upton@linux.dev>,
Marc Zyngier <maz@kernel.org>,
Sean Christopherson <seanjc@google.com>
Subject: [PATCH] Documentation: KVM: Formalizing taking vcpu->mutex *outside* of kvm->slots_lock
Date: Thu, 16 Oct 2025 16:55:38 -0700 [thread overview]
Message-ID: <20251016235538.171962-1-seanjc@google.com> (raw)
Explicitly document the ordering of vcpu->mutex being taken *outside* of
kvm->slots_lock. While extremely unintuitive, and arguably wrong, both
arm64 and x86 have gained flows that take kvm->slots_lock inside of
vcpu->mutex. x86's kvm_inhibit_apic_access_page() is particularly
nasty, as slots_lock is taken quite deep within KVM_RUN, i.e. simply
swapping the ordering isn't an option.
Commit to the vcpu->mutex => kvm->slots_lock ordering even though taking a
VM-scoped lock inside a vCPU-scoped lock is odd, as vcpu->mutex really is
intended to be a "top-level" lock in most respects, whereas kvm->slots_lock
is "just" a helper lock.
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
Documentation/virt/kvm/locking.rst | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/virt/kvm/locking.rst b/Documentation/virt/kvm/locking.rst
index ae8bce7fecbe..2b4c786038be 100644
--- a/Documentation/virt/kvm/locking.rst
+++ b/Documentation/virt/kvm/locking.rst
@@ -17,6 +17,8 @@ The acquisition orders for mutexes are as follows:
- kvm->lock is taken outside kvm->slots_lock and kvm->irq_lock
+- vcpu->mutex is taken outside kvm->slots_lock
+
- kvm->slots_lock is taken outside kvm->irq_lock, though acquiring
them together is quite rare.
base-commit: 6b36119b94d0b2bb8cea9d512017efafd461d6ac
--
2.51.0.858.gf9c4a03a3a-goog
next reply other threads:[~2025-10-16 23:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 23:55 Sean Christopherson [this message]
2026-01-12 17:38 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251016235538.171962-1-seanjc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®