TLDR Tech / Practical
Conditional Branching Introduced by Compilers in Branch-Free Code
The author discusses how contemporary compilers, such as LLVM and GCC, can inadvertently insert conditional branches into code intended to be branch-free and constant-time on processors like RISC-V. Although operations like bitwise selections, 128-bit additions, and comparisons are implemented without explicit branching instructions, compiler optimizations may add branches, creating potential security risks through side channels. The article explores mitigation strategies, including the use of register barriers and the forthcoming RISC-V Zicond extension, to ensure code remains truly free of branches.
Read the full story