From nobody Sun Sep 14 14:53:52 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D1C7C38159 for ; Sat, 21 Jan 2023 00:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbjAUAbk (ORCPT ); Fri, 20 Jan 2023 19:31:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbjAUAbh (ORCPT ); Fri, 20 Jan 2023 19:31:37 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6FC21420F; Fri, 20 Jan 2023 16:31:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674261079; x=1705797079; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=YMQAWurETlSCjBbvjxddlKNJW8TpNQNrIE4e8GG/gJs=; b=DANXdSbgFMJ+MkCkaczkA3VB+vXSHQuaFTXk3mpJNH3Y7LSro3/o4XRY ejgoYrQLvzE6OV9MnGZA/uZWIGVruVc+X7DBNCdVOH1DmQbE+atwdMH1z 7rpVxs+H+Yv5CsQ/I0sWwRBILH8DY3/0BsCLNUFaBcGXHZWb6MPKtv42Y i5/WZN1SGyhkSk7XkqQDvs08ZV7sFgk3QLNuuhrihlH5fSMrx2wun4WBK YOyt4s0Ufx7rIFM6sa6xpfaECZ/c6dRvncLi7i+Vx+4LmdsJrY3xAH+lw niYx1VTdZFcNBvqnTLRUivplaVztDgg3AHZQaupDTbySOWEN+kj32pqho A==; X-IronPort-AV: E=McAfee;i="6500,9779,10596"; a="305404609" X-IronPort-AV: E=Sophos;i="5.97,233,1669104000"; d="scan'208";a="305404609" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2023 16:30:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10596"; a="784729483" X-IronPort-AV: E=Sophos;i="5.97,233,1669104000"; d="scan'208";a="784729483" Received: from chang-linux-3.sc.intel.com ([172.25.66.173]) by orsmga004.jf.intel.com with ESMTP; 20 Jan 2023 16:30:16 -0800 From: "Chang S. Bae" To: dave.hansen@linux.intel.com, x86@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de Cc: hpa@zytor.com, corbet@lwn.net, bagasdotme@gmail.com, tony.luck@intel.com, yang.zhong@intel.com, linux-doc@vger.kernel.org, linux-man@vger.kernel.org, linux-kernel@vger.kernel.org, chang.seok.bae@intel.com Subject: [PATCH v5 RESEND 1/4] Documentation/x86: Explain the purpose for dynamic features Date: Fri, 20 Jan 2023 16:18:57 -0800 Message-Id: <20230121001900.14900-2-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230121001900.14900-1-chang.seok.bae@intel.com> References: <20220922195810.23248-1-chang.seok.bae@intel.com> <20230121001900.14900-1-chang.seok.bae@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This summary will help to guide the proper use of the enabling model. Signed-off-by: Chang S. Bae Reviewed-by: Tony Luck Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org --- Changes from v4: * Re-write about the sigaltstack sizing (Dave Hansen). * Drop the second point as the case is not clear yet. Changes from v3: * Add as a new patch (Tony Luck). --- Documentation/x86/xstate.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/x86/xstate.rst b/Documentation/x86/xstate.rst index 5cec7fb558d6..e954e79af4ce 100644 --- a/Documentation/x86/xstate.rst +++ b/Documentation/x86/xstate.rst @@ -11,6 +11,22 @@ are enabled by XCR0 as well, but the first use of relate= d instruction is trapped by the kernel because by default the required large XSTATE buffers are not allocated automatically. =20 +The purpose for dynamic features +-------------------------------- + +Legacy userspace libraries often have hard-coded, static sizes for +alternate signal stacks, often using MINSIGSTKSZ which is typically 2KB. +That stack must be able to store at *least* the signal frame that the +kernel sets up before jumping into the signal handler. That signal frame +must include an XSAVE buffer defined by the CPU. + +However, that means that the size of signal stacks is dynamic, not static, +because different CPUs have differently-sized XSAVE buffers. A compiled-in +size of 2KB with existing applications is too small for new CPU features +like AMX. Instead of universally requiring larger stack, with the dynamic +enabling, the kernel can enforce userspace applications to have +properly-sized altstacks. + Using dynamically enabled XSTATE features in user space applications -------------------------------------------------------------------- =20 --=20 2.17.1