[PATCH] KVM: Remove subtle "struct kvm_stats_desc" pseudo-overlay
Christian Borntraeger
borntraeger at linux.ibm.com
Mon Dec 8 02:32:27 PST 2025
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 at kernel.org>
> Closes: https://lore.kernel.org/all/aPfNKRpLfhmhYqfP@kspp
> Signed-off-by: Sean Christopherson <seanjc at google.com>
Acked-by: Christian Borntraeger <borntraeger at linux.ibm.com>
[..]
> --- 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.
More information about the linux-arm-kernel
mailing list