xen/wait: Describe RSB safety
PATCH 1/1 xen/wait: Describe RSB safety
It turns out that we do in fact have RSB safety here, but not for obvious reasons.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/common/wait.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
xen/common/wait.c +20 -0
@@ -210,6 +210,26 @@ void check_wakeup_from_wait(void) }/* +* We are about to jump into a deeper call tree. In principle, this risks +* executing more RET than CALL instructions, and underflowing the RSB. +* +* However, we are pinned to the same CPU as previously. Therefore, +* either: +* +* 1) We've scheduled another vCPU in the meantime, and the context +* switch path has (by default) issued IPBP which flushes the RSB, or +* +* 2) We're still in the same context. Returning back to the deeper +* call tree is resuming the execution path we left, and remains +* balanced as far as that logic is concerned. +* +* In fact, the path though the scheduler will execute more CALL than +* RET instructions, making the RSB unbalanced in the safe direction. +* +* Therefore, no actions are necessary here to maintain RSB safety. +*/ + +/* * Hand-rolled longjmp(). * * check_wakeup_from_wait() is always called with a shallow stack,
Signature · 1 line
2.11.0
Quoted 4 lines · Andrew Cooper
It turns out that we do in fact have RSB safety here, but not for obvious reasons.
Signed-off-by Andrew Cooper <[email protected]>
preferably with ...
Quoted 4 lines
xen/common/wait.c +0
-0@@ -210,6 +210,26 @@ void check_wakeup_from_wait(void) }
xen/common/wait.c void check_wakeup_from_wait(void) · line 220
Quoted 10 lines
xen/common/wait.c +8
-0/* +* We are about to jump into a deeper call tree. In principle, this risks +* executing more RET than CALL instructions, and underflowing the RSB. +* +* However, we are pinned to the same CPU as previously. Therefore, +* either: +* +* 1) We've scheduled another vCPU in the meantime, and the context +* switch path has (by default) issued IPBP which flushes the RSB, or
... IBPB used here and ...
xen/common/wait.c void check_wakeup_from_wait(void) · line 226
Quoted 5 lines
xen/common/wait.c +5
-0+* 2) We're still in the same context. Returning back to the deeper +* call tree is resuming the execution path we left, and remains +* balanced as far as that logic is concerned. +* +* In fact, the path though the scheduler will execute more CALL than
... (nit) "through" used here.
Quoted 9 lines
xen/common/wait.c +6
-0+* RET instructions, making the RSB unbalanced in the safe direction. +* +* Therefore, no actions are necessary here to maintain RSB safety. +*/ + +/* * Hand-rolled longjmp(). * * check_wakeup_from_wait() is always called with a shallow stack,
Quoted 24 lines · Jan Beulich
Quoted 4 lines · Andrew Cooper
It turns out that we do in fact have RSB safety here, but not for obvious reasons.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>preferably with ...
Quoted 4 lines
xen/common/wait.c +0
-0@@ -210,6 +210,26 @@ void check_wakeup_from_wait(void) }xen/common/wait.c void check_wakeup_from_wait(void) · line 220
Quoted 10 lines
xen/common/wait.c +8
-0/* +* We are about to jump into a deeper call tree. In principle, this risks +* executing more RET than CALL instructions, and underflowing the RSB. +* +* However, we are pinned to the same CPU as previously. Therefore, +* either: +* +* 1) We've scheduled another vCPU in the meantime, and the context +* switch path has (by default) issued IPBP which flushes the RSB, or ... IBPB used here and ...
Quoted 6 lines
xen/common/wait.c void check_wakeup_from_wait(void) · line 226
Quoted 5 lines
xen/common/wait.c +5
-0+* 2) We're still in the same context. Returning back to the deeper +* call tree is resuming the execution path we left, and remains +* balanced as far as that logic is concerned. +* +* In fact, the path though the scheduler will execute more CALL than ... (nit) "through" used here.
Wow I failed at writing... Fixed.
~Andrew
Quoted 10 lines
Quoted 10 lines
xen/common/wait.c +6
-0+* RET instructions, making the RSB unbalanced in the safe direction. +* +* Therefore, no actions are necessary here to maintain RSB safety. +*/ + +/* * Hand-rolled longjmp(). * * check_wakeup_from_wait() is always called with a shallow stack,