Chameleon

Issue 92: CPU Detection for AMD

Reported by Fumo Mofu, Jun 20, 2011

Reopening issue #52 (as instructed by Cosmosis Jones):

The part for AMD CPU detection in cpu.c is essentially commented out 

(#if 0…#endif).  This leads to a CPU and FSB frequency of 0.

In addition (I don't know if this is related), my TSC is 
unsynchronized which leads to random EXC_I386_DIV crashes a few 
hours after booting.  I have an AMD Athlon 64 X2.  Should TSC 
syncing be performed by the bootloader or by the kernel?

Unsynchronized  TSC for cpu 1: 0x0000002774723755, delta 
0xfffffffffff27682

I stopped the EXC_I386_DIV crashes by modifying VoodooTSCSync.kext 
to run every 10 seconds.

There are a few bugs in cpu.c that I would like to point out:
1. The number of cores for AMD is in CPUID 0x80000008 ECX[7:0]; 
CPUID 0x00000004 EAX[31:26] is only for Intel.
2. For AMD K8, there is no divisor ID so currdiv should just be left 

alone (set to 0).
3. Why are a lot of bit-extracting operations not using the macro 
bitfield?
4. There is no support for multipliers that are non-integers such as 

11.5x.

Comment 1 by Fumo Mofu, Jun 20, 2011

This is for the trunk by the way.

Comment 2 by Cosmosis Jones, Jun 21, 2011

tsc syncing in bootloader is problamatic as there are no mp_ 
functions defined.. Looking at the rest of it..

Comment 3 by Fumo Mofu, Jul 10, 2011

By the way…I already fixed 1, 2, and 3 a long time ago but I didn't 
know how to make a patch file. So…here are the files I modified 
(original is from the trunk at revision 1140).

Comment 4 by Fumo Mofu, Jul 10, 2011

Also, someone should check my conversion of the bit-extracting 
operations to the bitfield macro because I did not double check.

Comment 5 by Cosmosis Jones, Jul 18, 2011

Labels: Target:2.0
Status: Accepted
Owner: meklort

Comment 6 by Evan Lojewski, Jul 20, 2011

I've added your patch as well as support for K10 / K14 cpus. Please 
verify that trunk works properly with K8.
Status: Fixed

Comment 7 by Fumo Mofu, Jul 20, 2011

Works for K8. But no non-integer multipliers. =(

Comment 8 by Andy Moa, Jul 20, 2011

Just checked it with a K10 ..instant reboot

Comment 9 by Evan Lojewski, Jul 20, 2011

I'll double check K10.

Comment 10 by Evan Lojewski, Jul 20, 2011

Andy, when do you get the reboot?

I've just double checked and chameleon starts up just fine. Please 
set DEBUG_CPU in cpu.c to 1 and let pot a picture if you can.

Fumo: non integer multipliers are supported. For K10 /2 works fine 
(I've tested it) and for K14 /4 works. TO make K8's work fine, 
please ensure that you set currdiv and currcoef properly.

Comment 11 by Andy Moa, Jul 20, 2011

It was a hell of a Job to get a Pic but here it is 
http://cl.ly/242R3J2P231p350U2d0C 

all i could get since it incredbly fast rebooted

Comment 12 by Evan Lojewski, Jul 20, 2011

I've added a check for a register that only exists on revD+ cpus (I 
believe). Let me know if you still have the reboot issue.

Comment 13 by Andy Moa, Jul 20, 2011

All running smooth  thanx alot for this 

here the dmesg http://pastebin.com/Cgy6MaHs

Comment 14 by Andy Moa, Jul 20, 2011

In Addition asoon the FSB gets detected Correct sound is messed up ! 
(like lags)

Comment 15 by Evan Lojewski, Jul 20, 2011

Andy, that's because the legacy kernel multiplies the FSB by two for 
K10s. It was a hack added to work around the bug in chameleon. Now 
that it's fixed, it should be removed from xnu.

Comment 16 by Evan Lojewski, Jul 20, 2011

Would you also chcek the output of the following command in 
terminal:
sysctl -a | grep bus

If *should* match what chameleon states, however it will probably be 
x2.

Comment 17 by Andy Moa, Jul 21, 2011

Here is that Output 

sysctl -a | grep bus
hw.busfrequency = 800000000
hw.busfrequency: 800000000
hw.busfrequency_min: 800000000
hw.busfrequency_max: 800000000

Comment 18 by Andy Moa, Jul 21, 2011

Since without it is only 10000000 on each .does it mean is it only a 
cosmetical  thing or  ..so in other words its useless since everbody 
uses legacy kernel  on amd based system and will get chobby sound 
..just trying to get it

Created: 6 years 5 months ago by Fumo Mofu

Updated: 6 years 4 months ago

Status: Fixed

Owner: Evan Lojewski

Followed by: 2 persons

Labels:
Priority:Medium
Type:Defect
Target:2.0