1.1 --- a/libexec/include/exec/process_creating.h Sat Mar 04 12:42:09 2023 +0100
1.2 +++ b/libexec/include/exec/process_creating.h Sat Mar 04 18:00:11 2023 +0100
1.3 @@ -46,10 +46,10 @@
1.4
1.5 /* Stack and payload descriptions. */
1.6
1.7 - ExplicitSegment _rm_stack;
1.8 + ExplicitSegment *_rm_stack = NULL;
1.9 Payload *_rm_payload = NULL;
1.10
1.11 - ExplicitSegment _program_stack;
1.12 + ExplicitSegment *_program_stack = NULL;
1.13 Payload *_program_payload = NULL;
1.14
1.15 /* IPC gate for communication within the created task, plus allocated
2.1 --- a/libexec/lib/src/process_creating.cc Sat Mar 04 12:42:09 2023 +0100
2.2 +++ b/libexec/lib/src/process_creating.cc Sat Mar 04 18:00:11 2023 +0100
2.3 @@ -40,10 +40,10 @@
2.4 /* Initialise the process creator with the details of a region mapper. */
2.5
2.6 ProcessCreating::ProcessCreating(const char *rm_filename)
2.7 -: _rm_filename(rm_filename),
2.8 - _rm_stack(Utcb_area_start - initial_stack_size, initial_stack_size, L4_FPAGE_RW),
2.9 - _program_stack(Utcb_area_start - initial_stack_size * 2, initial_stack_size, L4_FPAGE_RW)
2.10 +: _rm_filename(rm_filename)
2.11 {
2.12 + _rm_stack = new ExplicitSegment(Utcb_area_start - initial_stack_size, initial_stack_size, L4_FPAGE_RW);
2.13 + _program_stack = new ExplicitSegment(Utcb_area_start - initial_stack_size * 2, initial_stack_size, L4_FPAGE_RW);
2.14 }
2.15
2.16 /* Initialise the memory segments of the region mapper. These are mapped into
2.17 @@ -57,7 +57,7 @@
2.18 if (err)
2.19 return err;
2.20
2.21 - return _rm_stack.allocate(true);
2.22 + return _rm_stack->allocate(true);
2.23 }
2.24
2.25 /* Initialise the memory segments of the actual program. These are not mapped
2.26 @@ -71,7 +71,7 @@
2.27 if (err)
2.28 return err;
2.29
2.30 - return _program_stack.allocate(true);
2.31 + return _program_stack->allocate(true);
2.32 }
2.33
2.34 /* Initialise an external system-level pager serving the region mapper in a
2.35 @@ -93,7 +93,7 @@
2.36
2.37 /* Include the region mapper's stack region. */
2.38
2.39 - _exec_pager->add(_rm_stack.region());
2.40 + _exec_pager->add(_rm_stack->region());
2.41
2.42 /* Start the pager in a separate thread. */
2.43
2.44 @@ -181,7 +181,7 @@
2.45
2.46 /* Introduce the stack region and capability. */
2.47
2.48 - init_region(rm_regions, rm_mapped_caps, _program_stack.exec_region(), rm_index);
2.49 + init_region(rm_regions, rm_mapped_caps, _program_stack->exec_region(), rm_index);
2.50
2.51 /* Terminate the region array. */
2.52
2.53 @@ -221,7 +221,7 @@
2.54 region mapper, plus the initial server capability and region details. */
2.55
2.56 const char *argv[] = {_rm_filename};
2.57 - Stack rm_st(_rm_stack);
2.58 + Stack rm_st(*_rm_stack);
2.59
2.60 rm_st.set_init_caps(rm_init_caps);
2.61 rm_st.set_regions(rm_regions);
2.62 @@ -260,7 +260,7 @@
2.63 actual program. The server capability should be assigned to the region
2.64 mapper capability slot already. */
2.65
2.66 - Stack program_st(_program_stack);
2.67 + Stack program_st(*_program_stack);
2.68
2.69 program_st.populate(argc, argv, envp);
2.70
2.71 @@ -318,12 +318,15 @@
2.72 _exec_pager->set_task(_process.get_task());
2.73 _exec_pager->set_gate(_ipc_gate);
2.74
2.75 - /* Discard instances created to initialise the process.
2.76 + /* Discard instances created to initialise the process. The region mapper
2.77 + relies on resources associated with its payload and stack and so these
2.78 + cannot be deleted immediately.
2.79 +
2.80 NOTE: The region mapper payload could be retained instead of being
2.81 reconstructed each time. */
2.82
2.83 - delete _rm_payload;
2.84 delete _program_payload;
2.85 + delete _program_stack;
2.86
2.87 return L4_EOK;
2.88 }