Re: [PATCH 7/7] selftests/x86: Add tests for signal frame FPU portability

From: Andrei Vagin

Date: Thu Sep 24 2026 - 17:13:28 EST


On Thu, Sep 24, 2026 at 11:54 AM Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Thu, Sep 24, 2026 at 04:16:03AM +0000, Andrei Vagin wrote:
> > Add a new selftest tools/testing/selftests/x86/sigframe_fpu_portability.c
> > to verify signal frame portability and consistency when the xstate size
> > is shrunk:
> >
> > - test_valid_shrunk_xstate_size: Verifies that the kernel correctly
> > restores the xstate context from a signal frame where xstate_size has
> > been manually shrunk to only cover active features, as long as the
> > FP_XSTATE_MAGIC2 marker is correctly placed. This simulates migrating
> > a process created on a host with fewer xstate features to a host with
> > more features.
> >
> > - test_invalid_shrunk_xstate_size: Verifies that the kernel rejects
> > (via SIGSEGV) a signal frame where xstate_size is smaller than required
> > by the enabled features in the xfeatures mask.
> >
> > Reviewed-by: Alexander Mikhalitsyn <alexander@xxxxxxxxxxxxx>
> > Reviewed-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>
> > Signed-off-by: Andrei Vagin <avagin@xxxxxxxxxx>
> > ---
> > tools/testing/selftests/x86/Makefile | 5 +-
> > .../selftests/x86/sigframe_fpu_portability.c | 246 ++++++++++++++++++
> > tools/testing/selftests/x86/xstate.c | 12 -
> > tools/testing/selftests/x86/xstate.h | 20 ++
> > 4 files changed, 270 insertions(+), 13 deletions(-)
> > create mode 100644 tools/testing/selftests/x86/sigframe_fpu_portability.c
>
> Sashiko has a comment which sounds valid to me but I haven't looked at the
> surrounding code:
>
> https://sashiko.dev/#/patchset/20260924041604.3209659-1-avagin%40google.com

Thank you for pointing this out. Sashiko didn't report anything on the
v6 version, and this test hasn't been changed since then. I combined
%ymm0 load/store and the kill syscall into a single inline assembly,
so I think it should address Sashiko's concerns. I've sent v8, let's see
what Sashiko reports on it.

Thanks,
Andrei