Fix memory leak and incorrect debugging output in pmap.c
This commit is contained in:
parent
d5b94390f8
commit
0d26227290
@ -59,7 +59,7 @@ PMap_Init()
|
||||
// Setup system mappings
|
||||
PMap_SystemLMap(0x0, 0x0, (3*512), 0); // 3GB RWX
|
||||
PMap_SystemLMap(0xC0000000, 0xC0000000, 512, PTE_NX|PTE_PCD); // 1GB RW + PCD
|
||||
PMap_SystemLMap(0x100000000, 0x100000000, 3*512, 0); // 60GB RWX
|
||||
PMap_SystemLMap(0x100000000, 0x100000000, 60*512, 0); // 60GB RWX
|
||||
|
||||
write_cr3((uint64_t)systemAS.root);
|
||||
|
||||
@ -146,6 +146,11 @@ PMapLookupEntry(AS *space, uint64_t va, PageEntry **entry, int size)
|
||||
table = (PageTable *)(pte & 0xFFFFFFFFFFFFF000);
|
||||
|
||||
pte = table->entries[j];
|
||||
if (size == HUGE_PGSIZE) {
|
||||
// Handle 1GB pages
|
||||
*entry = &table->entries[j];
|
||||
return;
|
||||
}
|
||||
if (pte == 0) {
|
||||
PageTable *newtable = PMapAllocPageTable();
|
||||
if (!newtable)
|
||||
@ -154,14 +159,14 @@ PMapLookupEntry(AS *space, uint64_t va, PageEntry **entry, int size)
|
||||
pte = (uint64_t)newtable | PTE_P | PTE_W;
|
||||
table->entries[j] = pte;
|
||||
}
|
||||
if (size == HUGE_PGSIZE) {
|
||||
// Handle 1GB pages
|
||||
*entry = &table->entries[j];
|
||||
return;
|
||||
}
|
||||
table = (PageTable *)(pte & 0xFFFFFFFFFFFFF000);
|
||||
|
||||
pte = table->entries[k];
|
||||
if (size == LARGE_PGSIZE) {
|
||||
// Handle 2MB pages
|
||||
*entry = &table->entries[k];
|
||||
return;
|
||||
}
|
||||
if (pte == 0) {
|
||||
PageTable *newtable = PMapAllocPageTable();
|
||||
if (!newtable)
|
||||
@ -170,11 +175,6 @@ PMapLookupEntry(AS *space, uint64_t va, PageEntry **entry, int size)
|
||||
pte = (uint64_t)newtable | PTE_P | PTE_W;
|
||||
table->entries[k] = pte;
|
||||
}
|
||||
if (size == LARGE_PGSIZE) {
|
||||
// Handle 2MB pages
|
||||
*entry = &table->entries[k];
|
||||
return;
|
||||
}
|
||||
table = (PageTable *)(pte & 0xFFFFFFFFFFFFF000);
|
||||
|
||||
// Handle 4KB pages
|
||||
@ -201,7 +201,7 @@ PMapDump(AS *space)
|
||||
kprintf("Level 1: %016llx\n", (uint64_t)pte);
|
||||
|
||||
for (j = 0; j < PAGETABLE_ENTRIES; j++) {
|
||||
PageEntry pte = l1->entries[i];
|
||||
PageEntry pte = l1->entries[j];
|
||||
PageTable *l2 = (PageTable *)(pte & 0xFFFFFFFFFFFFF000);
|
||||
|
||||
if (!(pte & PTE_P))
|
||||
@ -210,7 +210,7 @@ PMapDump(AS *space)
|
||||
kprintf("Level 2: %016llx\n", (uint64_t)pte);
|
||||
|
||||
for (k = 0; k < PAGETABLE_ENTRIES; k++) {
|
||||
PageEntry pte = l2->entries[i];
|
||||
PageEntry pte = l2->entries[k];
|
||||
PageTable *l3 = (PageTable *)(pte & 0xFFFFFFFFFFFFF000);
|
||||
|
||||
if (!(pte & PTE_P))
|
||||
|
Loading…
Reference in New Issue
Block a user