]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: x86: Use __DECLARE_FLEX_ARRAY() for UAPI structures with VLAs
authorDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 5 Mar 2026 19:49:55 +0000 (20:49 +0100)
committerSean Christopherson <seanjc@google.com>
Thu, 12 Mar 2026 17:56:10 +0000 (10:56 -0700)
commit2619da73bb2f10d88f7e1087125c40144fdf0987
tree0de0979fb7411831fc7b04da3a9d0288f30cde92
parentd2ea4ff1ce50787a98a3900b3fb1636f3620b7cf
KVM: x86: Use __DECLARE_FLEX_ARRAY() for UAPI structures with VLAs

Commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with
flexible-array members") broke the userspace API for C++.

These structures ending in VLAs are typically a *header*, which can be
followed by an arbitrary number of entries. Userspace typically creates
a larger structure with some non-zero number of entries, for example in
QEMU's kvm_arch_get_supported_msr_feature():

    struct {
        struct kvm_msrs info;
        struct kvm_msr_entry entries[1];
    } msr_data = {};

While that works in C, it fails in C++ with an error like:
 flexible array member 'kvm_msrs::entries' not at end of 'struct msr_data'

Fix this by using __DECLARE_FLEX_ARRAY() for the VLA, which uses [0]
for C++ compilation.

Fixes: 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members")
Cc: stable@vger.kernel.org
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Link: https://patch.msgid.link/3abaf6aefd6e5efeff3b860ac38421d9dec908db.camel@infradead.org
[sean: tag for stable@]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/uapi/asm/kvm.h
include/uapi/linux/kvm.h