From: Suchit Karunakaran <suchitkarunakaran@gmail.com>
To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, hpa@zytor.com, darwi@linutronix.de,
sohil.mehta@intel.com, peterz@infradead.org,
ravi.bangoria@amd.com
Cc: skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev,
linux-kernel@vger.kernel.org,
Suchit Karunakaran <suchitkarunakaran@gmail.com>
Subject: [PATCH v2] x86/intel: Fix always false range check in x86_vfm model matching
Date: Tue, 29 Jul 2025 09:56:21 +0530 [thread overview]
Message-ID: <20250729042621.6403-1-suchitkarunakaran@gmail.com> (raw)
Fix a logic bug in early_init_intel() where a conditional range check:
(c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_WILLAMETTE)
was always false due to (PRESCOTT) being numerically greater than the
upper bound (WILLAMETTE). This triggers:-Werror=logical-op:
logical ‘and’ of mutually exclusive tests is always false
The fix corrects the constant ordering to ensure the range is valid:
(c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_CEDARMILL)
Fixes: fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural
constant_tsc model checks")
Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
Changes since v1:
- Fix incorrect logic
---
arch/x86/kernel/cpu/intel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 076eaa41b8c8..6f5bd5dbc249 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -262,7 +262,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
if (c->x86_power & (1 << 8)) {
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
- } else if ((c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_WILLAMETTE) ||
+ } else if ((c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_CEDARMILL) ||
(c->x86_vfm >= INTEL_CORE_YONAH && c->x86_vfm <= INTEL_IVYBRIDGE)) {
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
}
--
2.50.1
next reply other threads:[~2025-07-29 4:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 4:26 Suchit Karunakaran [this message]
2025-07-29 5:28 ` [PATCH v2] x86/intel: Fix always false range check in x86_vfm model matching Greg KH
2025-07-29 6:53 ` Suchit Karunakaran
2025-07-29 7:56 ` Greg KH
2025-07-29 8:54 ` Suchit Karunakaran
2025-07-29 9:01 ` Greg KH
2025-07-29 9:10 ` Suchit Karunakaran
[not found] ` <CAO9wTFjkBz=NbHeAdOaJ8jFpgOmO=pM5O+Q43hTT8qqvvXTSog@mail.gmail.com>
2025-07-29 22:32 ` H. Peter Anvin
2025-07-29 18:49 ` Sohil Mehta
2025-07-30 4:30 ` Suchit Karunakaran
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=20250729042621.6403-1-suchitkarunakaran@gmail.com \
--to=suchitkarunakaran@gmail.com \
--cc=bp@alien8.de \
--cc=darwi@linutronix.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=skhan@linuxfoundation.org \
--cc=sohil.mehta@intel.com \
--cc=tglx@linutronix.de \
/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