News for hackers. Stuff that matters.
Re:The cpu_features library by jcranmer on Wednesday February 07, 2018 @05:14PM (#16328502)
The complex CPUID instruction is, to my knowledge, unique to x86 processors. The equivalents for other processors are essentially special machine status registers that set bits appropriately.

The main reason that these are privileged is probably because:

a) The main use of these is checking if you've got floating-point and/or vector unit support. This support requires the OS to know about this information anyways (imagine if your OS didn't bother to save/restore these registers on context switches!), so making the OS check this information is not difficult.

b) There's generally already a fairly generic mechanism for stuffing OS-level special-purpose registers that's fairly unbounded in size, so it's essentially free to add an addressing of these specific registers in that mode. Making some of these registers be legal in user-space code is more expensive in hardware size and complexity, and (as mentioned earlier) the OS has to be modified anyways to take advantage, so requiring the OS to report these details to userspace code isn't problematic.

c) For RISC processors, you've generally got a fairly full opcode space anyways. Taking up an opcode for a very niche functionality that isn't particularly necessary isn't a good use of scarce extra space.

There are no comments on this comment yet.