xen: don't longjmp() after domain_crash() in check_wakeup_from_wait()
PATCH 1/1 xen: don't longjmp() after domain_crash() in check_wakeup_from_wait()
Continuing on the stack saved by __prepare_to_wait() on the wrong cpu is rather dangerous.
Instead of doing so just call the scheduler again as it already is happening in the similar case in __prepare_to_wait() when doing the setjmp() would be wrong.
--- xen/common/wait.c | 5 +++++ 1 file changed, 5 insertions(+)
xen/common/wait.c +5 -0
@@ -196,6 +196,11 @@ void check_wakeup_from_wait(void) {gdprintk (XENLOG_ERR ,"vcpu affinity lost\n" );domain_crash (curr->domain); + +/* Re-initiate scheduler and don't longjmp(). */ +raise_softirq (SCHEDULE_SOFTIRQ ); +for ( ; ; ) +do_softirq (); }/*
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines · Juergen Gross
Continuing on the stack saved by
__prepare_to_wait()on the wrong cpu is rather dangerous.Instead of doing so just call the scheduler again as it already is happening in the similar case in
__prepare_to_wait()when doing thesetjmp()would be wrong.Signed-off-by Juergen Gross <[email protected]>
I'm afraid this is still problematic. By successfully invoking the waitqueue, we know that no spinlocks were held, but we have no guarantee that e.g. an xmalloc()'d pointer is still only stashed in the stack.
The original behaviour of this code, on discovering a mismatched affinity, was to set the affinity back to what it should be and try again. The purpose of this is to try and ensure that we (eventually) can successfully longjmp() and unwind the stack.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Juergen Gross
Continuing on the stack saved by
__prepare_to_wait()on the wrong cpu is rather dangerous.Instead of doing so just call the scheduler again as it already is happening in the similar case in
__prepare_to_wait()when doing thesetjmp()would be wrong.
Quoted 5 lines
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>I'm afraid this is still problematic. By successfully invoking the waitqueue, we know that no spinlocks were held, but we have no guarantee that e.g. an xmalloc()'d pointer is still only stashed in the stack.
But how are the domain_crash() invocations with following do_softirq() calls in the __prepare_to_wait() case fine then? At the place where either doing setjmp() or longjmp() it should be okay to throw away the current stack, or otherwise there would be inconsistencies.
So either there is already a problem in the code regarding how the domain crashing is done in __prepare_to_wait(), or my solution is just fine, as it is just expanding the current behavior.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Juergen Gross
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Juergen Gross
Continuing on the stack saved by
__prepare_to_wait()on the wrong cpu is rather dangerous.Instead of doing so just call the scheduler again as it already is happening in the similar case in
__prepare_to_wait()when doing thesetjmp()would be wrong.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>I'm afraid this is still problematic. By successfully invoking the waitqueue, we know that no spinlocks were held, but we have no guarantee that e.g. an xmalloc()'d pointer is still only stashed in the stack.
But how are the
domain_crash()invocations with followingdo_softirq()calls in the__prepare_to_wait()case fine then?
You make a very good point.
Seeing as this patch returns it to "no worse than before", and this code isn't long for the world anyway, Reviewed-by: Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel