Received: from mail-oa1-f73.google.com (mail-oa1-f73.google.com [209.85.160.73]) (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 5906F3793CA for ; Thu, 4 Jun 2026 16:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780592170; cv=none; b=OGGlUbvuXWCBdSOgH9ptMM0by2cFLiaMyZBYvT3dPUMKi+I8nYIzXi8IKkbC0ZBOUSj0zid8MojrOO9iMs32IPign344zPrbHS9hRRKxyMHIYbQ/vxYTYuYJv8CyZ3o6+MY+MXbsKkAuHnyNfDzsFTLomQQFZdK1AExwM0aSbFc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780592170; c=relaxed/simple; bh=uLD0C3Ak/FkADJwnlhPdlkmF7On5Kbp3laOnQjRKAco=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Mk26uNoyT5jUQq+M/GREc54TssN3FS1xjVGL8K8tdwf1lfGi0tls/SB0GhZAUA9szbw00rqHUU6LAcw9DW5jCkXOlMniRABXu7K6YBfGcN24JZFYJzUhJorfRUsmNEkmhuOxZo4vHYlKpeog82qiM5+NZeqP8WQMazbzaADOkYk= 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=oK9J28dV; arc=none smtp.client-ip=209.85.160.73 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="oK9J28dV" Received: by mail-oa1-f73.google.com with SMTP id 586e51a60fabf-43e09813423so926954fac.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=lists.linux.dev; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=EOYj+0hEeFNd+v3FnBBqysDLnZXV6YfCEQBmvWIZj8w=; b=oK9J28dVoUpXzKlGhZT/Cd+0zsNDkk5RncIES7AYrJrcf2PFjhjqrHLzhZkOJVe4cf NxCzaAp4Ta7LCCSyYF8G4WsF9gfZ6RQT6hRw1r6OAAnLj8yaJg1R+Qsg0AzA1/p2hW1p gFagC+nKw+x8hSi5c+TmO6a1qKyPWmk9pLmuVVGPPeX3F3vKtNXhCvwIXzW5OGu+VDq2 EI5qtVtK7/taKqbAGxQz/SYkVQoEETiVYVHRMdFkWpajQhVI9KF3PHBeUyWO6erA+jnk kw9Rn98CwGR/xe13wO3Bx0qfEDLniMme3EMyjuyAcZnp4C5B+CJFl9s4cfwzNkLGj/dc 5dmw== 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=sOFCeV/0rFNxSJ4n4GnU3hWv3d2nIOWOWhn1xA+vOIo7zE4ifv92rjcTuV1RtVwhAW Uf6gF9ocz/LoM7lXyJje5ReWOglwir7Hk3EajWDo6UFer98kY5HB1QPsMfeRBu5yM2s7 lqJhvX6zFwYvPLO/FDTeubjJ4NnI5gcbXDuqhqnrzdSy14JqzEem1ogW55JW7BrTZkFS K8kRk4RDO3U2xLgnFYwn+NLaNEMDxtTCZ5MFJMXg9nr/oKpvhm6bKmASPxzdem6Blo1J m43D8RfUiyDruV89PIga4e9R44BYaH0Fq/iXYe1/WU1O8AwjCV4IHX0WPKgCxARN0f3l ZC0Q== X-Forwarded-Encrypted: i=1; AFNElJ+yappKZIiE+LfuQKOctBkvCO43htD2LVTjjsah11t4MJGsgCjt9/IZAJF5OZ2WC+hliHRr@lists.linux.dev X-Gm-Message-State: AOJu0Yyub7l3+taVpv5oMuILrOUGbKTsYUFDh6GoeUau29z2XBnTUjqh rPhH45UiyVgGhVQoGPrVFsmbfV8g3zNCmnnkBOO/XmqKziMZAWf6ydI/8wun5NZP7Zzc/0gslMl nUvNj+Q== 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: criu@lists.linux.dev 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