Re: [PATCH RESEND v2] x86/fpu: Use vmemdup_user() in xstateregs_set()

From: Thorsten Blum

Date: Tue Oct 06 2026 - 11:03:00 EST


On Thu, Sep 17, 2026 at 02:14:41PM +0200, Thorsten Blum wrote:
> Replace the open-coded vmalloc() and copy_from_user() with
> vmemdup_user() to simplify xstateregs_set().
>
> vmemdup_user() returns an ERR_PTR() on failure, preserving the existing
> -ENOMEM and -EFAULT error codes. Since vmemdup_user() is backed by
> kvmalloc(), use kvfree() to free the buffer instead.
>
> Return early on error and drop the obsolete out label.
>
> Performance should be similar, and xstateregs_set() is not a hot path.
> Page alignment should not matter because the buffer is only used as a
> memcpy() source in copy_uabi_from_kernel_to_xstate().
>
> The allocation behavior differs because vmemdup_user() uses GFP_USER,
> which adds __GFP_HARDWALL and may affect cpuset allocations.
>
> tools/testing/selftests/x86/avx_64 passed on an Alder Lake CPU.
>
> Signed-off-by: Thorsten Blum <blum@xxxxxxxxxx>
> ---
> Changes in v2:
> - Add performance analysis and selftest result to the changelog (Ingo)
> - v1: https://lore.kernel.org/r/20260720195534.70111-3-thorsten.blum@xxxxxxxxx/
> ---
> arch/x86/kernel/fpu/regset.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)

Hi Ingo,

A gentle follow-up on this resend. The v2 changelog now includes the
analysis you asked for in the earlier thread, plus a successful x86
selftest result. Is anything else needed for this to be queued?

Thanks,
Thorsten