1.1 --- a/libexec/lib/src/process.cc Thu Mar 23 15:42:39 2023 +0100
1.2 +++ b/libexec/lib/src/process.cc Fri Mar 24 00:46:26 2023 +0100
1.3 @@ -67,7 +67,6 @@
1.4 _env.log = L4_BASE_LOG_CAP;
1.5 _env.scheduler = L4_BASE_SCHEDULER_CAP;
1.6 _env.mem_alloc = L4_EXEC_MA_CAP;
1.7 - _env.parent = L4_EXEC_PARENT_CAP;
1.8
1.9 /* Capability details that are updated for each thread. Note that the region
1.10 mapper is redefined, but it would traditionally employ the given index. */
1.11 @@ -156,10 +155,10 @@
1.12 return map_capabilities(mapped_caps, false);
1.13 }
1.14
1.15 -/* Configure the thread environment, employing the given capability for the
1.16 - region mapper, returning its capability details in the new task. */
1.17 +/* Set the pager/region mapper of the new thread, using the given capability,
1.18 + returning its capability details in the new task. */
1.19
1.20 -long Process::configure_thread(l4_cap_idx_t rm, l4_cap_idx_t *mapped_rm)
1.21 +long Process::set_pager(l4_cap_idx_t rm, l4_cap_idx_t *mapped_rm)
1.22 {
1.23 /* Employ a distinct region mapper for each thread's environment, this acting
1.24 as pager. */
1.25 @@ -173,16 +172,28 @@
1.26 {
1.27 _env.rm = allocate_cap();
1.28 *mapped_rm = _env.rm;
1.29 - return ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.rm, rm, L4_CAP_FPAGE_RWS, 0});
1.30 + return ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.rm, rm,
1.31 + L4_CAP_FPAGE_RWS, L4_FPAGE_C_OBJ_RIGHTS});
1.32 }
1.33 }
1.34
1.35 -/* Set the parent of the new thread. */
1.36 +/* Set the parent of the new thread, using the default parent capability index
1.37 + if no mapped capability is provided. */
1.38
1.39 long Process::set_parent(l4_cap_idx_t parent, l4_cap_idx_t *mapped_parent)
1.40 {
1.41 - *mapped_parent = _env.parent;
1.42 - return ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.parent, parent, L4_CAP_FPAGE_RWS, 0});
1.43 + if ((mapped_parent != NULL) && l4_is_valid_cap(*mapped_parent))
1.44 + {
1.45 + _env.parent = *mapped_parent;
1.46 + return L4_EOK;
1.47 + }
1.48 + else
1.49 + {
1.50 + _env.parent = L4_EXEC_PARENT_CAP;
1.51 + *mapped_parent = _env.parent;
1.52 + return ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.parent,
1.53 + parent, L4_CAP_FPAGE_RWS, 0});
1.54 + }
1.55 }
1.56
1.57 /* Map capabilities into the task, counting them if indicated. If capability