Merge Slite with main branch, for discussion.#445
Merge Slite with main branch, for discussion.#445WenyuanShao wants to merge 7 commits intogwsystems:mainfrom
Conversation
* Have SCB capability and resource working. * TODO: DCB capabilities to work. * TODO: Fix the API around SCB frontier. * SCB address in a component will be the start of the heap pointer and the INIT DCB (initial dcb caps that are used when creating the INIT threads in those components) are next to SCB and statically set to be NUM_CPU number of pages. This is the idea to fix their addresses and avoid passing in component_information structure.
gparmer
left a comment
There was a problem hiding this comment.
I'm posting this for now. Still working my way through. You did a very good job pulling this out. I'm mainly providing context, and provide you feedback for where areas of concern might be. Think of this as stream-of-consciousness, not as having very actionable feedback.
| asndcap_t capmgr_asnd_key_create(cos_channelkey_t key); | ||
| asndcap_t COS_STUB_DECL(capmgr_asnd_key_create)(cos_channelkey_t key); | ||
|
|
||
| int capmgr_thd_migrate(thdid_t tid, thdcap_t tc, cpuid_t core); |
There was a problem hiding this comment.
Yikes. Not sure we have this at all. Might be dead code?
| } | ||
|
|
||
| COS_CLIENT_STUB(thdcap_t, capmgr_initthd_create, spdid_t child, thdid_t *tid) | ||
| COS_CLIENT_STUB(thdcap_t, capmgr_thd_retrieve, spdid_t child, thdid_t tid, thdid_t *inittid) |
There was a problem hiding this comment.
If we can avoid pulling this in, we want to. Not a high priority though. Might want to add to the list of "fix later" if we have to pull it in.
|
|
||
| ret = cos_sinv_2rets(uc->cap_no, child, idx, 0, 0, &tid_ret, &unused); | ||
| ret = cos_sinv_2rets(uc->cap_no, id, 0, 0, 0, &tid_ret, &dcb_ret); | ||
| *dcb = &dcb_ret; |
There was a problem hiding this comment.
Isn't this completely broken? We cannot return the address of a stack allocated value.
I'm worried that we aren't getting a compiler warning due to this.
| thdcap_t ret; | ||
|
|
||
| ret = cos_sinv_2rets(uc->cap_no, child, idx, 0, 0, &tid_ret, &dcb_ret); | ||
| *dcb = &dcb_ret; |
| aep->tc = (tcrcvret >> 16); | ||
| aep->tid = tid; | ||
|
|
||
| *dcb = &dcb_ret; |
There was a problem hiding this comment.
I have no understanding of why this is working!
|
|
||
| static inline int | ||
| sl_thd_activate(struct sl_thd *t, sched_tok_t tok) | ||
| sl_thd_activate(struct sl_thd *t, sched_tok_t tok, tcap_time_t timeout) |
There was a problem hiding this comment.
Confused by the timeout here. We'll see where thaht goes.
| } | ||
| } | ||
|
|
||
| static inline int |
There was a problem hiding this comment.
Yeah, this is the core of the logic for slite. This is very very delicate, and we'll want to try and change it as little as possible. Phani took a lot of time on this, and I completely trust his judgement for where it ended up.
There was a problem hiding this comment.
...of course, we'll need to update for x86-64, and provide a default version that always uses the slowpath for architectures for which we don't have a fastpath.
| sl_thd_aep_alloc_ext(struct cos_defcompinfo *comp, struct sl_thd *sched_thd, thdclosure_index_t idx, int is_aep, int own_tcap, cos_channelkey_t key, microsec_t ipiwin, u32_t ipimax, arcvcap_t *extrcv) | ||
| sl_thd_aep_alloc_ext_dcb(struct cos_defcompinfo *comp, struct sl_thd *sched_thd, thdclosure_index_t idx, int is_aep, int own_tcap, cos_channelkey_t key, dcbcap_t dcap, dcboff_t doff, microsec_t ipiwin, u32_t ipimax, arcvcap_t *extrcv) | ||
| { | ||
| PRINTC("UNIMPLEMENTED: Using CAPMGR API which should manage the DCB capabilities\n"); |
There was a problem hiding this comment.
You pointed these out before. We'll certainly want to invert the logic. The capmgr should manage the scb/dcbs, and the backend should be easier to integrate with slm
| sl_cs_exit(); | ||
| } | ||
|
|
||
| int |
There was a problem hiding this comment.
I don't think that we'll find much use for all of this migration complexity. It spans most of the abstraction layers.
| #include "include/hw.h" | ||
| #include "include/chal/chal_proto.h" | ||
| #include "include/scb.h" | ||
| //#include "include/dcb.h" |
There was a problem hiding this comment.
if you can, take the opportunity to clean up stuff like this.
gparmer
left a comment
There was a problem hiding this comment.
OK, made it through. Some additional thoughts.
| sz = __captbl_cap2bytes(type); | ||
|
|
||
| /* don't allow cap copy on SCB/DCB */ | ||
| if (type == CAP_SCB || type == CAP_DCB) return -EINVAL; |
There was a problem hiding this comment.
Oh, wow, so no delegation at all for these. OK, somewhat surprising. Likely to keep things simple.
| * The rest is all co-operative, so if sched_tok in scb page | ||
| * increments after someone fetching a tok, then check for that! | ||
| * | ||
| * FIXME: make sure we're checking the scb of the scheduling component and not in any other component. |
There was a problem hiding this comment.
this is a worrisome comment
|
|
||
| if (thd_cap->cpuid != get_cpuid() || thd_cap->cpuid != next->cpuid) return -EINVAL; | ||
| if (unlikely(thd->dcbinfo && thd->dcbinfo->sp)) { | ||
| assert((unsigned long)regs->cx == thd->dcbinfo->ip + DCB_IP_KERN_OFF); |
There was a problem hiding this comment.
These are fine for debugging, but have to go after we get it to work. User-level can cause the kernel to crash trivially with these.
| ret = cap_kmem_activate(ct, ptcap, kaddr, (unsigned long *)&dcb, &pte); | ||
| if (ret) cos_throw(err, ret); | ||
|
|
||
| ret = dcb_activate(ct, cap, dcbcap, (vaddr_t)dcb, lid, ptcapin, uaddrin); |
There was a problem hiding this comment.
OK, great, they are both allocated as kernel memory. DCB is mapped into memory at creation time as well (uaddrin).
|
|
||
| return 0; | ||
|
|
||
| /*undo_scb: |
| BOOT_CAPTBL_SINV_CAP = 32, | ||
| BOOT_CAPTBL_SELF_INITHW_BASE = 36, | ||
| BOOT_CAPTBL_SELF_INITTHD_BASE = 40, | ||
| BOOT_CAPTBL_SELF_SCB = 36, /* FIXME: Do we need this? */ |
There was a problem hiding this comment.
Hope you were very careful when merging these!
src/kernel/include/thd.h
Outdated
| thd_scheduler_set(thd, thd_current(cli)); | ||
|
|
||
| thd_rcvcap_init(thd); | ||
| /* TODO: fix the way to specify scheduler in a component! */ |
There was a problem hiding this comment.
This whole thing with init_data feels like a hack that might cause us headaches. Better ideas?
| memcpy(&curr->regs, regs, sizeof(struct pt_regs)); | ||
| } | ||
|
|
||
| static int |
There was a problem hiding this comment.
We didn't talk about all of this. The SCB is also used to send interrupt events up to user-level now.
Summary of this Pull Request (PR)
Add description here.
Intent for your PR
Choose one (Mandatory):
Reviewers (Mandatory):
(Specify @<github.com username(s)> of the reviewers. Ex: @user1, @user2)
Code Quality
As part of this pull request, I've considered the following:
Style:
Code Craftsmanship:
Testing
I've tested the code using the following test programs (provide list here):