Alex Ionescu wrote:
If you have a "nop" by default, then your
job is as follows:
- Detect support for the instruction
- If it's NOT supported, overwrite with ret.
Additionnally, the default state of the function is to WORK, which
fundamentally speaking is wrong because you're assuming that the
advanced functionality exists, and then you're disabling it. Since
you're trying to be safe, then the whole point is to protect from the
potential BSOD.
However, with a "ret" by default, you only overwrite with nop if the
instruction IS supported. Apart from the design issue itself, I think
the premise here is that more CPUs don't have the support for the
function, then the ones that do.
That depends on whether the machine supports it or not, it's not a
general optimization. But you made it sound like one ;)
- Thomas