microkit_pd_stop()/microkit_pd_resume() behavior
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- rust
- Domain
- operating-systems
Research direction
Start by reviewing the microkit_pd_stop()/microkit_pd_resume() wrappers and Monitor's passive-PD request handling, then compare them with seL4_TCB_Suspend/seL4_TCB_Resume semantics. Check both the schedContext-less TCB case and replayed requests while a passive transition is pending. Done should be an agreed behavior with corresponding handling or documentation.
Written by the indexing model from the issue text.
Description
seL4's seL4_TCB_Suspend/seL4_TCB_Resume (which are invoked by the thin microkit wrappers) implicitly assumes a normal case: an SC bound to the TCB that is being suspended. From our reading of the kernel source:
suspend()unconditionally dequeues the thread and setsThreadState_Inactive, with no special handling for a notification-bound SC.restart()setsThreadState_Restart, but only actually reschedules the thread ifisSchedulable()— which requirestcbSchedContext != NULL.
The result is that a passive PD (tcbSchedContext==NULL) remains permanently unrunnable.
From the kernel perspective, given its overall minimalist philosophy, this seems like reasonable behavior: a TCB and its SC are just two independent objects that just happen to usually be bound together and the result is well-defined in either case. [I would suggest, however, that seL4_TCB_Resume's manual/spec document the schedContext-less-TCB case, where success is returned but the thread is never again scheduled.]
Whether this is desirable behavior from microkit's perspective I think could be reasonably argued either way. But passive PDs are microkit abstractions so it definitively involves, at a minimum, a gap in the documentation. Using microkit_pd_stop()/microkit_pd_resume() is unsafe once Monitor has made the PD passive. The passive PD will never be scheduled to run again, yet no error is ever indicated.
I will add here that there can be a secondary issue. If the timing is right, a seL4_TCB_Suspend may hit a passive PD during its 'Please make me passive' request to the Monitor. If the request has been sent but has not been responded to yet (i.e., the passive PD is in blocked waiting on the reply) and a seL4_TCB_Resume is issued to the passive PD, then seL4 semantics are to replay the entire system call. This results in a second message being sent to the Monitor. Monitor handles both messages unconditionally by attempting to do a seL4_SchedContext_Bind. The second message results in seL4 issuing a TCB already bound error message, and microkit also issuing a "MON|ERROR: could not bind scheduling context to notification object" message.
- Dominant language
- Rust
- Stars
- 201
- Forks
- 80
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from seL4/microkit
-
Difficulty 2/5 Half a day Newbie friendliness 72/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100