kboot: Hack for running on FreeBSD host

When we're running on a FreeBSD host, we can't open /proc/iomem.  So,
for now, just assume that we have 32GB of ram starting at 4GB.

Sponsored by: Netflix
This commit is contained in:
Warner Losh 2023-03-02 10:31:05 -07:00
parent de1a17db89
commit 6c47abb63b
2 changed files with 8 additions and 0 deletions

View file

@ -86,6 +86,11 @@ memory_limits(void)
committed_as <<= 10; /* Units are kB */
}
}
} else {
/* Otherwise, on FreeBSD host, for testing 32GB host: */
mem_avail = 31ul << 30; /* 31GB free */
commit_limit = mem_avail * 9 / 10; /* 90% comittable */
committed_as = 20ul << 20; /* 20MB used */
}
printf("Commit limit: %lld Committed bytes %lld Available %lld\n",
(long long)commit_limit, (long long)committed_as,

View file

@ -286,6 +286,9 @@ populate_avail_from_iomem(void)
fd = open("host:/proc/iomem", O_RDONLY);
if (fd == -1) {
printf("Can't get memory map\n");
init_avail();
// Hack: 32G of RAM starting at 4G
add_avail(4ull << 30, 36ull << 30, system_ram);
return false;
}