[zion] Fix an over-allocation bug when creating a memory object
This commit is contained in:
parent
0f0e39d1e9
commit
b6735d3175
|
@ -24,7 +24,8 @@ KernelHeap::KernelHeap(uint64_t lower_bound, uint64_t upper_bound)
|
|||
|
||||
void* KernelHeap::Allocate(uint64_t size) {
|
||||
if (next_addr_ + size >= upper_bound_) {
|
||||
panic("Kernel Heap Overrun");
|
||||
panic("Kernel Heap Overrun (next, size, max): %m, %x, %m", next_addr_, size,
|
||||
upper_bound_);
|
||||
}
|
||||
#if K_HEAP_DEBUG
|
||||
RecordSize(size);
|
||||
|
|
|
@ -61,6 +61,9 @@ class PhysicalMemoryManager {
|
|||
front_ = front_->next;
|
||||
delete temp;
|
||||
}
|
||||
#if K_PHYS_DEBUG
|
||||
dbgln("Single %m", page);
|
||||
#endif
|
||||
return page;
|
||||
}
|
||||
uint64_t AllocateContinuous(uint64_t num_pages) {
|
||||
|
@ -89,6 +92,9 @@ class PhysicalMemoryManager {
|
|||
front_ = front_->next;
|
||||
delete temp;
|
||||
}
|
||||
#if K_PHYS_DEBUG
|
||||
dbgln("Continuous %m:%u", page, num_pages);
|
||||
#endif
|
||||
return page;
|
||||
}
|
||||
void FreePage(uint64_t page) { AddMemoryRegion(page, 0x1000); }
|
||||
|
|
|
@ -138,7 +138,7 @@ z_err_t MemoryObjectCreatePhysical(ZMemoryObjectCreatePhysicalReq* req,
|
|||
auto& curr_proc = gScheduler->CurrentProcess();
|
||||
uint64_t paddr = req->paddr;
|
||||
if (paddr == 0) {
|
||||
paddr = phys_mem::AllocateContinuous((req->size - 1 / 0x1000) + 1);
|
||||
paddr = phys_mem::AllocateContinuous(((req->size - 1) / 0x1000) + 1);
|
||||
}
|
||||
auto vmmo_ref = MakeRefCounted<FixedMemoryObject>(paddr, req->size);
|
||||
resp->vmmo_cap =
|
||||
|
|
Loading…
Reference in New Issue