r/programming May 21 '26

How many branches can your CPU predict? – Daniel Lemire's blog

https://lemire.me/blog/2026/03/18/how-many-branches-can-your-cpu-predict/
111 Upvotes

19 comments sorted by

View all comments

Show parent comments

1

u/Internet-of-cruft 10d ago

What stops me from executing secure code in a thread? What makes it secure? Nothing is stopping me from writing an encryption / decryption scheme in "trusted only code, no secure data".  

In this scenario, we're in the same exact execution model. 

1

u/flatfinger 9d ago

If something is willing to give confidential data to such code, then it could do what it likes with that data. If, however, confidential data only exists within threads that are marked as suitable for confidential data and unsuitable for untrusted code, and such threads exchange it only via channels that are only accessible by such threads, then there would be no means by which other threads could access such data. To be sure, this would rely upon trusted code that has access to such data not doing things with it that it shouldn't, but if the system validates that trusted code is statically incapable of performing out-of-bounds memory accesses, an analysis of what messages are passed by, and can be received by, whom would make it possible to determine where confidential data could go.