From: Hongzhan Chen <[email protected]>

Ask for switching back to oob mode once ptrace core tell that
current is resuming from a stopped state, leaving space for
other runnable RT threads of the process to take over.

Signed-off-by: Hongzhan Chen <[email protected]>
[Philippe: added missing dovetail_request_ucall to pipeline_leave_oob_prepare]
Signed-off-by: Philippe Gerum <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
---
 kernel/cobalt/dovetail/kevents.c |  2 ++
 kernel/cobalt/dovetail/sched.c   | 17 +++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/dovetail/kevents.c b/kernel/cobalt/dovetail/kevents.c
index 164ab9461..37ff6ca4b 100644
--- a/kernel/cobalt/dovetail/kevents.c
+++ b/kernel/cobalt/dovetail/kevents.c
@@ -491,6 +491,8 @@ static void handle_ptrace_cont(void)
                        unregister_debugged_thread(curr);
 
                xnthread_set_localinfo(curr, XNHICCUP);
+
+               dovetail_request_ucall(current);
        }
 
        xnlock_put_irqrestore(&nklock, s);
diff --git a/kernel/cobalt/dovetail/sched.c b/kernel/cobalt/dovetail/sched.c
index de7c43b70..074bc006e 100644
--- a/kernel/cobalt/dovetail/sched.c
+++ b/kernel/cobalt/dovetail/sched.c
@@ -56,9 +56,22 @@ int pipeline_leave_inband(void)
 
 int pipeline_leave_oob_prepare(void)
 {
-       dovetail_leave_oob();
+       int suspmask = XNRELAX;
+       struct xnthread *curr = xnthread_current();
 
-       return XNRELAX;
+       dovetail_leave_oob();
+       /*
+        * If current is being debugged, record that it should migrate
+        * back in case it resumes in userspace. If it resumes in
+        * kernel space, i.e.  over a restarting syscall, the
+        * associated hardening will clear XNCONTHI.
+        */
+       if (xnthread_test_state(curr, XNSSTEP)) {
+               xnthread_set_info(curr, XNCONTHI);
+               dovetail_request_ucall(current);
+               suspmask |= XNDBGSTOP;
+       }
+       return suspmask;
 }
 
 void pipeline_leave_oob_finish(void)
-- 
2.26.2


Reply via email to