Re: [PATCH 6/7] x86/fpu: Pre-fault only required size of xstate buffer

From: Borislav Petkov

Date: Fri Sep 25 2026 - 20:15:23 EST


On Fri, Sep 25, 2026 at 12:16:08PM -0700, Borislav Petkov wrote:
> On Fri, Sep 25, 2026 at 09:51:03AM -0700, Andrei Vagin wrote:
> > 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, makes sense.
>
> Lemme queue them and see what conflicts I get.

Ok, this is for my tip folks: merging this into tip/master gives a wrong merge
resolution, see below.

The proper merge should be to drop one of the prototypes.

HTH.

commit c59a5d54d06d4a025f925b0b3b4c63f2b81d75e7 (HEAD -> refs/heads/test-merge)
Merge: a14fcf2723cc 391cac638edd
Author: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Date: Fri Sep 25 17:11:39 2026 -0700

Merge branch 'tip-x86-fpu' into test-merge

* tip-x86-fpu:
selftests/x86: Add tests for signal frame FPU portability
x86/fpu: Pre-fault only required size of xstate buffer
x86/fpu: Fix potential underflow in xstate_calculate_size()
x86/fpu: Document reasoning of FX-only fallback
x86/fpu: Extract restore_from_ia32_fxstate() and clean up fpu__restore_sig()
x86/fpu: Clean up and rename variables in signal frame handling
x86/fpu: Document signal frame layout and portability
xor: Add AVX-512 optimized xor_gen()
xor: Remove redundant X86_FEATURE_OSXSAVE check
lib/crc: x86: Stop using cpu_has_xfeatures()
lib/crypto: x86: Stop using cpu_has_xfeatures()
crypto: x86 - Stop using cpu_has_xfeatures()
um: Check for missing AVX and AVX-512 xstate bits
x86/fpu: Check for missing AVX and AVX-512 xstate bits

diff --cc arch/x86/include/asm/fpu/xstate.h
index 19dec5f0b1c7,33343e5d54b0..25308312cd78
--- a/arch/x86/include/asm/fpu/xstate.h
+++ b/arch/x86/include/asm/fpu/xstate.h
@@@ -110,10 -110,9 +110,12 @@@ int xfeature_size(int xfeature_nr)

void xsaves(struct xregs_state *xsave, u64 mask);
void xrstors(struct xregs_state *xsave, u64 mask);
+void xsaves_nmi(struct xregs_state *xsave, u64 mask);
+
+unsigned int xstate_calculate_size(u64 xfeatures, bool compacted);

+ unsigned int xstate_calculate_size(u64 xfeatures, bool compacted);
+
int xfd_enable_feature(u64 xfd_err);

#ifdef CONFIG_X86_64


>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette