[PATCH] x86: Check if CPUID_INDEX_7_ECX_1 is supported first
"H.J. Lu" <[email protected]>
| Newsgroups | gmane.comp.lib.glibc.alpha |
|---|---|
| Message-ID | <CAMe9rOro-xjRjsaOsRcYrcyb5F-Lcs+gdBq-pYzwPE3UtiTsGw@mail.gmail.com> |
Since bits 31 - 00 in EAX from CPUID with EAX == 7 and ECX == 0 reports the maximum input value for supported leaf 7 sub-leaves for CPUID with EAX == 7, check it before invoking CPUID with EAX == 7 and ECX == 1. This fixes BZ #34565. -- H.J.
0001-x86-Check-if-CPUID_INDEX_7_ECX_1-is-supported-first.patch
(text/x-patch, 1.7 KB)
From 7f5f1bdc7fd97d165d1c41d7a83c426f4423cd1b Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <[email protected]> Date: Tue, 25 Aug 2026 09:43:26 +0800 Subject: [PATCH] x86: Check if CPUID_INDEX_7_ECX_1 is supported first Since bits 31 - 00 in EAX from CPUID with EAX == 7 and ECX == 0 reports the maximum input value for supported leaf 7 sub-leaves for CPUID with EAX == 7, check it before invoking CPUID with EAX == 7 and ECX == 1. This fixes BZ #34565. Signed-off-by: H.J. Lu <[email protected]> --- sysdeps/x86/cpu-features.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index a453136827..0db33e0f35 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -458,11 +458,13 @@ get_common_indices (struct cpu_features *cpu_features, cpu_features->features[CPUID_INDEX_7].cpuid.ebx, cpu_features->features[CPUID_INDEX_7].cpuid.ecx, cpu_features->features[CPUID_INDEX_7].cpuid.edx); - __cpuid_count (7, 1, - cpu_features->features[CPUID_INDEX_7_ECX_1].cpuid.eax, - cpu_features->features[CPUID_INDEX_7_ECX_1].cpuid.ebx, - cpu_features->features[CPUID_INDEX_7_ECX_1].cpuid.ecx, - cpu_features->features[CPUID_INDEX_7_ECX_1].cpuid.edx); + if (cpu_features->features[CPUID_INDEX_7].cpuid.eax != 0) + __cpuid_count + (7, 1, + cpu_features->features[CPUID_INDEX_7_ECX_1].cpuid.eax, + cpu_features->features[CPUID_INDEX_7_ECX_1].cpuid.ebx, + cpu_features->features[CPUID_INDEX_7_ECX_1].cpuid.ecx, + cpu_features->features[CPUID_INDEX_7_ECX_1].cpuid.edx); } if (cpu_features->basic.max_cpuid >= 0xd) -- 2.55.0