IA32
Mark Hobley IA32
WHAT IS BAD ABOUT CPUID

What is cpuid?

The cpuid instruction is a processor supplementary instruction introduced onto certain processors within the x86 family.

What is wrong with using cpuid?

The problem with using cpuid is that it may be used by programs to execute different instructions on different computers. This may lead to differences in behaviour on supposedly compatible machines. The problem with using cpuid for decision making, is that you can potentially have binary code that tests ok on one computer, but behaves differently on another. There are a whole lot of headaches relating to this, especially in organizations that have different processors in different machines, but the machines are all supposed to be compatible with each other. Look at this familar looking example:

if cpuid="Microsoft Sales Laptop" then
crashes=minimal # except when bill gates is on television
else
# end users machine
random_crash(with_blue_screen_of_death)
endif

A better methodology

Allow compilation decisions to be made based on the target architecture

66
"If you know what your platform is, platform feature detection is a waste of code" - Andi Kleen, Suse Laboratories

A better design would be to let the system builder decide which branch is to be used at compile time:

Do you want to build in the random crash feature [Y/n/?]

This technique would enable all machines to run the same code.

The GNU operating system

The GNU operating system currently causes compilation decisions to made based on specifics of the build machine, rather than the generic IA32 target for which the software is aimed. Making compilation decisions based on build machine specifics is just a bad idea.


Alternative ways of supporting different generations of computer

© Copyright 2009 Mark Hobley