mm: make get_physaddr return NULL if PD or PT is not present
This commit is contained in:
+10
-2
@@ -22,10 +22,18 @@ void *get_physaddr(void *virtualaddr) {
|
||||
unsigned long ptindex = (unsigned long)virtualaddr >> 12 & 0x03FF;
|
||||
|
||||
unsigned long *pd = (unsigned long *)0xFFFFF000;
|
||||
// Here you need to check whether the PD entry is present.
|
||||
if(!(pd[pdindex] & PAGE_PRESENT))
|
||||
{
|
||||
debug_log("get_physaddr: no PD (virt address is %X)\n", virtualaddr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32_t *pt = (uint32_t*)(0xFFC00000 + (pdindex << 12));
|
||||
// Here you need to check whether the PT entry is present.
|
||||
if(!(pt[ptindex] & PAGE_PRESENT))
|
||||
{
|
||||
debug_log("get_physaddr: no PT (virt address is %X)\n", virtualaddr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void *)((pt[ptindex] & ~0xFFF) + ((unsigned long)virtualaddr & 0xFFF));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user