Hacker News new | ask | show | jobs
by dougall 1386 days ago
This header works with standard Xcode/macOS, by taking advantage of inline assembly in a slightly-cursed way (turning register names into numbers and encoding the instruction itself).
1 comments

Slightly cursed is how I roll. I would like to know where the trick first originated from though (I found it at https://github.com/yvt/amx-rs/blob/main/src/nativeops.rs#L22 rather than inventing it de novo)
This happens often in the Linux kernel to continue to support older assemblers for newer instruction set extensions.

The x86 retbleed mitigation uses .inst to trick the hardware instruction decoder...different instructions are encoded/run than what is speculatively decoded.