This is the logic how to calculate FSB and CPU frequency in cpu.c source code from chameleon loader, it is pretty easy to understand it:
Code: Select all
msr = rdmsr64(MSR_IA32_PERF_STATUS);
DBG("msr(%d): ia32_perf_stat 0x%08x\n", __LINE__, bitfield(msr, 31, 0));
currcoef = bitfield(msr, 15, 8);
/* Non-integer bus ratio for the max-multi*/
maxdiv = bitfield(msr, 46, 46);
/* Non-integer bus ratio for the current-multi (undocumented)*/
currdiv = bitfield(msr, 14, 14);
// This will always be model >= 3
if ((p->CPU.Family == 0x06 && p->CPU.Model >= 0x0e) || (p->CPU.Family == 0x0f))
{
/* On these models, maxcoef defines TSC freq */
maxcoef = bitfield(msr, 44, 40);
}
else
{
/* On lower models, currcoef defines TSC freq */
/* XXX */
maxcoef = currcoef;
}
if (maxcoef)
{
if (maxdiv)
{
fsbFrequency = ((tscFrequency * 2) / ((maxcoef * 2) + 1));
}
else
{
fsbFrequency = (tscFrequency / maxcoef);
}
if (currdiv)
{
cpuFrequency = (fsbFrequency * ((currcoef * 2) + 1) / 2);
}
else
{
cpuFrequency = (fsbFrequency * currcoef);
}
DBG("max: %d%s current: %d%s\n", maxcoef, maxdiv ? ".5" : "",currcoef, currdiv ? ".5" : "");
}
}
}
For IBM/Lenovo Thinkpad, there is no option in bios to disable IDA (Intel Dynamic Acceleration). so variable
maxcoef always return higher values than stocked value. For example, T7500@ 2.2GHz, when IDA enabled, maxcoef =12, so that CPU frequency can go as high as 2.4Ghz. when IDA is disabled. maxcoef =11.
for T7500, tscFrequency is labelled frequency as 2194Mhz (2.2Ghz). this is how chameleon loader to calculate fsbFrequency:
fsbFrequency = (tscFrequency / maxcoef);
When IDA enabled, maxcoef =12 , fsbFrequency = 2194/12 = 182 (Mhz), we saw this on Thinkpad
When IDA disabled, maxcoef =11 ,fsbFrequency = 2194/11 = 199 (Mhz), on Dell laptop, disable IDA in bios, you will get this correct value in MAC OSX.
The 2nd Example, T9300@2.5Ghz, tscFrequency = 2493MHz(2.5Ghz), this is how chameleon loader to calculate fsbFrequency:
fsbFrequency = ((tscFrequency * 2) / ((maxcoef * 2) + 1));
When IDA enabled, maxcoef = 13, fsbFrequency = 2493 *2 / (13*2 +1) = 184 (Mhz), we saw this on Thinkpad
When IDA disabled, maxcoef = 12, fsbFrequency = 2493 *2/ (12*2 +1) = 199 (Mhz), again on Dell laptop, disable IDA in bios, you will get this correct value in MAC OSX.
Unfortunately, on Thinkpad, We can only disable Intel Speedstep in order to disable IDA. when we disable Intel Speedstep. this is what happened.
For T7500@ 2.2GHz, tscFrequency = 2194Mhz (2.2Ghz), maxcoef =11, currcoef = 6
fsbFrequency = (tscFrequency / maxcoef) = 2194/11 = 199 (Mhz) which is correct now. But
cpuFrequency = (fsbFrequency * currcoef) = 199 x6 = 1194 Mhz. The CPU will show as 1.2Ghz C2D. We saw this on Thinkpad. We always need to enable Intel Speedstep in BIOS in order to make currcoef = maxcoef. so CPU can run at its stocked maximum frequency.
Based on above analysis, I will modify cpu.c code in chameleon loader to ignore IDA, but get the correct maxcoef value!