Re: [v2][PATCH 1/2] x86/virt/tdx: Remove __user annotation from kernel pointer

From: Sean Christopherson
Date: Tue Nov 04 2025 - 11:35:30 EST


On Tue, Nov 04, 2025, Xiaoyao Li wrote:
> On 11/4/2025 7:44 AM, Dave Hansen wrote:
> >
> > From: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> >
> > Separate __user pointer variable declaration from kernel one.
> >
> > There are two 'kvm_cpuid2' pointers involved here. There's an "input"
> > side: 'td_cpuid' which is a normal kernel pointer and an 'output'
> > side. The output here is userspace and there is an attempt at properly
> > annotating the variable with __user:
> >
> > struct kvm_cpuid2 __user *output, *td_cpuid;
> >
> > But, alas, this is wrong. The __user in the definition applies to both
> > 'output' and 'td_cpuid'. Sparse notices the address space mismatch and
> > will complain about it.
> >
> > Fix it up by completely separating the two definitions so that it is
> > obviously correct without even having to know what the C syntax rules
> > even are.
> >
> > Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> > Fixes: 488808e682e7 ("KVM: x86: Introduce KVM_TDX_GET_CPUID")
> > Reviewed-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
>
> the prefix of the shortlog is still "x86/virt/tdx". I think Sean will change
> it to "KVM: TDX:", if it gets routed through KVM tree.

Ya, I'll fixup when applying.