From 39ac0216dd72a0e8f25b5b0bcd54dc15428a8808 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Fri, 24 Nov 2023 17:07:55 -0800 Subject: [PATCH] [Zion] Free all user space mappings when exitting a process. --- zion/memory/constants.h | 2 ++ zion/object/process.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/zion/memory/constants.h b/zion/memory/constants.h index 2c17ba3..7b619b2 100644 --- a/zion/memory/constants.h +++ b/zion/memory/constants.h @@ -25,3 +25,5 @@ const uint64_t kKernelStackOffset = 4 * kPageSize; const uint64_t kUserStackMin = 0x00007FF0'00000000; const uint64_t kUserStackMax = 0x00008000'00000000; const uint64_t kUserStackSize = MiB; + +const uint64_t kUserSpaceMax = 0x00008000'00000000; diff --git a/zion/object/process.cpp b/zion/object/process.cpp index 55e73ed..f0c7e86 100644 --- a/zion/object/process.cpp +++ b/zion/object/process.cpp @@ -101,7 +101,9 @@ void Process::Cleanup() { // 2. Release all capabailities. caps_.ReleaseAll(); - // 3. Unmap all user memory. TODO + // 3. Unmap all user memory. + PANIC_ON_ERR(vmas_->FreeAddressRange(0, kUserSpaceMax), + "Failed to cleanup userspace mappings in process exit."); // 4. Release paging structures. TODO state_ = FINISHED;