From c0baf959ab3ea0868beb007cba3d713b848a4311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Tue, 2 Jan 2024 00:47:32 +0000 Subject: [PATCH] Make sure brk area is zeroed on start. Some stage0 applications, e.g. M0 assume that newly allocated memory is empty. We also need to do that for forked processes but it's not part of this commit. --- M2libc | 2 +- posix-runner/posix-runner.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/M2libc b/M2libc index c809024..80d3274 160000 --- a/M2libc +++ b/M2libc @@ -1 +1 @@ -Subproject commit c8090241c55fe23033c674c47da6c3719e5bca3a +Subproject commit 80d32745dcab5b21683ed3e79e943b158397c224 diff --git a/posix-runner/posix-runner.c b/posix-runner/posix-runner.c index 9cb5638..50a66df 100644 --- a/posix-runner/posix-runner.c +++ b/posix-runner/posix-runner.c @@ -10,13 +10,13 @@ #include #include -#define MSR_EFER 0x60000080 + 0x60000000 -#define MSR_STAR 0x60000081 + 0x60000000 -#define MSR_LSTAR 0x60000082 + 0x60000000 +#define MSR_EFER (0x60000080 + 0x60000000) +#define MSR_STAR (0x60000081 + 0x60000000) +#define MSR_LSTAR (0x60000082 + 0x60000000) void* syscall_table; -#define MAX_MIB_PER_PROC 128 +#define MAX_MEMORY_PER_PROC (128 * 1024 * 1024) struct mem_block { void* address; @@ -408,7 +408,7 @@ int main(int argc, char** argv, char** envp) exit(3); } - _brk = malloc(MAX_MIB_PER_PROC * 1024 * 1024); + _brk = calloc(1, MAX_MEMORY_PER_PROC); if (_brk == NULL) { fputs("Could not allocate memory brk area.", stderr); exit(4);