status_t vmi_pagetable_lookup_extended( vmi_instance_t vmi, addr_t dtb, addr_t vaddr, page_info_t *info) { status_t ret = VMI_FAILURE; if(!info) return ret; memset(info, 0, sizeof(page_info_t)); info->vaddr = vaddr; info->dtb = dtb; if(vmi->arch_interface && vmi->arch_interface->v2p) { ret = vmi->arch_interface->v2p(vmi, dtb, vaddr, info); } else { errprint("Invalid paging mode during vmi_pagetable_lookup\n"); } /* add this to the cache */ if (ret == VMI_SUCCESS) { v2p_cache_set(vmi, vaddr, dtb, info->paddr); } return ret; }
addr_t vmi_pagetable_lookup (vmi_instance_t vmi, addr_t dtb, addr_t vaddr) { page_info_t info = {0}; /* check if entry exists in the cachec */ if (VMI_SUCCESS == v2p_cache_get(vmi, vaddr, dtb, &info.paddr)) { /* verify that address is still valid */ uint8_t value = 0; if (VMI_SUCCESS == vmi_read_8_pa(vmi, info.paddr, &value)) { return info.paddr; } else { v2p_cache_del(vmi, vaddr, dtb); } } if(vmi->arch_interface && vmi->arch_interface->v2p) { vmi->arch_interface->v2p(vmi, dtb, vaddr, &info); } else { errprint("Arch interface not initialized, can't use vmi_pagetable_lookup!\n"); } /* add this to the cache */ if (info.paddr) { v2p_cache_set(vmi, vaddr, dtb, info.paddr); } return info.paddr; }
void vmi_v2pcache_add( vmi_instance_t vmi, addr_t va, addr_t dtb, addr_t pa) { return v2p_cache_set(vmi, va, dtb, pa); }
/* * Return a status when page_info is not needed, but also use the cache, * which vmi_pagetable_lookup_extended() does not do. * * TODO: Should this eventually replace vmi_pagetable_lookup() in the API? */ status_t vmi_pagetable_lookup_cache( vmi_instance_t vmi, addr_t dtb, addr_t vaddr, addr_t *paddr) { status_t ret = VMI_FAILURE; page_info_t info = { .vaddr = vaddr, .dtb = dtb }; if(!paddr) return ret; *paddr = 0; /* check if entry exists in the cache */ if (VMI_SUCCESS == v2p_cache_get(vmi, vaddr, dtb, paddr)) { /* verify that address is still valid */ uint8_t value = 0; if (VMI_SUCCESS == vmi_read_8_pa(vmi, *paddr, &value)) { return VMI_SUCCESS; } else { if ( VMI_FAILURE == v2p_cache_del(vmi, vaddr, dtb) ) return VMI_FAILURE; } } if(vmi->arch_interface && vmi->arch_interface->v2p) { ret = vmi->arch_interface->v2p(vmi, dtb, vaddr, &info); } else { errprint("Invalid paging mode during vmi_pagetable_lookup\n"); ret = VMI_FAILURE; } /* add this to the cache */ if (ret == VMI_SUCCESS) { *paddr = info.paddr; v2p_cache_set(vmi, vaddr, dtb, info.paddr); } return ret; }