I've tried to identify which UEFI modules make use of cpuid to fork code depending on cpu model. Problem is that the cpuid instruction is also used to query processor features, so it is widely used inside a lot of uefi modules.
Anyway, I've not found many modules where code is forked depending on cpu model, for most part the Apple bios assumes the cpu is Sandy Bridge and forks code depending on cpu features, that should not be a problem for Ivy Bridge which is very similar to SB regarding features.
The module I think it's causing the iMac not to boot Ivy Bridge is the
MemoryInit module.
On Sandy Bridge and Ivy Bridge architectures, the Memory Controller is integrated into the CPU:
So RAM is connected straight to the CPU Integrated Memory Controller (IMC). That RAM must be recognized and initialized earliest on the PEI phase by the CPU System Agent.
Taking a look at how this is done on Intel reference code we see it is done with different code depending on CPU stepping (last digit of cpuid).
Steppings for Sandy Bridge are defined as:
and mapped to an enum:
using this code:
A Sandy Bridge i7-2600 with cpuid 0x206a7 (stepping 7) will be assigned "csD2".
Back to the Apple bios, the mapping code is very similar. It lacks the debug and error features, so code will not stop execution, but a 3770 Ivy Bridge with cpuid 0x306a9 (stepping 9) will be assigned the "
csUnknow" stepping.
Ivy Bridge steppings are different from Sandy Bridge:
Later, ram initialization code gets very complex and undocumented, but there are many memory configuration sections that get executed conditionally depending on cpu stepping:
So, memory initialization for Ivy Bridge will not work on the iMac 2011 Apple bios, and I think most probably is the cause of not booting.
Possible fixes would be:
- patch module to force all cpus to be recognized as Sandy Bridge stepping 7 and hope it works (no idea, since memory controller features are undocumented)
- try to replace module for that of an Ivy Bridge bios (need to have same dependencies).
Not an easy task...
As a bonus, having real Ivy Bridge MemoryInit working would allow higher ram speed (1600 MHz) and lower voltage (1.35v) ram to be used on the iMac.
Edit: Another possible source of conflict may be the PEI Function to initialize the PciExpress bus, as Ivy Bridge supports PCIe 3.0. This is pending to be researched.