1.1 --- a/libexec/lib/src/process_creating.cc Sat Mar 04 12:42:09 2023 +0100
1.2 +++ b/libexec/lib/src/process_creating.cc Sat Mar 04 18:00:11 2023 +0100
1.3 @@ -40,10 +40,10 @@
1.4 /* Initialise the process creator with the details of a region mapper. */
1.5
1.6 ProcessCreating::ProcessCreating(const char *rm_filename)
1.7 -: _rm_filename(rm_filename),
1.8 - _rm_stack(Utcb_area_start - initial_stack_size, initial_stack_size, L4_FPAGE_RW),
1.9 - _program_stack(Utcb_area_start - initial_stack_size * 2, initial_stack_size, L4_FPAGE_RW)
1.10 +: _rm_filename(rm_filename)
1.11 {
1.12 + _rm_stack = new ExplicitSegment(Utcb_area_start - initial_stack_size, initial_stack_size, L4_FPAGE_RW);
1.13 + _program_stack = new ExplicitSegment(Utcb_area_start - initial_stack_size * 2, initial_stack_size, L4_FPAGE_RW);
1.14 }
1.15
1.16 /* Initialise the memory segments of the region mapper. These are mapped into
1.17 @@ -57,7 +57,7 @@
1.18 if (err)
1.19 return err;
1.20
1.21 - return _rm_stack.allocate(true);
1.22 + return _rm_stack->allocate(true);
1.23 }
1.24
1.25 /* Initialise the memory segments of the actual program. These are not mapped
1.26 @@ -71,7 +71,7 @@
1.27 if (err)
1.28 return err;
1.29
1.30 - return _program_stack.allocate(true);
1.31 + return _program_stack->allocate(true);
1.32 }
1.33
1.34 /* Initialise an external system-level pager serving the region mapper in a
1.35 @@ -93,7 +93,7 @@
1.36
1.37 /* Include the region mapper's stack region. */
1.38
1.39 - _exec_pager->add(_rm_stack.region());
1.40 + _exec_pager->add(_rm_stack->region());
1.41
1.42 /* Start the pager in a separate thread. */
1.43
1.44 @@ -181,7 +181,7 @@
1.45
1.46 /* Introduce the stack region and capability. */
1.47
1.48 - init_region(rm_regions, rm_mapped_caps, _program_stack.exec_region(), rm_index);
1.49 + init_region(rm_regions, rm_mapped_caps, _program_stack->exec_region(), rm_index);
1.50
1.51 /* Terminate the region array. */
1.52
1.53 @@ -221,7 +221,7 @@
1.54 region mapper, plus the initial server capability and region details. */
1.55
1.56 const char *argv[] = {_rm_filename};
1.57 - Stack rm_st(_rm_stack);
1.58 + Stack rm_st(*_rm_stack);
1.59
1.60 rm_st.set_init_caps(rm_init_caps);
1.61 rm_st.set_regions(rm_regions);
1.62 @@ -260,7 +260,7 @@
1.63 actual program. The server capability should be assigned to the region
1.64 mapper capability slot already. */
1.65
1.66 - Stack program_st(_program_stack);
1.67 + Stack program_st(*_program_stack);
1.68
1.69 program_st.populate(argc, argv, envp);
1.70
1.71 @@ -318,12 +318,15 @@
1.72 _exec_pager->set_task(_process.get_task());
1.73 _exec_pager->set_gate(_ipc_gate);
1.74
1.75 - /* Discard instances created to initialise the process.
1.76 + /* Discard instances created to initialise the process. The region mapper
1.77 + relies on resources associated with its payload and stack and so these
1.78 + cannot be deleted immediately.
1.79 +
1.80 NOTE: The region mapper payload could be retained instead of being
1.81 reconstructed each time. */
1.82
1.83 - delete _rm_payload;
1.84 delete _program_payload;
1.85 + delete _program_stack;
1.86
1.87 return L4_EOK;
1.88 }