1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

fix bug in resizing and splitting of a VMA regions

This commit is contained in:
Stefan Lankes 2016-05-26 10:03:13 +02:00
parent 8eb597d0c5
commit 82017fe436

View file

@ -109,9 +109,10 @@ fail:
return 0;
found:
if (pred && pred->flags == flags)
pred->end = start + size; // resize VMA
else {
if (pred && pred->flags == flags) {
pred->end += size; // resize VMA
//kprintf("vma_alloc: resize vma, start 0x%zx, pred->start 0x%zx, pred->end 0x%zx\n", start, pred->start, pred->end);
} else {
// insert new VMA
vma_t* new = kmalloc(sizeof(vma_t));
if (BUILTIN_EXPECT(!new, 0))
@ -182,6 +183,8 @@ int vma_free(size_t start, size_t end)
return -ENOMEM;
}
new->flags = vma->flags;
new->end = vma->end;
vma->end = start;
new->start = end;
@ -255,10 +258,11 @@ void vma_dump(void)
{
void print_vma(vma_t *vma) {
while (vma) {
kprintf("0x%lx - 0x%lx: size=%x, flags=%c%c%c\n", vma->start, vma->end, vma->end - vma->start,
kprintf("0x%lx - 0x%lx: size=%x, flags=%c%c%c%s\n", vma->start, vma->end, vma->end - vma->start,
(vma->flags & VMA_READ) ? 'r' : '-',
(vma->flags & VMA_WRITE) ? 'w' : '-',
(vma->flags & VMA_EXECUTE) ? 'x' : '-');
(vma->flags & VMA_EXECUTE) ? 'x' : '-',
(vma->flags & VMA_CACHEABLE) ? "" : " (uncached)");
vma = vma->next;
}
}