circular dependency in paging
Posted: Sun Jul 19, 2015 8:21 pm
Hello
I'm having a bit of a problem with paging. I use a higher-half kernel, beginning at 3GB + 1MB and the first thing i do is i map 4 megabytes from virtual 3GB to 0. This works (for now). Then i set up my 'kernel heap' to allocate space beginning with the virtual-kernel-end address (should be somewhere around 3GB + 2MB). This works too. The Problem now is, consider the following:
I request some bytes in kernel-heap. The heap is exhausted so it has to request the paging to map a new frame to the end of kernel-heap. BUT: The end of kernel-heap is an address dividable by (4096*1024) which would mean, it lies in the page-directory at an offset where no page-table is created yet, so the paging itself has to request a new page from kernel-heap first, to create the new page-table. Now everything breaks since kmalloc needs a new page and the paging needs allocated space from kmalloc. How would i handle this? I thought about pre-creating 256 page-tables for the 3GB-4GB (kernel) range so i'd never need a new page-table when i need space in kernel-heap. Also, this would mean i don't need to care about synchronizing processes kernel-space mappings since every processes page-directory already has the kernel-space tables set.
I'm having a bit of a problem with paging. I use a higher-half kernel, beginning at 3GB + 1MB and the first thing i do is i map 4 megabytes from virtual 3GB to 0. This works (for now). Then i set up my 'kernel heap' to allocate space beginning with the virtual-kernel-end address (should be somewhere around 3GB + 2MB). This works too. The Problem now is, consider the following:
I request some bytes in kernel-heap. The heap is exhausted so it has to request the paging to map a new frame to the end of kernel-heap. BUT: The end of kernel-heap is an address dividable by (4096*1024) which would mean, it lies in the page-directory at an offset where no page-table is created yet, so the paging itself has to request a new page from kernel-heap first, to create the new page-table. Now everything breaks since kmalloc needs a new page and the paging needs allocated space from kmalloc. How would i handle this? I thought about pre-creating 256 page-tables for the 3GB-4GB (kernel) range so i'd never need a new page-table when i need space in kernel-heap. Also, this would mean i don't need to care about synchronizing processes kernel-space mappings since every processes page-directory already has the kernel-space tables set.