sel4-capdl-initializer: lazy SC rebind for passive#352
Conversation
Add `fn bind_ntfn` for `SchedContext`. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
7dbba7a to
561c46e
Compare
| if obj.bound_notification().is_none() { | ||
| panic!("A passive task must have its own Notification."); | ||
| } | ||
| let bound_notification_cap = | ||
| self.orig_cap::<cap_type::Notification>(obj.bound_notification().unwrap().object); |
There was a problem hiding this comment.
Use the let/Some destrucuturing (or match) here rather than is_none() and unwrap.
Also, if we do sc.bind_ntfn(), where is that SC from, if not obj.sc() and does that not imply that it is not none?
There was a problem hiding this comment.
sc in this context could be the initialiser's SC or the TCB's SC as created from the spec. Binding the Notification to the initialiser's SC wouldn't make sense so that's why I had the if obj.bound_notification().is_none() check.
There was a problem hiding this comment.
But I'm confused, you then do sc.bind_ntfn(bound_notification_cap)?; next?
There was a problem hiding this comment.
Wait my bad, in the original comment, sc would be either a Null cap or the TCB's SC as created from the spec.
Regardless, the if obj.sc().is_none() { check will make sure that sc is the TCB's SC.
Then bound_notification_cap is the TCB's Notification cap.
There was a problem hiding this comment.
Then I think we should be explicit and use let/Some for that as well instead of using the previous sc.
There was a problem hiding this comment.
Ok sounds good
There was a problem hiding this comment.
I meant bound_sc here on the next line, not still sc. No point unwrapping to an unused var.
Also, I'd suggest using this variant:
let Some(bound_sc) = obj.sc() else {
panic!("blah blah");
}
This removes the nested as you add more checks.
(Also, is panic!() the normal way that you do errors in rust-sel4?)
Implements lazy Scheduling Context rebind for passive tasks inside the capDL initialiser. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
561c46e to
d20b04c
Compare
| #[sel4_cfg(KERNEL_MCS)] | ||
| impl<C: InvocationContext> SchedContext<C> { | ||
| /// Corresponds to `seL4_SchedContext_Bind`. | ||
| pub fn bind_ntfn(self, notification: Notification) -> Result<()> { |
There was a problem hiding this comment.
Could you rename this to sched_context_bind() to match the convention of the file?
Also, while you're at it, could you also rename unbind below to sched_context_unbind()?
|
|
||
| pub master_fault_ep: Option<Word>, | ||
|
|
||
| pub passive: bool, |
There was a problem hiding this comment.
Is this flag necessary? Could we just bind the nfn to the sc whenever a tcb has both a nfn and a sc?
There was a problem hiding this comment.
That seems wrong; an active server would both have a TCB, SC, and a notification but shouldn't have the SC bound to the notification for lazy rebind. Unless you mean something else?
(But yes this would also need changing in the C capDL spec)
There was a problem hiding this comment.
I could've sworn I left another comment but I feel like there should be a way to ask for "SC bound to NTFN" in the spec more generally; which is what this is wanting.
(paasive w/lazy rebind = SC bound to TCB and SC bound to NTFN, and the TCB has ability to block on that notification; no need for an extra passive attribute...)
There was a problem hiding this comment.
How about we give a pub slots: Vec<CapTableEntry> to the NTFN object in the spec, if there is a SC cap in that Vec then do the passive with lazy rebind?
There was a problem hiding this comment.
Surely binding ntfn to SC exists in the capDL spec?
(If not this should also be discussed on the C/Haskell repo as there are other stakeholders here)
There was a problem hiding this comment.
I've made an issue in the C/Haskell repo here: seL4/capdl#96
Implements lazy Scheduling Context rebind for passive tasks inside the capDL initialiser.
Solves problems such as seL4/microkit#91