setup child vspace

This commit is contained in:
Aurel Feer 2022-03-22 22:36:38 +01:00
parent e5632b050f
commit c83edbb696
2 changed files with 29 additions and 12 deletions

View File

@ -48,7 +48,9 @@ struct spawninfo {
struct capref cspace_cap_dispatcher; // < Contains the dispatcher capability.The dispatcher is the equivalent of a “Process Control Block” in other operating systems. You can create one using dispatcher_create(...); struct capref cspace_cap_dispatcher; // < Contains the dispatcher capability.The dispatcher is the equivalent of a “Process Control Block” in other operating systems. You can create one using dispatcher_create(...);
struct capref cspace_cap_rootcn; // < Contains a capability for the root (L1) CNode. struct capref cspace_cap_rootcn; // < Contains a capability for the root (L1) CNode.
struct capref cspace_cap_dispframe; // < A capability to the dispatcher frame, used to communicate between a process and the CPU driver. struct capref cspace_cap_dispframe; // < A capability to the dispatcher frame, used to communicate between a process and the CPU driver.
struct capref cspace_cap_argspage; // < A page containing a list of command line ar- guments. struct capref cspace_cap_argspage; // < A page containing a list of command line arguments.
struct capref vspace_cap_l0_pagetable;
}; };
// Start a child process using the multiboot command line. Fills in si. // Start a child process using the multiboot command line. Fills in si.

View File

@ -148,9 +148,10 @@ errval_t spawn_load_argv(int argc, char *argv[], struct spawninfo *si,
// - Setup the child's cspace // - Setup the child's cspace
// afeer: script page 84/85 // afeer: script page 84/85
cnode_create_l1(&si->cspace_l1_cnode_cap, &si->cspace_l1_cnode_info); err = cnode_create_l1(&si->cspace_l1_cnode_cap, &si->cspace_l1_cnode_info);
if (err_is_fail(err)) return err;
cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_TASKCN, &si->cspace_l2_cnode_taskcn); err = cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_TASKCN, &si->cspace_l2_cnode_taskcn);
if (err_is_fail(err)) return err;
// afeer: (script page 84) is this correct? // afeer: (script page 84) is this correct?
si->cspace_cap_selfep.cnode = si->cspace_l2_cnode_taskcn; si->cspace_cap_selfep.cnode = si->cspace_l2_cnode_taskcn;
@ -168,18 +169,32 @@ errval_t spawn_load_argv(int argc, char *argv[], struct spawninfo *si,
si->cspace_cap_argspage.cnode = si->cspace_l2_cnode_taskcn; si->cspace_cap_argspage.cnode = si->cspace_l2_cnode_taskcn;
si->cspace_cap_argspage.slot = TASKCN_SLOT_ARGSPAGE; si->cspace_cap_argspage.slot = TASKCN_SLOT_ARGSPAGE;
cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_SLOT_ALLOC0, &si->cspace_l2_cnode_slot_alloc_0); err = cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_SLOT_ALLOC0, &si->cspace_l2_cnode_slot_alloc_0);
cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_SLOT_ALLOC1, &si->cspace_l2_cnode_slot_alloc_1); if (err_is_fail(err)) return err;
cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_SLOT_ALLOC2, &si->cspace_l2_cnode_slot_alloc_2); err = cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_SLOT_ALLOC1, &si->cspace_l2_cnode_slot_alloc_1);
cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_BASE_PAGE_CN, &si->cspace_l2_cnode_base_pagecn); if (err_is_fail(err)) return err;
cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_PAGECN, &si->cspace_l2_cnode_pagecn); // < afeer: TODO: script page 85: fill this with pagetable capabilities err = cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_SLOT_ALLOC2, &si->cspace_l2_cnode_slot_alloc_2);
if (err_is_fail(err)) return err;
err = cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_BASE_PAGE_CN, &si->cspace_l2_cnode_base_pagecn);
if (err_is_fail(err)) return err;
err = cnode_create_foreign_l2(si->cspace_l1_cnode_cap, ROOTCN_SLOT_PAGECN, &si->cspace_l2_cnode_pagecn);
if (err_is_fail(err)) return err;
// afeer: populate some capabilities // afeer: populate some capabilities
dispatcher_create(si->cspace_cap_dispatcher); err = dispatcher_create(si->cspace_cap_dispatcher);
cap_retype(si->cspace_cap_selfep, si->cspace_cap_dispatcher, 0, ObjType_EndPointLMP, 0, 1); if (err_is_fail(err)) return err;
err = cap_retype(si->cspace_cap_selfep, si->cspace_cap_dispatcher, 0, ObjType_EndPointLMP, 0, 1);
if (err_is_fail(err)) return err;
// - Setup the child's vspace // - Setup the child's vspace
// TODO // afeer: create level 0 page table
// the l0 page table is in the first slot of the pagecn cnode.
// lower-level pagetables and mappings are stored on different slots of the pagecn cnode.
si->vspace_cap_l0_pagetable.cnode = si->cspace_l2_cnode_pagecn;
si->vspace_cap_l0_pagetable.slot = PAGECN_SLOT_VROOT;
err = vnode_create(si->vspace_cap_l0_pagetable, ObjType_VNode_AARCH64_l0);
if (err_is_fail(err)) return err;
// - Load the ELF binary // - Load the ELF binary
struct allocate_state st = {}; struct allocate_state st = {};