mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
Kernel: Assert that a KmallocSubheap fits inside a page
Since we allocate the subheap in the first page of the given storage let's assert that the subheap can actually fit in a single page, to prevent the possible future headache of trying to debug the cause of random kernel memory corruption :^)
This commit is contained in:
parent
1c99f99e99
commit
7757d874ad
1 changed files with 1 additions and 0 deletions
|
@ -58,6 +58,7 @@ struct KmallocGlobalData {
|
||||||
void add_subheap(u8* storage, size_t storage_size)
|
void add_subheap(u8* storage, size_t storage_size)
|
||||||
{
|
{
|
||||||
dbgln("Adding kmalloc subheap @ {} with size {}", storage, storage_size);
|
dbgln("Adding kmalloc subheap @ {} with size {}", storage, storage_size);
|
||||||
|
static_assert(sizeof(KmallocSubheap) <= PAGE_SIZE);
|
||||||
auto* subheap = new (storage) KmallocSubheap(storage + PAGE_SIZE, storage_size - PAGE_SIZE);
|
auto* subheap = new (storage) KmallocSubheap(storage + PAGE_SIZE, storage_size - PAGE_SIZE);
|
||||||
subheaps.append(*subheap);
|
subheaps.append(*subheap);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue