[PATCH v6 88/90] KVM: x86: Remove BUILD_BUG_ON() x86_capability[] check

From: Ahmed S. Darwish

Date: Thu Mar 26 2026 - 22:41:46 EST


KVM's direct access to cpuinfo_x86::x86_capability[] has been replaced with
the cpuid_word_*() APIs. The former is getting removed from the kernel.

Adjust the kvm_cpu_caps[] alignment comment accordingly.

Remove BUILD_BUG_ON() related to x86_capability[] as it does not matte
anymore.

Signed-off-by: Ahmed S. Darwish <darwi@xxxxxxxxxxxxx>
---
arch/x86/kvm/cpuid.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 161fa2b23bdb..dac12dfdf47a 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -30,8 +30,8 @@
#include "xen.h"

/*
- * Unlike "struct cpuinfo_x86.x86_capability", kvm_cpu_caps doesn't need to be
- * aligned to sizeof(unsigned long) because it's not accessed via bitops.
+ * No unsigned long alignment is needed. The CPUID tables X86_FEATURE
+ * words are accessed by bitops, but this table is not.
*/
u32 kvm_cpu_caps[NR_KVM_CPU_CAPS] __read_mostly;
EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_cpu_caps);
@@ -838,9 +838,6 @@ void kvm_initialize_cpu_caps(void)
WARN_ON_ONCE(kvm_is_configuring_cpu_caps);
kvm_is_configuring_cpu_caps = true;

- BUILD_BUG_ON(sizeof(kvm_cpu_caps) - (NKVMCAPINTS * sizeof(*kvm_cpu_caps)) >
- sizeof(boot_cpu_data.x86_capability));
-
kvm_cpu_cap_init(CPUID_1_ECX,
F(XMM3),
F(PCLMULQDQ),
--
2.53.0