Re: [PATCH RESEND] KVM: TDX: Use struct_size and simplify tdx_get_capabilities

From: Thorsten Blum

Date: Wed Nov 12 2025 - 16:22:18 EST


On 12. Nov 2025, at 20:59, Edgecombe, Rick P wrote:
> It looks like you are conducting a treewide pattern matching cleanup?

Just a few instances here and there, but not really treewide.

> In the handling of get_user(nr_user_entries, &user_caps->cpuid.nent), the old
> code forced -EFAULT, this patch doesn't. But it leaves the copy_to_user()'s to
> still force EFAULT. Why?

get_user() already returns -EFAULT and the error can just be forwarded,
whereas copy_to_user() returns the number of bytes that could not be
copied and we must return -EFAULT manually.

> Tested-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx> (really the TDX CI)

Thanks,
Thorsten