From nobody Sun Feb 8 02:56:01 2026 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 4163CEB64D8 for ; Wed, 21 Jun 2023 12:22:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230506AbjFUMWg (ORCPT ); Wed, 21 Jun 2023 08:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbjFUMW3 (ORCPT ); Wed, 21 Jun 2023 08:22:29 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E98C51718 for ; Wed, 21 Jun 2023 05:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687350148; x=1718886148; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PmT32/vt4ethKYYTdguD5n3hD6F8WduFRTRcW71c8DQ=; b=Os1x4E6oZMqeSd1H3Zx35T/L0AM7LhdL6b2t8VWGqPRx4DDe9apfQzi2 D/GHVQ6z2gmNSdQELd2x6kWLrd08FYiIKXRS+/5KO5UtvDLG/9b0SMS/x tifTgOCXj6MnB7SYBge46+ny2sM37HciLIP59sLTu4tA5rexK1ErOYYgh fZbf0+y1DJPy6c00BaDTKaxpgfJSRg5WPpZzPDQYnmBFFvDg8LA5XQs+F U4OhqK99hmtE5AMdGF5j1WnMUt6AmgYbbzFGgK4PjLWj10ACvizacKtZM OimMfTxhjVtIMVPQq+tJl1CE0/RFTQ+bFuaS7DUm/kGXzKHN6SqRuK5C8 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="360165682" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="360165682" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2023 05:22:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="888638343" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="888638343" Received: from chang-linux-3.sc.intel.com ([172.25.66.173]) by orsmga005.jf.intel.com with ESMTP; 21 Jun 2023 05:22:27 -0700 From: "Chang S. Bae" To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, andrew.cooper3@citrix.com, chang.seok.bae@intel.com Subject: [PATCH v1 1/4] x86/fpu/xstate: Convert get_xsave_addr() to a static function Date: Wed, 21 Jun 2023 05:09:39 -0700 Message-Id: <20230621120942.121822-2-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621120942.121822-1-chang.seok.bae@intel.com> References: <20230621120942.121822-1-chang.seok.bae@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The function is defined as global but is not invoked anywhere else. Switch it a local (static) function. Signed-off-by: Chang S. Bae Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/kernel/fpu/xstate.c | 2 +- arch/x86/kernel/fpu/xstate.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 0bab497c9436..2f03acc47f62 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -956,7 +956,7 @@ static void *__raw_xsave_addr(struct xregs_state *xsave= , int xfeature_nr) * address of the state in the xsave area, or NULL if the * field is not present in the xsave buffer. */ -void *get_xsave_addr(struct xregs_state *xsave, int xfeature_nr) +static void *get_xsave_addr(struct xregs_state *xsave, int xfeature_nr) { /* * Do we even *have* xsave state? diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h index a4ecb04d8d64..82f2d3c41298 100644 --- a/arch/x86/kernel/fpu/xstate.h +++ b/arch/x86/kernel/fpu/xstate.h @@ -53,8 +53,6 @@ extern int copy_sigframe_from_user_to_xstate(struct task_= struct *tsk, const void extern void fpu__init_cpu_xstate(void); extern void fpu__init_system_xstate(unsigned int legacy_size); =20 -extern void *get_xsave_addr(struct xregs_state *xsave, int xfeature_nr); - static inline u64 xfeatures_mask_supervisor(void) { return fpu_kernel_cfg.max_features & XFEATURE_MASK_SUPERVISOR_SUPPORTED; --=20 2.34.1 From nobody Sun Feb 8 02:56:01 2026 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 C4FDEEB64D7 for ; Wed, 21 Jun 2023 12:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231279AbjFUMWi (ORCPT ); Wed, 21 Jun 2023 08:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbjFUMW3 (ORCPT ); Wed, 21 Jun 2023 08:22:29 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43CB69B for ; Wed, 21 Jun 2023 05:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687350149; x=1718886149; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t4zNUfsUfdiWgC9xVUBFnZiyusneatQsxuKrxZmd51w=; b=B/U+F9Rqf5RQ7GgP9Q95TZ3IOdMDAufARnQyDeYx6mSCahY7P1N1DsIL KE8OEnLUGiwrzj/m/bTMcKotnnrdMWlKcz24L0lGEIVzJH66rzy+5wlkn 1AD+cXklFdGOPuq35cqthghPzE0OYusDue4tFXBFytORRquBSTA7M8QKD bv+PD5H4sI96c8Wfx0wqutlR8xunf4l/9pJjyvMccRQmZ9hcwFoG6Y46U AcSpke0xcM5WBzYLS0I5xMlcBhhOjQn6R9eJpSS6VygYkoDvyxI4u1bBi lEhOQbpm3YTV0Vej5P2m1Tgpw0pnFKUB5MmFww6D8+FYgKevrDsaBKCmu A==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="360165691" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="360165691" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2023 05:22:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="888638350" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="888638350" Received: from chang-linux-3.sc.intel.com ([172.25.66.173]) by orsmga005.jf.intel.com with ESMTP; 21 Jun 2023 05:22:27 -0700 From: "Chang S. Bae" To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, andrew.cooper3@citrix.com, chang.seok.bae@intel.com Subject: [PATCH v1 2/4] x86/fpu/xstate: Simplify xstate_calculate_size() Date: Wed, 21 Jun 2023 05:09:40 -0700 Message-Id: <20230621120942.121822-3-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621120942.121822-1-chang.seok.bae@intel.com> References: <20230621120942.121822-1-chang.seok.bae@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This size calculation code uses xfeatures_get_offset() only for the compacted format. But, it is capable of handling both formats. Use it for simpler and more concise code. Signed-off-by: Chang S. Bae Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/kernel/fpu/xstate.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 2f03acc47f62..d488621b280e 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -563,14 +563,11 @@ static bool __init check_xstate_against_struct(int nr) static unsigned int xstate_calculate_size(u64 xfeatures, bool compacted) { unsigned int topmost =3D fls64(xfeatures) - 1; - unsigned int offset =3D xstate_offsets[topmost]; =20 if (topmost <=3D XFEATURE_SSE) return sizeof(struct xregs_state); =20 - if (compacted) - offset =3D xfeature_get_offset(xfeatures, topmost); - return offset + xstate_sizes[topmost]; + return xfeature_get_offset(xfeatures, topmost) + xstate_sizes[topmost]; } =20 /* --=20 2.34.1 From nobody Sun Feb 8 02:56:01 2026 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 9FE17EB64DC for ; Wed, 21 Jun 2023 12:22:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231491AbjFUMWl (ORCPT ); Wed, 21 Jun 2023 08:22:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbjFUMWa (ORCPT ); Wed, 21 Jun 2023 08:22:30 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D35EDD for ; Wed, 21 Jun 2023 05:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687350149; x=1718886149; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t7jSq9lhIuDurlZNMr91+neHmx2u8cph/G6HgXnh4hI=; b=iNlRnkdrHc36YbhD2KaZiF5rttMJXCm4yYkKrmq48HYRrKvqysghohZ5 hq1jPi/rRghzjRjpJNqAO2bdrCcIPb+GoTBNnuqFK1uw87KA5ZQkbbHFX l48mc/sBGy8+bf87+pd8T6YJYS8uLHau31P1cHCFrCgEPXpxb/IcFtaDy cthAp4A3ZO0LZ2Wq28xSKKj5OM3EY8/9O/5IGKfjV3fC5QDwVxwGbM0l+ 93I8GAk5UDqJynzm5cddM5CevUkvsVng9+EVjgAMsHy6EvuT+zaOeJrUv 7MY3GmGeR1NvgZFafPR7sEKVveDh91qxxrW6r3slIb+/VHhtcrpzYcb+9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="360165698" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="360165698" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2023 05:22:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="888638354" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="888638354" Received: from chang-linux-3.sc.intel.com ([172.25.66.173]) by orsmga005.jf.intel.com with ESMTP; 21 Jun 2023 05:22:28 -0700 From: "Chang S. Bae" To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, andrew.cooper3@citrix.com, chang.seok.bae@intel.com Subject: [PATCH v1 3/4] x86/fpu/xstate: Simplify print_xstate_features() Date: Wed, 21 Jun 2023 05:09:41 -0700 Message-Id: <20230621120942.121822-4-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621120942.121822-1-chang.seok.bae@intel.com> References: <20230621120942.121822-1-chang.seok.bae@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The print_xstate_features() invokes print_xstate_feature() multiple times in separate lines which can be replaced with a loop. The print_xstate_feature() function already checks the feature enabling status, and it is only called from within print_xstate_features(). So the code can be relocated. Move the code exactly to print_xstate_features() and wrap it with a loop there. Signed-off-by: Chang S. Bae Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/kernel/fpu/xstate.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index d488621b280e..6d72498ea0bc 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -253,31 +253,20 @@ static void __init setup_xstate_cache(void) } } =20 -static void __init print_xstate_feature(u64 xstate_mask) -{ - const char *feature_name; - - if (cpu_has_xfeatures(xstate_mask, &feature_name)) - pr_info("x86/fpu: Supporting XSAVE feature 0x%03Lx: '%s'\n", xstate_mask= , feature_name); -} - /* * Print out all the supported xstate features: */ static void __init print_xstate_features(void) { - print_xstate_feature(XFEATURE_MASK_FP); - print_xstate_feature(XFEATURE_MASK_SSE); - print_xstate_feature(XFEATURE_MASK_YMM); - print_xstate_feature(XFEATURE_MASK_BNDREGS); - print_xstate_feature(XFEATURE_MASK_BNDCSR); - print_xstate_feature(XFEATURE_MASK_OPMASK); - print_xstate_feature(XFEATURE_MASK_ZMM_Hi256); - print_xstate_feature(XFEATURE_MASK_Hi16_ZMM); - print_xstate_feature(XFEATURE_MASK_PKRU); - print_xstate_feature(XFEATURE_MASK_PASID); - print_xstate_feature(XFEATURE_MASK_XTILE_CFG); - print_xstate_feature(XFEATURE_MASK_XTILE_DATA); + int i; + + for (i =3D 0; i < XFEATURE_MAX; i++) { + u64 mask =3D BIT_ULL(i); + const char *name; + + if (cpu_has_xfeatures(mask, &name)) + pr_info("x86/fpu: Supporting XSAVE feature 0x%03Lx: '%s'\n", mask, name= ); + } } =20 /* --=20 2.34.1 From nobody Sun Feb 8 02:56:01 2026 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 8EE17EB64D7 for ; Wed, 21 Jun 2023 12:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbjFUMWp (ORCPT ); Wed, 21 Jun 2023 08:22:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbjFUMWa (ORCPT ); Wed, 21 Jun 2023 08:22:30 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6EEC1718 for ; Wed, 21 Jun 2023 05:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687350149; x=1718886149; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PxrG7SFhXzSn4raQBGerOrXRroeYuO9/VMUGq89WOlM=; b=EE3rqI8LbKdp6TGGgcyQ9iO6LM5XIU4GfX32AzOmiJbRjcWI73me/lKJ zrrqfkfgBESP5kKsXzDr1Outx/xgQyMt6+UFwIRuE00YuVsMxaElrv0en p87fxIv4ZOHC/D77FUk/DVYsqUi5g5DtUI6nMlePruQiaJaVoYRMlOa6G 0Fj7WrhY6FFS8XCuG/5QTUpUOrwo6mUwiV7jAOdtQo5yQRAzG530BrOhP Dnarh1Fg0oATAJ2Zh5BAgUolh6wtC+CZdvVeu0tk7CSWw5S/C3v1sN3qn cJ6kj9ju3Pz9/YxT4Frm8PuQYlZjB8aJ9Ob3+ULNlNb4bVdMZzedfzRgK w==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="360165707" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="360165707" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2023 05:22:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="888638358" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="888638358" Received: from chang-linux-3.sc.intel.com ([172.25.66.173]) by orsmga005.jf.intel.com with ESMTP; 21 Jun 2023 05:22:28 -0700 From: "Chang S. Bae" To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, andrew.cooper3@citrix.com, chang.seok.bae@intel.com Subject: [PATCH v1 4/4] x86/fpu: Remove the unnecessary fpstate_reset() invocation Date: Wed, 21 Jun 2023 05:09:42 -0700 Message-Id: <20230621120942.121822-5-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621120942.121822-1-chang.seok.bae@intel.com> References: <20230621120942.121822-1-chang.seok.bae@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" fpstate_reset() initializes the fpstate container. But, when no state has been established yet, calling this is not meaningful. In the fpu__init_system() function, it is called immediately after the legacy FPU size is determined. So, remove it as not causing any issues. Signed-off-by: Chang S. Bae Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- The change made by fpstate_reset() can be measured with this: static struct fpstate fps; void __init fpu__init_system(struct cpuinfo_x86 *c) { memcpy(&fps, ¤t->thread.fpu.__fpstate, sizeof(struct fpstate)); fpstate_reset(¤t->thread.fpu); if (memcmp(&fps, ¤t->thread.fpu.__fpstate, sizeof(struct fpstate))) pr_info("fpstate has reason to be inited at %s\n", __func__); else pr_info("fpstate has no reason to be inited at %s\n", __func__); ... } Although it looks to be a no-op, there might be some unknown intention behind it. If there is a specific reason for invoking fpstate_reset() at that point, this should be documented properly instead of removing it. --- arch/x86/kernel/fpu/init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c index 998a08f17e33..95af3084c4cf 100644 --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -213,7 +213,6 @@ static void __init fpu__init_system_xstate_size_legacy(= void) */ void __init fpu__init_system(void) { - fpstate_reset(¤t->thread.fpu); fpu__init_system_early_generic(); =20 /* --=20 2.34.1