From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: Andrei Vagin <avagin@google.com>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>, <linux-kernel@vger.kernel.org>,
<criu@lists.linux.dev>, Dave Hansen <dave.hansen@linux.intel.com>,
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 09/10] x86/fpu: Allow restoring signal frames with larger xstate_size
Date: Mon, 6 Jul 2026 10:08:51 -0700 [thread overview]
Message-ID: <358834b6-86da-4f7f-b2b8-cda31663682d@intel.com> (raw)
In-Reply-To: <CAEWA0a47n5VUKsMTOOuXMwOZgPDMAt+1kBzbHLELAaK7oc8OkQ@mail.gmail.com>
On 6/30/2026 5:48 PM, Andrei Vagin wrote:
>
> In our previous discussion, I explained why the state translation
> approach doesn't solve the problem: in-flight signal frames on user
> stacks cannot be translated. When a process is checkpointed while
> handling a signal, there is an in-flight signal frame residing directly
> on the thread's user stack. There is no way for userspace tools to
> reliably discover arbitrary in-flight signal frames embedded in stack
> memory.
>
> We want to support cases where processes using only cluster-wide
> available features can be migrated from newer to older CPUs. If we
> migrate from a newer CPU (larger default `user_size`) to an older CPU
> (smaller `user_size`), enforcing `xstate_size <= fpstate->user_size` in
> the kernel unconditionally rejects valid signal frames.
>
> An fpu translation mechanism already exists in CRIU to restore current
> per-thread FPU states, making it possible to migrate workloads between
> different CPUs even today. But there is always a risk that a process is
> migrated at the wrong moment (while running inside a signal handler).
> Without this change, failing the size check on that in-flight stack
> frame can trigger a state corruption. This patch eliminates that risk.
So if I understand correctly, the intended usage model is a cluster of
machines exposing a compatible set of xfeatures. Migration may occur in
either direction (old -> new or new -> old), and the process image,
including any inflight signal frames, is copied verbatim because
interpreting or translating arbitrary signal frame is either impossible
or at least not reliable.
>> With APX, userspace can no longer assume that a higher XSTATE component
>> number implies a higher offset within the XSAVE image. Going forward,
>> migration software will likely need a more robust approach that
>> interprets the layout and transforms the image when moving between
>> machines with different layouts. With such translation, maybe further
>> relaxing the kernel-side checker isn't that needed.
>
> I think APX was designed to preserve backward compatibility cleanly. And
> I don't think that we rely on the assumption that a higher XSTATE component
> number implies a higher offset within the XSAVE image.
> `xstate_calculate_size()` already finds the topmost feature by offset. The
> only reason the kernel needs to know the required xstate size is to
> correctly pre-fault the user memory buffer.
>
> While APX reuses the MPX space in the xsave state, it introduces a new
> feature bit to indicate the presence of its state, which is really what
> matters. The actual register state that gets restored depends on
> `task_xfeatures` and the header's `xstate_bv`. Any attempt by XRSTOR to
> restore a header containing unsupported feature bits in xstate_bv
> generates a GP fault. This cleanly traps in restore_fpregs_from_user()
> and fails out, triggering a SIGSEGV.
IIUC, this works because the migration pool is already constrained to
architecturally compatible machines. In particular, APX systems would
not be mixed with older MPX systems. Otherwise, while with a
distinguishing feature bit though, the layout is still ambiguous without
interpreting signal frames.
>
> I completely understand that some features may be deprecated in the
> future, but I still believe that for non-deprecated features, component
> offsets should be fixed across all CPUs within a vendor's family. If
> this assumption is ever broken, even standard KVM live migration of
> guest vCPUs would break.
>
> Sorry if I missed something. Maybe you can give an example of when
> this change would work against us?
With dynamic XSTATE, suppose a take has opted into a dynamic state and
therefore carries a larger xstate_size, but it is migrated to another
machine where the corresponding dynamic permission has not been
requested. Since, according to the usage model, reliable interpretation
of arbitrary signal frames is not possible, I assume the migration
framework does not inspect each individual state to determine whether
this is still in its init state or not.
If that's the case, is there a possibility that meaningful dynamic state
could be lost during migration?
More generally, if ever reconsidering the kernel's sanity checking, one
concern I still have with this change is validation in the presence of
unknown future feature bits. This series does not run into that problem
in practice though.
Thanks,
Chang
next prev parent reply other threads:[~2026-07-06 17:09 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 19:37 [PATCH v3 0/10] x86/fpu: Restore and reinforce signal frame portability Andrei Vagin
2026-06-15 19:37 ` [PATCH 01/10] x86/fpu: Document " Andrei Vagin
2026-06-26 13:51 ` Alexander Mikhalitsyn
2026-06-30 19:23 ` Chang S. Bae
2026-06-15 19:37 ` [PATCH 02/10] x86/fpu: Clean up and rename variables in signal frame handling Andrei Vagin
2026-06-26 17:05 ` Alexander Mikhalitsyn
2026-06-15 19:37 ` [PATCH 03/10] x86/fpu: Split __fpu_restore_sig to extract compat path Andrei Vagin
2026-06-26 17:20 ` Alexander Mikhalitsyn
2026-06-15 19:37 ` [PATCH 04/10] x86/fpu: Document reasoning of FX-only fallback Andrei Vagin
2026-06-26 14:22 ` Alexander Mikhalitsyn
2026-06-30 19:23 ` Chang S. Bae
2026-06-15 19:37 ` [PATCH 05/10] x86/fpu: Fix potential underflow in xstate_calculate_size() Andrei Vagin
2026-06-26 14:32 ` Alexander Mikhalitsyn
2026-06-30 19:23 ` Chang S. Bae
2026-06-15 19:37 ` [PATCH 06/10] selftests/x86: Add a test for signal frame FPU portability Andrei Vagin
2026-06-26 14:39 ` Alexander Mikhalitsyn
2026-06-15 19:37 ` [PATCH 07/10] x86/fpu: Pre-fault only required size of xstate buffer Andrei Vagin
2026-06-26 17:28 ` Alexander Mikhalitsyn
2026-06-15 19:37 ` [PATCH 08/10] selftests/x86: Add a sigframe insufficient xstate_size test Andrei Vagin
2026-06-26 15:02 ` Alexander Mikhalitsyn
2026-06-15 19:37 ` [PATCH 09/10] x86/fpu: Allow restoring signal frames with larger xstate_size Andrei Vagin
2026-06-26 17:32 ` Alexander Mikhalitsyn
2026-06-30 19:23 ` Chang S. Bae
2026-07-01 0:48 ` Andrei Vagin
2026-07-06 17:08 ` Chang S. Bae [this message]
2026-07-07 20:27 ` Andrei Vagin
2026-07-09 21:14 ` Chang S. Bae
2026-07-10 22:24 ` Chang S. Bae
2026-06-15 19:37 ` [PATCH 10/10] selftests/x86: Check restoring FPU state " Andrei Vagin
2026-06-26 15:12 ` Alexander Mikhalitsyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=358834b6-86da-4f7f-b2b8-cda31663682d@intel.com \
--to=chang.seok.bae@intel.com \
--cc=avagin@google.com \
--cc=bp@alien8.de \
--cc=criu@lists.linux.dev \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox