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.
This commit is contained in:
Andrius Štikonas 2024-01-02 00:47:32 +00:00
parent c7c827a1e9
commit c0baf959ab
Signed by: andrius
GPG Key ID: 0C0331D5228A3B62
2 changed files with 6 additions and 6 deletions

2
M2libc

@ -1 +1 @@
Subproject commit c8090241c55fe23033c674c47da6c3719e5bca3a
Subproject commit 80d32745dcab5b21683ed3e79e943b158397c224

View File

@ -10,13 +10,13 @@
#include <unistd.h>
#include <bootstrappable.h>
#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);