Skip to content

Commit 037c5b4

Browse files
kernel/process_standard: Handle null minimum RAM memory
On some architectures, the minimum ammount of memory required to run a process may be null. This caused a panic in the kernel during ProcessStandard::create(). The case is now handled by asking the memory manager for 1 byte if the architecture specifies a null ammount of memory. Signed-off-by: Ioan-Cristian CÎRSTEA <ioan.cirstea@oxidos.io>
1 parent d1bb660 commit 037c5b4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

kernel/src/process_standard.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,10 +1622,20 @@ impl<C: 'static + Chip, D: 'static + ProcessStandardDebug> ProcessStandard<'_, C
16221622
// the context switching implementation and allocate at least that much
16231623
// memory so that we can successfully switch to the process. This is
16241624
// architecture and implementation specific, so we query that now.
1625-
let min_process_memory_size = chip
1625+
let initial_process_app_brk_size = chip
16261626
.userspace_kernel_boundary()
16271627
.initial_process_app_brk_size();
16281628

1629+
// Protected allocated region cannot be empty. As such, if the
1630+
// architecture does not require any memory for a process to start
1631+
// running, tell the memory manager that the architectures requires 1
1632+
// byte.
1633+
let min_process_memory_size = if initial_process_app_brk_size == 0 {
1634+
1
1635+
} else {
1636+
initial_process_app_brk_size
1637+
};
1638+
16291639
// We have to ensure that we at least ask the MPU for
16301640
// `min_process_memory_size` so that we can be sure that `app_brk` is
16311641
// not set inside the kernel-owned memory region. Now, in practice,

0 commit comments

Comments
 (0)