From: Marco Elver <elver@google.com>
To: elver@google.com
Cc: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Kiryl Shutsemau <kas@kernel.org>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
David Hildenbrand <david@kernel.org>,
kvm@vger.kernel.org, linux-coco@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH RFC 00/10] KVM: Enable Clang Context Analysis
Date: Thu, 10 Sep 2026 16:21:33 +0000 [thread overview]
Message-ID: <20260910162343.4092060-1-elver@google.com> (raw)
Enable compiler-based static context analysis [1] for x86 KVM, along with
prerequisite lock annotations in virt/kvm.
During the initial annotation pass, context analysis uncovered a missing
SRCU read-side critical section in x86 PMU filter lookups; patch 1 fixes
this bug.
The remainder of the series is strictly non-functional: it establishes
basic function annotations, guarded_by annotations on core structs, and
straightforward refactorings in hva/gfn range walks and guest_memfd to
eliminate conditional locking patterns that cannot be tracked statically.
Annotating the MMU (mmu/mmu.c, mmu/tdp_mmu.c), i8259, and Xen requires
more invasive changes and is deferred to follow-ups.
[1] https://docs.kernel.org/next/dev-tools/context-analysis.html
Marco Elver (10):
KVM: x86/pmu: Acquire SRCU in pmc_is_event_allowed() to protect filter
lookup
KVM: Allow reading memslots while holding slots_arch_lock
KVM: guest_memfd: Avoid conditional mmu_lock acquisition
KVM: Refactor kvm_handle_hva_range() to avoid conditional mmu_lock
KVM: Refactor kvm_handle_gfn_range() to avoid conditional mmu_lock
KVM: Add basic lock context annotations
KVM: x86: Add basic lock context annotations
KVM: Add guarded_by to members in struct kvm
KVM: x86: Add guarded_by annotations for kvm_arch, kvm_hv, and ioapic
KVM: x86: Enable CONTEXT_ANALYSIS with opt-outs
arch/x86/include/asm/kvm_host.h | 32 ++--
arch/x86/kvm/Makefile | 8 +
arch/x86/kvm/debugfs.c | 1 +
arch/x86/kvm/hyperv.c | 21 +++
arch/x86/kvm/hyperv.h | 16 +-
arch/x86/kvm/ioapic.c | 28 ++-
arch/x86/kvm/ioapic.h | 16 +-
arch/x86/kvm/irq.c | 2 +
arch/x86/kvm/lapic.c | 8 +-
arch/x86/kvm/lapic.h | 15 +-
arch/x86/kvm/mmu/page_track.c | 1 +
arch/x86/kvm/mmu/page_track.h | 3 +-
arch/x86/kvm/mmu/spte.h | 3 +-
arch/x86/kvm/msrs.c | 5 +
arch/x86/kvm/msrs.h | 3 +-
arch/x86/kvm/pmu.c | 9 +-
arch/x86/kvm/regs.h | 15 +-
arch/x86/kvm/smm.c | 6 +
arch/x86/kvm/smm.h | 2 +-
arch/x86/kvm/svm/hyperv.c | 2 +
arch/x86/kvm/svm/hyperv.h | 6 +-
arch/x86/kvm/svm/nested.c | 30 +++-
arch/x86/kvm/svm/sev.c | 18 ++
arch/x86/kvm/svm/svm.c | 32 ++++
arch/x86/kvm/svm/svm.h | 28 ++-
arch/x86/kvm/vmx/hyperv.h | 6 +-
arch/x86/kvm/vmx/main.c | 5 +
arch/x86/kvm/vmx/nested.c | 54 +++++-
arch/x86/kvm/vmx/nested.h | 19 +-
arch/x86/kvm/vmx/sgx.c | 3 +
arch/x86/kvm/vmx/sgx.h | 3 +-
arch/x86/kvm/vmx/tdx.c | 9 +
arch/x86/kvm/vmx/vmx.c | 11 ++
arch/x86/kvm/vmx/x86_ops.h | 24 ++-
arch/x86/kvm/x86.c | 66 ++++++-
arch/x86/kvm/x86.h | 37 ++--
include/linux/kvm_host.h | 215 ++++++++++++++++-------
scripts/context-analysis-suppression.txt | 1 +
virt/kvm/dirty_ring.c | 2 +
virt/kvm/eventfd.c | 9 +-
virt/kvm/guest_memfd.c | 21 ++-
virt/kvm/kvm_main.c | 183 +++++++++++++------
virt/kvm/pfncache.c | 3 +
43 files changed, 745 insertions(+), 236 deletions(-)
--
2.55.0.1003.g10538fe699-goog
next reply other threads:[~2026-09-10 16:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 16:21 Marco Elver [this message]
2026-09-10 16:21 ` [PATCH RFC 01/10] KVM: x86/pmu: Acquire SRCU in pmc_is_event_allowed() to protect filter lookup Marco Elver
2026-09-10 16:46 ` Sean Christopherson
2026-09-10 16:21 ` [PATCH RFC 02/10] KVM: Allow reading memslots while holding slots_arch_lock Marco Elver
2026-09-10 16:30 ` Sean Christopherson
2026-09-10 17:11 ` Marco Elver
2026-09-10 17:52 ` Sean Christopherson
2026-09-10 19:05 ` Marco Elver
2026-09-10 16:21 ` [PATCH RFC 03/10] KVM: guest_memfd: Avoid conditional mmu_lock acquisition Marco Elver
2026-09-10 16:21 ` [PATCH RFC 04/10] KVM: Refactor kvm_handle_hva_range() to avoid conditional mmu_lock Marco Elver
2026-09-10 16:38 ` Sean Christopherson
2026-09-10 16:21 ` [PATCH RFC 05/10] KVM: Refactor kvm_handle_gfn_range() " Marco Elver
2026-09-10 16:21 ` [PATCH RFC 06/10] KVM: Add basic lock context annotations Marco Elver
2026-09-10 16:21 ` [PATCH RFC 07/10] KVM: x86: " Marco Elver
2026-09-10 16:21 ` [PATCH RFC 08/10] KVM: Add guarded_by to members in struct kvm Marco Elver
2026-09-10 16:21 ` [PATCH RFC 09/10] KVM: x86: Add guarded_by annotations for kvm_arch, kvm_hv, and ioapic Marco Elver
2026-09-10 16:21 ` [PATCH RFC 10/10] KVM: x86: Enable CONTEXT_ANALYSIS with opt-outs Marco Elver
2026-09-10 16:55 ` [PATCH RFC 00/10] KVM: Enable Clang Context Analysis Sean Christopherson
2026-09-10 19:19 ` Marco Elver
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=20260910162343.4092060-1-elver@google.com \
--to=elver@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=hpa@zytor.com \
--cc=kas@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tglx@kernel.org \
--cc=vkuznets@redhat.com \
--cc=x86@kernel.org \
/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®