Thread (8 messages) flat view 8 messages, 7 authors, 2026-03-24

Re: [PATCH] KVM: Remove subtle "struct kvm_stats_desc" pseudo-overlay

From: Christian Borntraeger <borntraeger@linux.ibm.com>
Date: 2025-12-08 10:33:01
Also in: kvm, kvm-riscv, kvmarm, linux-arm-kernel, linux-mips, linux-riscv, lkml, loongarch

Am 06.12.25 um 00:26 schrieb Sean Christopherson:
Remove KVM's internal pseudo-overlay of kvm_stats_desc, which subtly
aliases the flexible name[] in the uAPI definition with a fixed-size array
of the same name.  The unusual embedded structure results in compiler
warnings due to -Wflex-array-member-not-at-end, and also necessitates an
extra level of dereferencing in KVM.  To avoid the "overlay", define the
uAPI structure to have a fixed-size name when building for the kernel.

Opportunistically clean up the indentation for the stats macros, and
replace spaces with tabs.

No functional change intended.

Reported-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Closes: https://lore.kernel.org/all/aPfNKRpLfhmhYqfP@kspp (local)
Signed-off-by: Sean Christopherson <seanjc@google.com>
Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
[..]
quoted hunk ↗ jump to hunk
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -14,6 +14,10 @@
  #include <linux/ioctl.h>
  #include <asm/kvm.h>
  
+#ifdef __KERNEL__
+#include <linux/kvm_types.h>
+#endif
+
  #define KVM_API_VERSION 12
  
  /*
@@ -1579,7 +1583,11 @@ struct kvm_stats_desc {
  	__u16 size;
  	__u32 offset;
  	__u32 bucket_size;
+#ifdef __KERNEL__
+	char name[KVM_STATS_NAME_SIZE];
+#else
  	char name[];
+#endif
  };
Not sure if we need a comment here or not. Maybe git blame is good enough.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help