[PATCH RFC 10/10] KVM: x86: Enable CONTEXT_ANALYSIS with opt-outs

From: Marco Elver

Date: Thu Sep 10 2026 - 12:44:29 EST


Enable Clang context analysis (-Wthread-safety) for x86 KVM.

Because virt/kvm/ objects are built directly into the x86 KVM module,
this also enables checking for common KVM sources.

Temporarily opt out sources that require more invasive annotations:
mmu/mmu.c, mmu/tdp_mmu.c, i8259.c, and xen.c.

No functional change intended.

Signed-off-by: Marco Elver <elver@xxxxxxxxxx>
---
arch/x86/kvm/Makefile | 8 ++++++++
scripts/context-analysis-suppression.txt | 1 +
2 files changed, 9 insertions(+)

diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 0474604ab8a1..a93b54b00ae2 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -1,5 +1,13 @@
# SPDX-License-Identifier: GPL-2.0

+CONTEXT_ANALYSIS := y
+
+# Opt out x86 objects pending context annotations:
+CONTEXT_ANALYSIS_mmu/mmu.o := n
+CONTEXT_ANALYSIS_mmu/tdp_mmu.o := n
+CONTEXT_ANALYSIS_i8259.o := n
+CONTEXT_ANALYSIS_xen.o := n
+
ccflags-y += -I $(srctree)/arch/x86/kvm
ccflags-$(CONFIG_KVM_WERROR) += -Werror

diff --git a/scripts/context-analysis-suppression.txt b/scripts/context-analysis-suppression.txt
index 1c51b6153f08..666c4ca54708 100644
--- a/scripts/context-analysis-suppression.txt
+++ b/scripts/context-analysis-suppression.txt
@@ -17,6 +17,7 @@ src:*include/net/*
src:*include/linux/bit_spinlock.h=emit
src:*include/linux/cleanup.h=emit
src:*include/linux/kref.h=emit
+src:*include/linux/kvm_host.h=emit
src:*include/linux/list*.h=emit
src:*include/linux/local_lock*.h=emit
src:*include/linux/lockdep.h=emit
--
2.55.0.1003.g10538fe699-goog