From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f201.google.com (mail-oi1-f201.google.com [209.85.167.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 618B649253E for ; Thu, 4 Jun 2026 16:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780592169; cv=none; b=or7DctIRYJSbTKdMFFjIO7nLJLDHaKL/HXG+MXSb8TWVy6kTCGPKCGSKqJU6Q7J8pTSj/A8N4fPY8cqHfnnDpf1Gtnw0lokrbGd4vm3ktOqYI2n6pADKnKtRNQlWwmcFVSTwXHotB6xk+1CaCfyPs83Wiv09dxvtybR48CTsZIE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780592169; c=relaxed/simple; bh=uLD0C3Ak/FkADJwnlhPdlkmF7On5Kbp3laOnQjRKAco=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=t5/3msyqnRVRJ9Cho1P9YZRLKh0fMNBYJfYZ/FfiCG3uOnsKpxD+b35S5XWonrNUlr6RsYczYbDn4yFUDKb55q+gHB8ODzcbhCcDbDr5e/JhNUB4A+JYHzpxjBqeO9HGxLhp2pwb3228X46I1u1S3jhALn9Fco9Q2B8dqVnciY0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--avagin.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vMTMo6TE; arc=none smtp.client-ip=209.85.167.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--avagin.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vMTMo6TE" Received: by mail-oi1-f201.google.com with SMTP id 5614622812f47-486055c1c6fso684066b6e.1 for ; Thu, 04 Jun 2026 09:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780592167; x=1781196967; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=EOYj+0hEeFNd+v3FnBBqysDLnZXV6YfCEQBmvWIZj8w=; b=vMTMo6TEXt0esPU+3DFYxCOSc97rPUuOl9et6oP1DNq/qoSngx6JOOT+XwN40M3ZRd uXTvs2HeAAqFwI+CnGuYuEK8T6INlHR+swlfzffNhzt0U3TEQv1pDbOUhhHfyRFkjaq6 z73CJKkZrTA42X4HNZqu+VSwyDd6Dex7HDgy8SPsMauYfrpN1CkwEapJZ4tIdsYUsxTM zcYg3D9bpwSFCoOxqxWB5lonyjhiF2vDKQihy5SAL+QwRJcTCyAmmqgkuZnpKrtDqtX0 LB02HPFy6T1wZYqtAQg/cSHurni9ci0BTmbMU6xtLFtar8JMVrlC3n+BxpHOqAYxgYmD T1JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780592167; x=1781196967; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EOYj+0hEeFNd+v3FnBBqysDLnZXV6YfCEQBmvWIZj8w=; b=nLm6J7qywDtC5wlZqz2lQlQR07d282LgDX+MXTlwrvYJCRqO9x3gGHY71uebUfuT9/ U1WRpUIQ1os6k4tRWZDP5/oKYZw3+4rN+xjuinI5LkVLeM/1EXJrrPCRholJbH6U9rB5 1zf5r7L1YejlTYcvEGhinPNxfukCE1Ip4l0+a9PLJw7WVTacGjeQJGup41XGbelcaYPz fUdzbFAeL2FE1TZY6mHCI2jXom/1F8mZmY++61uzVSkiVh+Qr8s2crEPAsLxq1Vxbg2+ s0+8JqBi6anjTNqH1AFWhEYZ2DhPKrO2N0e90Sbr+qJgSKOumLrWZPgKm5Dtdhhrp24d SQuA== X-Gm-Message-State: AOJu0Yzaz5/IyPjXlqlN5HUEMucld3lIDVEq6a7+z3cror7Mj09C8nz6 Bgt1F5t7U7FqWJsHjjv5SBwG8QzLwuqdOXDn5p5HrFjzsrUhDJDyI4fvMfpFP6TkT2udWDlkR6q nzkevFA== X-Received: from jagi21-n2.prod.google.com ([2002:a05:6639:55:20b0:5e2:9af9:ddd3]) (user=avagin job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:1808:b0:69d:8936:403e with SMTP id 006d021491bc7-69e47deea69mr4537120eaf.5.1780592166903; Thu, 04 Jun 2026 09:56:06 -0700 (PDT) Date: Thu, 4 Jun 2026 16:56:00 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.1032.g2f8565e1d1-goog Message-ID: <20260604165604.1195243-1-avagin@google.com> Subject: [PATCH v2 0/4] x86/fpu: Restore and reinforce signal frame portability From: Andrei Vagin To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "Chang S. Bae" Cc: linux-kernel@vger.kernel.org, criu@lists.linux.dev, Dave Hansen , x86@kernel.org, Andrei Vagin , "H. Peter Anvin" Content-Type: text/plain; charset="UTF-8" The x86 signal frame is designed to be self-describing. The xstate_size field in the software-reserved bytes indicates the actual size of the xstate context and is used by the kernel to locate the FP_XSTATE_MAGIC2 marker during signal return. This design is required to provide portability of signal frames across different machines. For example, a process checkpointed on a system with fewer xstate features and restored on a system with more features will have a signal frame on its stack that is smaller than the destination host's default. By relying on the frame's internal xstate_size, the kernel can correctly validate and restore such frames. This series addresses a regression introduced in commit dc8aa31a7ac2 ("x86/fpu: Refine and simplify the magic number check during signal return"). v2: Address sashiko comments. 44eeff9bc467 ("Revert "x86/fpu: Refine and simplify the magic number check during signal return"") has been merged. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: "Chang S. Bae" Andrei Vagin (5): Revert "x86/fpu: Refine and simplify the magic number check during signal return" x86/fpu: Document signal frame portability selftests/x86: Add a test for signal frame portability x86/fpu: Add consistency check between xstate_size and xfeatures selftests/x86: Add a consistency test for signal frames Documentation/arch/x86/xstate.rst | 14 +- arch/x86/include/uapi/asm/sigcontext.h | 10 + arch/x86/kernel/fpu/signal.c | 29 ++- arch/x86/kernel/fpu/xstate.c | 2 +- arch/x86/kernel/fpu/xstate.h | 2 + tools/testing/selftests/x86/Makefile | 5 +- .../selftests/x86/sigframe_portability.c | 205 ++++++++++++++++++ tools/testing/selftests/x86/xstate.c | 5 - tools/testing/selftests/x86/xstate.h | 12 + 9 files changed, 269 insertions(+), 15 deletions(-) create mode 100644 tools/testing/selftests/x86/sigframe_portability.c -- 2.54.0.746.g67dd491aae-goog