4 ms·
Not just the abstract machines. CPUs don't guarantee constant-time execution for most instructions. And if you target wasm or some other intermediate compilatio
by the8472 2y ago
Not just the abstract machines. CPUs don't guarantee constant-time execution for most instructions. And if you target wasm or some other intermediate compilation target then the first compiler can't do much about the 2nd compiler applying additional optimizations. And then there are post-link optimizations where any hypothetical "please don't optimize this" annotations would be gone.
- pclmulqdq 2y agoIn a theoretical sense only, that is true on x86 when a flag (that is always set) is not set. The vast majority of useful instructions are constant-time (in the value of the data).
- nullc 2y agoIndeed, but the manufacturer doesn't promise anything-- for all you know the next processor generation or even microcode revision could change that. It would be nice for processor makers to explicitly specify that the common arithmetic instructions will take time which is constant in terms of their argument data.
- pclmulqdq 2y agoThey are explicitly specified by all major CPU vendors. 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...
- nullc 2y agoTIL -- wasn't the case a number of years ago.
- adrian_b 2y agoNowadays the manufacturer must promise that at least a well-defined subset of the instructions have an execution time independent of the operands. See the comment above by "cokernel_hacker", which provides links to the Intel and Arm documentation of this feature.