4 ms·
> You need a language where you can express what you actually meant, which in this case is "Perform this constant time operation". Having expressed what you mea
by eschneider 2y ago
> You need a language where you can express what you actually meant, which in this case is "Perform this constant time operation". Having expressed what you meant, now everybody between you and the hardware can co-operate to potentially deliver that.
Yeah, even with assembly, your timing guarantees are limited on modern architectures. But if you REALLY need something specific from the machine, that's where you go.
- pjmlp 2y agoAnd besides, Assembly should not be a scary thing. Even most managed languages provide a way to get down into Assembly dumps from their AOT and JIT compiler toolchains. Maybe we need some TikTok videos showing how to do such workflows.
- eschneider 2y agoThere's nothing terribly difficult to writing specific routines in asm. It's kinda fun, actually. Assembly _in the large_ is hard, just because you need to be next-level organized to keep things from being a mess.
- rbanffy 2y agoI find it rather easy as long as you don’t have to interact with the OS. That’s where it becomes messy, with inflexible data structures and convoluted arguments in ABIs designed to be used from higher level languages. If you are doing really low level stuff, sometimes it’s worth rolling out your own little RTOS with just the bits and pieces you need. Not that long ago, I realised most 8-bit (and MS-DOS) computer games had their own RTOS woven into the game code, with multi-tasking, hardware management, IO, and so on.
- eschneider 2y agoYeah...Old 8-bit computers didn't exactly have any OS services. :)
- rbanffy 2y agoSome very minimal things such as reading or writing to disk or files, reading the keyboard, or other very simple activities
- pclmulqdq 2y agoMost 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.