Uh oh!
There was an error while loading. Please reload this page.
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Implements safe wrappers for the `cmovz` and `cmovnz` instructions which work on `x86` and `x86_64`, implemented using inline assembly. Using inline assembly allows us to provide a sort of black box which LLVM will not interfere with, which is otherwise problematic when using anything besides ASM. It's otherwise not possible to correctly emit CMOV instructions on x86 platforms with LLVM because the `x86-cmov-conversion` pass which will potentially rewrite them as branches. For more details, see: https://dsprenkels.com/cmov-conversion.html
Adds a fallback implementation based on bitwise arithmetic, which allows the crate to work on any target architecture. Unfortunately, this implementation cannot guarantee constant-time operation in the same way as dedicated instructions are able to.
Uh oh!
There was an error while loading. Please reload this page.
Went ahead and added a portable fallback implementation for non-x86/x86_64 platforms in 5dfbdca with optimizations in 876653d which uses bitwise arithmetic but can't otherwise specifically guarantee constant-time operation. I think it's nice to have from an ergonomics perspective, even if we can't make guarantees. We could potentially add some tests that automatically inspect the generated assembly and make sure the generated instructions fall within a particular allow list. That'd provide a degree of due diligence that the resulting implementation is constant time, if not a guarantee. |
Implements safe wrappers for the
cmovzandcmovnzinstructions which work onx86andx86_64, implemented using inline assembly.Using inline assembly allows us to provide a sort of black box which LLVM will not interfere with, which is otherwise problematic when using anything besides ASM.
It's otherwise not possible to correctly emit CMOV instructions on x86 platforms with LLVM because the
x86-cmov-conversionpass which will potentially rewrite them as branches.For more details, see:
https://dsprenkels.com/cmov-conversion.html