Re: [PATCH v4 18/30] KVM: x86: Move "struct kvm_x86_msr_filter" definition to msrs.c
From: Huang, Kai
Date: Tue Jun 16 2026 - 03:33:33 EST
On Tue, 2026-06-16 at 14:29 +0800, Binbin Wu wrote:
> On 6/13/2026 8:03 AM, Sean Christopherson wrote:
> > Move the definition of "struct kvm_x86_msr_filter" and its associate,
> > "struct msr_bitmap_range", to msrs.c, as the details of the filters are
> > very much implementation details that can and should be buried in msrs.c.
> > While the _existence_ of filters is public knowledge, almost by definition,
> > the contents don't need to be exposed outside of the MSR code as the filter
> > data is provided by userspace, i.e. it pretty much has to be dynamically
> > allocated, and thus never should be fully embedded in a globally visible
> > structure.
> >
> > Note, this creates a discrepancy with the PMU event filter structure; that
> > will be remedied shortly.
> >
> > No functional change intended.
> >
> > Suggested-by: Kai Huang <kai.huang@xxxxxxxxx>
> > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> > ---
> > arch/x86/include/asm/kvm_host.h | 15 ++-------------
> > arch/x86/kvm/msrs.c | 13 +++++++++++++
> > 2 files changed, 15 insertions(+), 13 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> > index 09e437c947a9..4ff6304c02d0 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -315,6 +315,8 @@ enum x86_intercept_stage;
> > struct kvm_kernel_irqfd;
> > struct kvm_kernel_irq_routing_entry;
> >
> > +struct kvm_x86_msr_filter;
>
>
> Just FYI, the code failed to build on my desktop with an old gcc version v9.4.
> Due to dereferencing pointer to incomplete type ‘struct kvm_x86_msr_filter' via
> typeof().
>
> It's not the fault of the patch, the issue was fixed for GCC 10+ according to
> the link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44257
This issue was reported at:
rusty 2010-05-24 00:29:46 UTC
But only got fixed at:
Drea Pinski 2021-09-20 02:14:38 UTC
Amazing :-)
>
> But the minimal tool version got for gcc is still v8.1.0, not sure if it needs
> to bump the version in scripts/min-tool-version.sh?
>
Bumping the version would have global impact, so I don't think we should do.
However, does moving the structure definition to "msrs.h" fix the problem?