4 ms·
Most architectures have a subset of their instructions that can be called in constant time (constant time meaning data-independent time). Things like non-consta
by pclmulqdq 2y ago
Most architectures have a subset of their instructions that can be called in constant time (constant time meaning data-independent time). Things like non-constant pointer loads and branches are obviously out, and so are div/mod in almost all chips, but other arithmetic and conditional moves are in that set.
CPUs are actually much better at making those guarantees than compilers are.
- rbanffy 2y agoIf you tell the compiler, it can generate code with only those instructions.
- ynik 2y agoThat's no longer true: https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/best-practices/data-operand-independent-timing-isa-guidance.html https://www.intel.com/content/www/us/en/developer/articles/t... x86 hardware does not guarantee anything unless you enable "Data Operand Independent Timing Mode", which is disabled by default and AFAIK can only be enabled by kernel-level code. So unless operating systems grow new syscalls to enable this mode, you're just out of luck on modern hardware.
- pclmulqdq 2y agoIn the most purely theoretical sense, you are correct, but everything Intel and AMD has said indicates they will still offer strong guarantees on the DOIT instructions: https://lore.kernel.org/all/851920c5-31c9-ddd9-3e2d-57d379aa0671@intel.com/ https://lore.kernel.org/all/851920c5-31c9-ddd9-3e2d-57d379aa... In other words, they have announced the possibility of breaking that guarantee years before touching it, which is something the clang developers would never do.