mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Eric Biggers" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Eric Biggers <ebiggers@kernel.org>,
	"Borislav Petkov (AMD)" <bp@alien8.de>,
	Christoph Hellwig <hch@lst.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/fpu] x86/fpu: Remove cpu_has_xfeatures()
Date: Wed, 09 Sep 2026 23:57:56 -0000	[thread overview]
Message-ID: <178899827671.623050.8514464749794445362.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260901145740.42337-7-ebiggers@kernel.org>

The following commit has been merged into the x86/fpu branch of tip:

Commit-ID:     a5f7ae47667cc69738b2483e085cb0b2d819a9ce
Gitweb:        https://git.kernel.org/tip/a5f7ae47667cc69738b2483e085cb0b2d819a9ce
Author:        Eric Biggers <ebiggers@kernel.org>
AuthorDate:    Tue, 01 Sep 2026 07:57:38 -07:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Wed, 09 Sep 2026 14:15:12 -07:00

x86/fpu: Remove cpu_has_xfeatures()

The only remaining caller of cpu_has_xfeatures() is print_xstate_features(),
which uses it only to check and get the name of a single feature.

Remove it and just inline the needed code into print_xstate_features().

This also makes the "unknown xstate feature" entry at index XFEATURE_MAX of
xfeature_names[] unnecessary, so remove that too.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260901145740.42337-7-ebiggers@kernel.org
---
 arch/x86/include/asm/fpu/api.h |  9 +-------
 arch/x86/kernel/fpu/xstate.c   | 44 ++-------------------------------
 2 files changed, 3 insertions(+), 50 deletions(-)

diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index 90c63fe..cfed8b2 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -99,15 +99,6 @@ static inline void fpregs_assert_state_consistent(void) { }
  */
 extern void switch_fpu_return(void);
 
-/*
- * Query the presence of one or more xfeatures. Works on any legacy CPU as well.
- *
- * If 'feature_name' is set then put a human-readable description of
- * the feature there as well - this can be used to print error (or success)
- * messages.
- */
-extern int cpu_has_xfeatures(u64 xfeatures_mask, const char **feature_name);
-
 /* Trap handling */
 extern int  fpu__exception_code(struct fpu *fpu, int trap_nr);
 extern void fpu_sync_fpstate(struct fpu *fpu);
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 97cfd4f..0b17452 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -66,8 +66,8 @@ static const char *xfeature_names[] =
 	"AMX Tile config",
 	"AMX Tile data",
 	"APX registers",
-	"unknown xstate feature",
 };
+static_assert(ARRAY_SIZE(xfeature_names) == XFEATURE_MAX);
 
 static unsigned short xsave_cpuid_features[] __initdata = {
 	[XFEATURE_FP]				= X86_FEATURE_FPU,
@@ -122,44 +122,6 @@ static inline unsigned int next_xfeature_order(unsigned int i, u64 mask)
 #define XSTATE_FLAG_SUPERVISOR	BIT(0)
 #define XSTATE_FLAG_ALIGNED64	BIT(1)
 
-/*
- * Return whether the system supports a given xfeature.
- *
- * Also return the name of the (most advanced) feature that the caller requested:
- */
-int cpu_has_xfeatures(u64 xfeatures_needed, const char **feature_name)
-{
-	u64 xfeatures_missing = xfeatures_needed & ~fpu_kernel_cfg.max_features;
-
-	if (unlikely(feature_name)) {
-		long xfeature_idx, max_idx;
-		u64 xfeatures_print;
-		/*
-		 * So we use FLS here to be able to print the most advanced
-		 * feature that was requested but is missing. So if a driver
-		 * asks about "XFEATURE_MASK_SSE | XFEATURE_MASK_YMM" we'll print the
-		 * missing AVX feature - this is the most informative message
-		 * to users:
-		 */
-		if (xfeatures_missing)
-			xfeatures_print = xfeatures_missing;
-		else
-			xfeatures_print = xfeatures_needed;
-
-		xfeature_idx = fls64(xfeatures_print)-1;
-		max_idx = ARRAY_SIZE(xfeature_names)-1;
-		xfeature_idx = min(xfeature_idx, max_idx);
-
-		*feature_name = xfeature_names[xfeature_idx];
-	}
-
-	if (xfeatures_missing)
-		return 0;
-
-	return 1;
-}
-EXPORT_SYMBOL_GPL(cpu_has_xfeatures);
-
 static bool xfeature_is_aligned64(int xfeature_nr)
 {
 	return xstate_flags[xfeature_nr] & XSTATE_FLAG_ALIGNED64;
@@ -302,9 +264,9 @@ static void __init print_xstate_features(void)
 
 	for (i = 0; i < XFEATURE_MAX; i++) {
 		u64 mask = BIT_ULL(i);
-		const char *name;
+		const char *name = xfeature_names[i];
 
-		if (cpu_has_xfeatures(mask, &name))
+		if (fpu_kernel_cfg.max_features & mask)
 			pr_info("x86/fpu: Supporting XSAVE feature 0x%03Lx: '%s'\n", mask, name);
 	}
 }

  reply	other threads:[~2026-09-09 23:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 14:57 [PATCH v5 0/8] x86: Remove cpu_has_xfeatures() and add AVX-512 xor_gen() Eric Biggers
2026-09-01 14:57 ` [PATCH v5 1/8] x86/fpu: Check for missing AVX and AVX-512 xstate bits Eric Biggers
2026-09-09 23:58   ` [tip: x86/fpu] " tip-bot2 for Eric Biggers
2026-09-01 14:57 ` [PATCH v5 2/8] um: " Eric Biggers
2026-09-09 23:58   ` [tip: x86/fpu] " tip-bot2 for Eric Biggers
2026-09-01 14:57 ` [PATCH v5 3/8] crypto: x86 - Stop using cpu_has_xfeatures() Eric Biggers
2026-09-09 23:58   ` [tip: x86/fpu] " tip-bot2 for Eric Biggers
2026-09-01 14:57 ` [PATCH v5 4/8] lib/crypto: x86: " Eric Biggers
2026-09-09 23:57   ` [tip: x86/fpu] " tip-bot2 for Eric Biggers
2026-09-01 14:57 ` [PATCH v5 5/8] lib/crc: " Eric Biggers
2026-09-09 23:57   ` [tip: x86/fpu] " tip-bot2 for Eric Biggers
2026-09-01 14:57 ` [PATCH v5 6/8] x86/fpu: Remove cpu_has_xfeatures() Eric Biggers
2026-09-09 23:57   ` tip-bot2 for Eric Biggers [this message]
2026-09-10  8:38   ` Peter Zijlstra
2026-09-10 14:23     ` Borislav Petkov
2026-09-10 14:59       ` Eric Biggers
2026-09-10 15:44         ` Borislav Petkov
2026-09-01 14:57 ` [PATCH v5 7/8] xor: Remove redundant X86_FEATURE_OSXSAVE check Eric Biggers
2026-09-09 23:57   ` [tip: x86/fpu] " tip-bot2 for Eric Biggers
2026-09-10 15:38   ` tip-bot2 for Eric Biggers
2026-09-01 14:57 ` [PATCH v5 8/8] xor: Add AVX-512 optimized xor_gen() Eric Biggers
2026-09-09 23:57   ` [tip: x86/fpu] " tip-bot2 for Eric Biggers
2026-09-10 15:38   ` tip-bot2 for Eric Biggers
2026-09-02 17:11 ` [PATCH v5 0/8] x86: Remove cpu_has_xfeatures() and add AVX-512 xor_gen() Borislav Petkov

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=178899827671.623050.8514464749794445362.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bp@alien8.de \
    --cc=ebiggers@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.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

all inboxes | Powered by JetHome®