I've been looking for this for quite some time now, but it seems nobody knows:
How does the BIOS form the brandstring which can be read from the CPU via the cpuid instructions 0x8000002h-0x80000004h?
It must be programable by the BIOS as I've seen BIOSes omitting the model of the CPU and at least for AMD CPUs there are tech docs available to the public describing how to form the brandstring.
For AMD CPUs it works by reading extended cpuid instructions and selecting a particular string (like "AMD Opteron" or "AMD Athlon") and adding the model number based on information gained from the extended cpuid instructions as well.
So what has to be done in a BIOS to form the brandstring for Intel Core CPUs?
I know the brandstring can be written to the CPU with model-specific registers.
PS: I don't want to know how to read the brandstring from within an operating system, I know this works with the cpuid instruction! I really mean forming the brandstring from scratch.
You seem to assume brand string is the results of some buried data in Silicon, massaged by BIOS, and then CPUID reads the messaged output from BIOS...
That doesn't make a lot of sense.
Brand string corresponding to certain set of product features must be invariant, whether it's read by software written by joe or mary, whether the software is executed
a) at the first target address the reset vector
b) when bios gets control of the machine and executes CPUID
c) when OS gets control of the machine and executes CPUID
d) when application executes CPUID
your assumption implies a) and b) do not have the same answer as c) and d).
your assumptions also imply that BIOS could stick the massaged data back into the Si and CPUID would in turn read the massaged data. But BIOS uses the same ISA to talk to CPU as OS and app do. If bios could do that, so could OS and other privileged software alter brand string.
I've got a CPU that returns different brandstrings on different mainboards:
1) "Intel Core2 Quad CPU @ 2.40GHz"
2) "Intel Core2 Quad CPU Q6600 @ 2.40GHz"
So with mainboard 1 the BIOS was unable to identify the model of the CPU ("Q6600") because it was too old.
The brandstring can be modified by the operating system as well, because it is loaded via model specific registers. So theoretically any software that is allowed to write to model-specific registers can alter the brandstring.
The MSRs for this for AMD CPUs are MSR 0xC0010030h-0xC0010035h.
Source: "AMD Processor Recognition", AMD Application Note 20734, rev. 3.12 (released 2004/08).
When turning the computer on, before any intervention of the BIOS, the CPU will most definitely return a string of 48 NULL-characters as brand string.
The only question is how the BIOS forms the brandstring, so I can implement this in my software in order to by-pass faulty or old BIOSes. I already did this for AMD K8 and K10 CPUs, but Intel does not provide any tech docs on this (AMD does however).
And because there are different brandstrings with different mainboards I doubt the brandstring is hard-coded for Intel CPUs.
Sometimes It may be tempting to jump to conclusions...
An engineering sample is not a "product" that a manufacturer sells as a product. So, CPUID may reports a generic description of the enginnering sample via Brand string.
Brand string will report more specific information for a product vs. engineering sample.
These differences are not related to BIOS.
Different mainboards produce different brandstrings for the same CPUs, that's 100% sure. So I still think the brandstring can be programmed.
For AMD CPUs this is definitely true as they have docs on how to do this. It is at least probable that Intel did this in a similar way since there are different outputs for the same CPU and both vendors use the CPUID instruction in a very similar way.
If I recall correctly, AMD CPUs indeed have programmable brand string. Intel CPUs do not.
From my reverse-engineering sessions with BIOS code I can tell you that BIOS will usually first check if CPU brand string feature is supported and use that brand string if it is. If not, it will check the brand ID against the built-in table of known brand IDs, and if brand ID is zero then it will improvise based on family, model and stepping. Not every BIOS has up-to-date tables and code, nor they always use proper detection mechanism — that is the reason why different BIOSes may give different results. I hope this answers your question?