A couple of bug fixes.
* mmu_get_virtual_mapping() should check that the page directory entry is present rather than assuming there's a page table there. This was resulting in some invalid mappings being created in the 64-bit virtual address space. * arch_vm_init_end() should clear from KERNEL_LOAD_BASE to virtual_end, not from KERNEL_BASE. On x86_64 this was causing it to loop through ~512GB of address space, which obviously was taking quite a while.
This commit is contained in:
@@ -512,17 +512,18 @@ mmu_get_virtual_mapping(addr_t virtualAddress, addr_t *_physicalAddress)
|
|||||||
(void *)virtualAddress);
|
(void *)virtualAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 *pageTable = (uint32 *)(sPageDirectory[virtualAddress
|
uint32 dirEntry = sPageDirectory[virtualAddress / (B_PAGE_SIZE * 1024)];
|
||||||
/ (B_PAGE_SIZE * 1024)] & 0xfffff000);
|
if ((dirEntry & (1 << 0)) == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32 *pageTable = (uint32 *)(dirEntry & 0xfffff000);
|
||||||
uint32 tableEntry = pageTable[(virtualAddress % (B_PAGE_SIZE * 1024))
|
uint32 tableEntry = pageTable[(virtualAddress % (B_PAGE_SIZE * 1024))
|
||||||
/ B_PAGE_SIZE];
|
/ B_PAGE_SIZE];
|
||||||
|
if ((tableEntry & (1 << 0)) == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if ((tableEntry & (1<<0)) != 0) {
|
|
||||||
*_physicalAddress = tableEntry & 0xFFFFF000;
|
*_physicalAddress = tableEntry & 0xFFFFF000;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -897,10 +897,7 @@ arch_cpu_init_post_vm(kernel_args* args)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO x86_64
|
|
||||||
#ifndef __x86_64
|
|
||||||
if (!apic_available())
|
if (!apic_available())
|
||||||
#endif
|
|
||||||
x86_init_fpu();
|
x86_init_fpu();
|
||||||
// else fpu gets set up in smp code
|
// else fpu gets set up in smp code
|
||||||
|
|
||||||
|
|||||||
@@ -672,8 +672,8 @@ arch_vm_init_end(kernel_args *args)
|
|||||||
TRACE(("arch_vm_init_endvm: entry\n"));
|
TRACE(("arch_vm_init_endvm: entry\n"));
|
||||||
|
|
||||||
// throw away anything in the kernel_args.pgtable[] that's not yet mapped
|
// throw away anything in the kernel_args.pgtable[] that's not yet mapped
|
||||||
vm_free_unused_boot_loader_range(KERNEL_BASE,
|
vm_free_unused_boot_loader_range(KERNEL_LOAD_BASE,
|
||||||
args->arch_args.virtual_end - KERNEL_BASE);
|
args->arch_args.virtual_end - KERNEL_LOAD_BASE);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -539,7 +539,8 @@ X86VMTranslationMap64Bit::Query(addr_t virtualAddress,
|
|||||||
| ((entry & X86_64_PTE_PRESENT) != 0 ? PAGE_PRESENT : 0);
|
| ((entry & X86_64_PTE_PRESENT) != 0 ? PAGE_PRESENT : 0);
|
||||||
|
|
||||||
TRACE("X86VMTranslationMap64Bit::Query(%#" B_PRIxADDR ") -> %#"
|
TRACE("X86VMTranslationMap64Bit::Query(%#" B_PRIxADDR ") -> %#"
|
||||||
B_PRIxPHYSADDR ":\n", virtualAddress, *_physicalAddress);
|
B_PRIxPHYSADDR " %#" B_PRIx32 " (pte: %p %#" B_PRIx64 ")\n",
|
||||||
|
virtualAddress, *_physicalAddress, *_flags, pte, entry);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user