x86/cpu/intel: Fix the constant_tsc model check for Pentium 4s
Subsystems (2)
PATCH v3 1/1 x86/cpu/intel: Fix the constant_tsc model check for Pentium 4s
The logic to synthesize constant_tsc for Pentium 4s (Family 15) is wrong. Since INTEL_P4_PRESCOTT is numerically greater than INTEL_P4_WILLAMETTE, the logic always results in false and never sets X86_FEATURE_CONSTANT_TSC for any Pentium 4 model.
The error was introduced while replacing the x86_model check with a VFM one. The original check was as follows:
if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
(c->x86 == 0x6 && c->x86_model >= 0x0e))
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);Fix the logic to cover all Pentium 4 models from Prescott (model 3) to Cedarmill (model 6) which is the last model released in Family 15.
---
Changes since v2:
- Improve commit message
Changes since v1:
- Fix incorrect logic
arch/x86/kernel/cpu/intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/intel.c +1 -1
@@ -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 ); }
Signature · 1 line
2.50.1
Greg KH
maintainerQuoted 9 lines · Suchit Karunakaran
The logic to synthesize
constant_tscfor Pentium 4s (Family 15) is wrong. SinceINTEL_P4_PRESCOTTis numerically greater thanINTEL_P4_WILLAMETTE, the logic always results in false and never setsX86_FEATURE_CONSTANT_TSCfor any Pentium 4 model.
The error was introduced while replacing thex86_modelcheck with a VFM one. The original check was as follows:if ((c->x86 == 0xf && c->x86_model >= 0x03) || (c->x86 == 0x6 && c->x86_model >= 0x0e)) set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
What do you mean by "original check"? Before the change that caused this, or what it should be?
Quoted 8 lines
Fix the logic to cover all Pentium 4 models from Prescott (model 3) to Cedarmill (model 6) which is the last model released in Family 15.
Fixes fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural constant_tsc model checks")Cc <[email protected]> # v6.15Signed-off-by Suchit Karunakaran <[email protected]>
Nit, no blank lines beween all of those last lines. Hint, look at all of the patches on the mailing lists AND in the tree already, you have hundreds of thousands of examples here of how to format things :)
thanks,
greg k-h
Quoted 12 lines · Greg KH
Quoted 9 lines · Suchit Karunakaran
The logic to synthesize
constant_tscfor Pentium 4s (Family 15) is wrong. SinceINTEL_P4_PRESCOTTis numerically greater thanINTEL_P4_WILLAMETTE, the logic always results in false and never setsX86_FEATURE_CONSTANT_TSCfor any Pentium 4 model.
The error was introduced while replacing thex86_modelcheck with a VFM one. The original check was as follows:if ((c->x86 == 0xf && c->x86_model >= 0x03) || (c->x86 == 0x6 && c->x86_model >= 0x0e)) set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
Quoted 3 lines
What do you mean by "original check"? Before the change that caused this, or what it should be?
Original check in this context refers to the change before the erroneous code.
Quoted 5 lines
Quoted 5 lines
Fix the logic to cover all Pentium 4 models from Prescott (model 3) to Cedarmill (model 6) which is the last model released in Family 15.
Fixes fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural constant_tsc model checks")
Quoted 8 lines
Quoted 3 lines
Cc <[email protected]> # v6.15Signed-off-by Suchit Karunakaran <[email protected]>Nit, no blank lines beween all of those last lines. Hint, look at all of the patches on the mailing lists AND in the tree already, you have hundreds of thousands of examples here of how to format things :)
Sorry about it. Should I send a new version of the patch removing the blank lines?
Greg KH
maintainerQuoted 28 lines · Suchit Karunakaran
Quoted 12 lines · Greg KH
Quoted 9 lines · Suchit Karunakaran
The logic to synthesize
constant_tscfor Pentium 4s (Family 15) is wrong. SinceINTEL_P4_PRESCOTTis numerically greater thanINTEL_P4_WILLAMETTE, the logic always results in false and never setsX86_FEATURE_CONSTANT_TSCfor any Pentium 4 model.
The error was introduced while replacing thex86_modelcheck with a VFM one. The original check was as follows:if ((c->x86 == 0xf && c->x86_model >= 0x03) || (c->x86 == 0x6 && c->x86_model >= 0x0e)) set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);Quoted 3 lines
What do you mean by "original check"? Before the change that caused this, or what it should be?
Original check in this context refers to the change before the erroneous code.
Quoted 9 lines
Quoted 8 lines
Fix the logic to cover all Pentium 4 models from Prescott (model 3) to Cedarmill (model 6) which is the last model released in Family 15.
Fixes fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural constant_tsc model checks")Cc <[email protected]> # v6.15Signed-off-by Suchit Karunakaran <[email protected]>
Quoted 7 lines
Quoted 4 lines
Nit, no blank lines beween all of those last lines. Hint, look at all of the patches on the mailing lists AND in the tree already, you have hundreds of thousands of examples here of how to format things :)
Sorry about it. Should I send a new version of the patch removing the blank lines?
That's up to the maintainer(s) of this subsystem, if they want to manually edit the change or not. As it's the middle of the merge window, no one will probably be doing anything for another 2 weeks on it anyway, so just relax and see what happens :)
thanks,
greg k-h
Quoted 38 lines · Greg KH
Quoted 28 lines · Suchit Karunakaran
Quoted 12 lines · Greg KH
Quoted 9 lines · Suchit Karunakaran
The logic to synthesize
constant_tscfor Pentium 4s (Family 15) is wrong. SinceINTEL_P4_PRESCOTTis numerically greater thanINTEL_P4_WILLAMETTE, the logic always results in false and never setsX86_FEATURE_CONSTANT_TSCfor any Pentium 4 model.
The error was introduced while replacing thex86_modelcheck with a VFM one. The original check was as follows:if ((c->x86 == 0xf && c->x86_model >= 0x03) || (c->x86 == 0x6 && c->x86_model >= 0x0e)) set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);Quoted 3 lines
What do you mean by "original check"? Before the change that caused this, or what it should be?
Original check in this context refers to the change before the erroneous code.
Quoted 9 lines
Quoted 8 lines
Fix the logic to cover all Pentium 4 models from Prescott (model 3) to Cedarmill (model 6) which is the last model released in Family 15.
Fixes fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural constant_tsc model checks")Cc <[email protected]> # v6.15Signed-off-by Suchit Karunakaran <[email protected]>Quoted 7 lines
Quoted 4 lines
Nit, no blank lines beween all of those last lines. Hint, look at all of the patches on the mailing lists AND in the tree already, you have hundreds of thousands of examples here of how to format things :)
Sorry about it. Should I send a new version of the patch removing the blank lines?
Quoted 8 lines
That's up to the maintainer(s) of this subsystem, if they want to manually edit the change or not. As it's the middle of the merge window, no one will probably be doing anything for another 2 weeks on it anyway, so just relax and see what happens :)
thanks,
greg k-h
Hi Greg,
Thank you for the clarification. I apologize for the mistakes and appreciate your patience in reviewing.
Thanks,
Suchit
Hi Suchit,
The patch looks good to me except for a few nits below.
Quoted 4 lines · Suchit Karunakaran
The logic to synthesize
constant_tscfor Pentium 4s (Family 15) is wrong. SinceINTEL_P4_PRESCOTTis numerically greater thanINTEL_P4_WILLAMETTE, the logic always results in false and never setsX86_FEATURE_CONSTANT_TSCfor any Pentium 4 model.
A blank line here would be useful to separate the two paragraphs.
Quoted 2 lines
The error was introduced while replacing the
x86_modelcheck with a VFM one. The original check was as follows:
Maybe to make it more precise and avoid confusion.
The original check before the erroneous code was as follows:
Quoted 4 lines
if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
(c->x86 == 0x6 && c->x86_model >= 0x0e))
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);Quoted 9 lines
Fix the logic to cover all Pentium 4 models from Prescott (model 3) to Cedarmill (model 6) which is the last model released in Family 15.
Fixes fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural constant_tsc model checks")Cc <[email protected]> # v6.15Signed-off-by Suchit Karunakaran <[email protected]>
(without the blank lines as Greg mentioned)
arch/x86/kernel/cpu/intel.c static void early_init_intel(struct cpuinfo_x86 *c) · line 265
Quoted 11 lines
arch/x86/kernel/cpu/intel.c +1
-1@@ -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) ||
The alignment here seems to have changed because the extra space after INTEL_P4_PRESCOTT was moved before it. The current code has alignment matched with the below line. It isn't a big deal, but keeps the code easier to read.
Quoted 3 lines
arch/x86/kernel/cpu/intel.c +0
-0(c->x86_vfm >= INTEL_CORE_YONAH && c->x86_vfm <= INTEL_IVYBRIDGE)) {set_cpu_cap (c,X86_FEATURE_CONSTANT_TSC ); }
Quoted 38 lines · Sohil Mehta
Hi Suchit,
The patch looks good to me except for a few nits below.
Quoted 4 lines · Suchit Karunakaran
The logic to synthesize
constant_tscfor Pentium 4s (Family 15) is wrong. SinceINTEL_P4_PRESCOTTis numerically greater thanINTEL_P4_WILLAMETTE, the logic always results in false and never setsX86_FEATURE_CONSTANT_TSCfor any Pentium 4 model.A blank line here would be useful to separate the two paragraphs.
Quoted 2 lines
The error was introduced while replacing the
x86_modelcheck with a VFM one. The original check was as follows:Maybe to make it more precise and avoid confusion.
The original check before the erroneous code was as follows:
Quoted 4 lines
if ((c->x86 == 0xf && c->x86_model >= 0x03) || (c->x86 == 0x6 && c->x86_model >= 0x0e)) set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);Quoted 9 lines
Fix the logic to cover all Pentium 4 models from Prescott (model 3) to Cedarmill (model 6) which is the last model released in Family 15.
Fixes fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural constant_tsc model checks")Cc <[email protected]> # v6.15Signed-off-by Suchit Karunakaran <[email protected]>Reviewed-by Sohil Mehta <[email protected]>(without the blank lines as Greg mentioned)
Quoted 1 line
Quoted 22 lines
arch/x86/kernel/cpu/intel.c static void early_init_intel(struct cpuinfo_x86 *c) · line 265
Quoted 10 lines
arch/x86/kernel/cpu/intel.c +1
-1@@ -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) ||The alignment here seems to have changed because the extra space after
INTEL_P4_PRESCOTTwas moved before it. The current code has alignment matched with the below line. It isn't a big deal, but keeps the code easier to read.Quoted 3 lines
arch/x86/kernel/cpu/intel.c +0
-0(c->x86_vfm >= INTEL_CORE_YONAH && c->x86_vfm <= INTEL_IVYBRIDGE)) {set_cpu_cap (c,X86_FEATURE_CONSTANT_TSC ); }
Hi Sohil. Thanks for reviewing it. Should I send a new version of the patch fixing the minor issues with the reviewed by tag?
Quoted 2 lines · Suchit Karunakaran
Hi Sohil. Thanks for reviewing it. Should I send a new version of the patch fixing the minor issues with the reviewed by tag?
Yes please, I think one more revision would be helpful and reduce manual steps for the maintainers. (Likely after the merge window has closed).
Also, please try to trim your responses to only include the essential context:
https://subspace.kernel.org/etiquette.html#trim-your-quotes-when-replying.
Quoted 6 lines · Sohil Mehta
Quoted 2 lines · Suchit Karunakaran
Hi Sohil. Thanks for reviewing it. Should I send a new version of the patch fixing the minor issues with the reviewed by tag?
Quoted 8 lines
Yes please, I think one more revision would be helpful and reduce manual steps for the maintainers. (Likely after the merge window has closed).
Also, please try to trim your responses to only include the essential context:
https://subspace.kernel.org/etiquette.html#trim-your-quotes-when-replying.
Alright. I will send v4 after the merge window closes. Thanks!
Quoted 2 lines · Suchit Karunakaran
Alright. I will send v4 after the merge window closes. Thanks!
Sending the patch sooner is fine, if you want. I meant it is likely to be picked up after the merge window has closed.
Quoted 7 lines · Sohil Mehta
Quoted 2 lines · Suchit Karunakaran
Alright. I will send v4 after the merge window closes. Thanks!
Sending the patch sooner is fine, if you want. I meant it is likely to be picked up after the merge window has closed.
Yup got it.
Quoted 6 lines · Suchit Karunakaran
The logic to synthesize
constant_tscfor Pentium 4s (Family 15) is wrong. SinceINTEL_P4_PRESCOTTis numerically greater thanINTEL_P4_WILLAMETTE, the logic always results in false and never setsX86_FEATURE_CONSTANT_TSCfor any Pentium 4 model.
The error was introduced while replacing thex86_modelcheck with a VFM one. The original check was as follows:
Quoted 6 lines
if ((c->x86 == 0xf && c->x86_model >= 0x03) || (c->x86 == 0x6 && c->x86_model >= 0x0e)) set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);Fix the logic to cover all Pentium 4 models from Prescott (model 3) to Cedarmill (model 6) which is the last model released in Family 15.
Could we have a slightly different changelog, please? The fact that the logic results in the bit never getting set for P4's is IMNHO immaterial. This looks like a plain and simple typo, not a logical error on the patch author's part.
How about this as a changelog?
--
Pentium 4's which are INTEL_P4_PRESCOTT (mode 0x03) and later have a constant TSC. This was correctly captured until fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural constant_tsc model checks"). In that commit, the model was transposed from 0x03 to INTEL_P4_WILLAMETTE, which is just plain wrong. That was presumably a simple typo, probably just copying and pasting the wrong P4 model.
Fix the constant TSC logic to cover all later P4 models. End at INTEL_P4_CEDARMILL which is the last P4 model.
Quoted 31 lines · Dave Hansen
Quoted 6 lines · Suchit Karunakaran
The logic to synthesize
constant_tscfor Pentium 4s (Family 15) is wrong. SinceINTEL_P4_PRESCOTTis numerically greater thanINTEL_P4_WILLAMETTE, the logic always results in false and never setsX86_FEATURE_CONSTANT_TSCfor any Pentium 4 model.
The error was introduced while replacing thex86_modelcheck with a VFM one. The original check was as follows:Quoted 6 lines
if ((c->x86 == 0xf && c->x86_model >= 0x03) || (c->x86 == 0x6 && c->x86_model >= 0x0e)) set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);Fix the logic to cover all Pentium 4 models from Prescott (model 3) to Cedarmill (model 6) which is the last model released in Family 15.
Could we have a slightly different changelog, please? The fact that the logic results in the bit never getting set for P4's is IMNHO immaterial. This looks like a plain and simple typo, not a logical error on the patch author's part.
How about this as a changelog?
--
Pentium 4's which are
INTEL_P4_PRESCOTT(mode0x03) and later have a constant TSC. This was correctly captured untilfadb6f569b10("x86/cpu/intel: Limit the non-architecturalconstant_tscmodel checks"). In that commit, the model was transposed from0x03toINTEL_P4_WILLAMETTE, which is just plain wrong. That was presumably a simple typo, probably just copying and pasting the wrong P4 model.
Quoted 2 lines
Fix the constant TSC logic to cover all later P4 models. End at
INTEL_P4_CEDARMILLwhich is the last P4 model.
Yeah, I agree it's more of a typo than a logical error.
Quoted 5 lines · Dave Hansen
Could we have a slightly different changelog, please? The fact that the logic results in the bit never getting set for P4's is IMNHO immaterial. This looks like a plain and simple typo, not a logical error on the patch author's part.
I can confirm it was a typing error that led to this bogus logic.
Quoted 2 lines
How about this as a changelog?
The changelog is fine, except the error happened while choosing the upper bound (INTEL_P4_WILLAMETTE instead of INTEL_P4_CEDARMILL) and *not* the lower bound (INTEL_P4_PRESCOTT) as suggested below.
Quoted 11 lines
--
Pentium 4's which are
INTEL_P4_PRESCOTT(mode0x03) and later have a constant TSC. This was correctly captured untilfadb6f569b10("x86/cpu/intel: Limit the non-architecturalconstant_tscmodel checks"). In that commit, the model was transposed from0x03toINTEL_P4_WILLAMETTE, which is just plain wrong. That was presumably a simple typo, probably just copying and pasting the wrong P4 model.Fix the constant TSC logic to cover all later P4 models. End at
INTEL_P4_CEDARMILLwhich is the last P4 model.
Tweaked this slightly for accuracy:
Pentium 4's which are INTEL_P4_PRESCOTT (model 0x03) and later have a constant TSC. This was correctly captured until commit fadb6f569b10 ("x86/cpu/intel: Limit the non-architectural constant_tsc model checks").
In that commit, an error was introduced while selecting the last P4 model (0x06) as the upper bound. Model 0x06 was transposed to INTEL_P4_WILLAMETTE, which is just plain wrong. That was presumably a simple typo, probably just copying and pasting the wrong P4 model.
Fix the constant TSC logic to cover all later P4 models. End at INTEL_P4_CEDARMILL which accurately corresponds to the last P4 model.