Why is the x86 undefined instruction called ud2? Why 2?
The x86 undefined instruction "ud2" is called that way because its variant "0F FF" was later retroactively named "ud0", while the variant "0F B9" became "ud1". This naming convention left "ud2" as the recommended undefined opcode. The instruction was originally created to provide a reliable way to trigger an invalid opcode exception, as originally there were no architecturally undefined instructions on x86.
Different factions favored different opcode sequences, such as 0F FF and 0F B9, but both seemed to work equally well. Intel later introduced an official unsupported instruction called ud2 to address this issue. The "2" in ud2 comes from the fact that it was retroactively assigned the value "2" after the 0F FF variant and the 0F B9 variant were named ud0 and ud1, respectively.
One advantage of ud2 is that it is a two-byte instruction without any parameters, avoiding potential issues with decoding and accessing invalid memory pages.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
This story
This is one outlet's version. Read the fullest account.
- Why is the x86 undefined instruction called ud2? Why 2? devblogs.microsoft.com