by codeflo · 2y ago · 0 comments
Modern CPUs add complications to arguments like this. Branches stall the execution pipeline, so branch prediction was invented to keep the pipeline flowing. Return instructions are perfectly predicted, which makes them literally free. At the very least, any alternate return scheme has to pay for a full misprediction. That can be expensive.
The RSB has 10 or so entries and it is in the critical path, while the integrity stack might be larger and have less strict performance characteristics, so they might be separate objects.
Is that even true if an interrupt triggers after the return instruction prediction?
CALL
jump-without-RET
and the calls and the rets don’t line up. This defeats the return prediction on the next return.All of the interaction between a million caches, predictor, instruction parallelism, different cpus, different code etc. feels like it is impossible to reason about it
First explanation I found on Google. Haven't read it:
As long as you don't overwrite the return address on the stack.