Re: [PATCH 6/7] x86/fpu: Pre-fault only required size of xstate buffer
From: Andrei Vagin
Date: Fri Sep 25 2026 - 12:58:44 EST
On Thu, Sep 24, 2026 at 9:02 PM Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Thu, Sep 24, 2026 at 09:01:20PM +0000, Andrei Vagin wrote:
> > diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h
> > index 38a2862f09d3..c73cf2444de6 100644
> > --- a/arch/x86/kernel/fpu/xstate.h
> > +++ b/arch/x86/kernel/fpu/xstate.h
> > @@ -55,6 +55,8 @@ extern int copy_sigframe_from_user_to_xstate(struct task_struct *tsk, const void
> > extern void fpu__init_cpu_xstate(void);
> > extern void fpu__init_system_xstate(unsigned int legacy_size);
> >
> > +extern unsigned int xstate_calculate_size(u64 xfeatures, bool compacted);
> > +
> > extern void __user *get_xsave_addr_user(struct xregs_state __user *xsave, int xfeature_nr);
> >
> > static inline u64 xfeatures_mask_supervisor(void)
> > --
>
> Hmm, so which tree are you basing your stuff ontop?
It is based on tip/master:
commit 2edcfb3bc04385e287ebc2408be2882842bf6111
Merge: 3a7bb97db232 c9fc85f1e44e
Author: Ingo Molnar
Date: Wed Sep 23 13:28:15 2026 +0200
Merge branch into tip/master: 'x86/tdx'
>
> Because in patch 5, xstate_calculate_size() is not static so you must be
> basing it ontop of some tip/master branch from sometime because tip/perf/core
> has
>
> b84c96283684 ("perf/x86: Enable XMM register sampling for non-PEBS events")
>
> which drops the static qualifier of that function.
>
> But then you're declaring a prototype above in the header while that same
> patch is declaring the same prototype too. So if you were applying ontop of
> some tip/master state which has tip/perf/core, then you wouldn't need the
> extern.
>
> Weird.
I started this series before b84c96283684 landed. I put the prototype in
arch/x86/kernel/fpu/xstate.h because I didn't need it outside of x86.
Then the rebase went through cleanly, so I ended up with the duplicate
prototypes without realizing it.
I've sent v8.1, which is based on tip/fpu. In this version, I moved the
xstate_calculate_size prototype to arch/x86/include/asm/fpu/xstate.h.
This matches b84c96283684 to avoid the same problem when tip/x86/fpu and
tip/perf/core will be merged.
Thanks,
Andrei