[PATCH 3/4] perf/x86/intel: Remove redundant cpu_has_xfeatures() checks

From: Eric Biggers

Date: Sun Dec 06 2026 - 00:13:04 EST


Remove the cpu_has_xfeatures() checks from
__intel_update_pmu_xregs_caps(), since they are redundant with the
corresponding X86_FEATURE_* checks. fpu__init_system_xstate() already
disables XSAVE (and therefore XSAVES), AVX, AVX512F, SHSTK (and
USER_SHSTK), and APX if their required xstate components are missing.

Also simplify the AVX-512 case to OR in XFEATURE_MASK_AVX512 directly.

Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
---
arch/x86/events/intel/core.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index e752111f5ecd7..2f6ad6121a815 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -6255,8 +6255,7 @@ static inline void __intel_update_pmu_xregs_caps(struct pmu *pmu)
if (!boot_cpu_has(X86_FEATURE_XSAVES))
return;

- if (!boot_cpu_has(X86_FEATURE_XMM) ||
- !cpu_has_xfeatures(XFEATURE_MASK_SSE, NULL))
+ if (!boot_cpu_has(X86_FEATURE_XMM))
return;

/*
@@ -6266,22 +6265,13 @@ static inline void __intel_update_pmu_xregs_caps(struct pmu *pmu)
*/
x86_pmu.ext_regs_mask |= XFEATURE_MASK_SSE;

- if (boot_cpu_has(X86_FEATURE_AVX) &&
- cpu_has_xfeatures(XFEATURE_MASK_YMM, NULL))
+ if (boot_cpu_has(X86_FEATURE_AVX))
x86_pmu.ext_regs_mask |= XFEATURE_MASK_YMM;
- if (boot_cpu_has(X86_FEATURE_APX) &&
- cpu_has_xfeatures(XFEATURE_MASK_APX, NULL))
+ if (boot_cpu_has(X86_FEATURE_APX))
x86_pmu.ext_regs_mask |= XFEATURE_MASK_APX;
- if (boot_cpu_has(X86_FEATURE_AVX512F)) {
- if (cpu_has_xfeatures(XFEATURE_MASK_OPMASK, NULL))
- x86_pmu.ext_regs_mask |= XFEATURE_MASK_OPMASK;
- if (cpu_has_xfeatures(XFEATURE_MASK_ZMM_Hi256, NULL))
- x86_pmu.ext_regs_mask |= XFEATURE_MASK_ZMM_Hi256;
- if (cpu_has_xfeatures(XFEATURE_MASK_Hi16_ZMM, NULL))
- x86_pmu.ext_regs_mask |= XFEATURE_MASK_Hi16_ZMM;
- }
- if (cpu_feature_enabled(X86_FEATURE_USER_SHSTK) &&
- cpu_has_xfeatures(XFEATURE_MASK_CET_USER, NULL))
+ if (boot_cpu_has(X86_FEATURE_AVX512F))
+ x86_pmu.ext_regs_mask |= XFEATURE_MASK_AVX512;
+ if (cpu_feature_enabled(X86_FEATURE_USER_SHSTK))
x86_pmu.ext_regs_mask |= XFEATURE_MASK_CET_USER;

dest_pmu->capabilities |= PERF_PMU_CAP_EXTENDED_REGS;
--
2.56.1