[PATCH v7 118/120] KVM: x86: Remove BUILD_BUG_ON() x86_capability[] check

"Ahmed S. Darwish" <[email protected]> Thu, 28 May 2026 17:39:20 +0200
Newsgroups dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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 <[email protected]>
---
 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 018cd3078306..5ed45353802b 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.54.0