/* finds the address of the page global directory for a given pid */ status_t vmi_pid_to_dtb (vmi_instance_t vmi, vmi_pid_t pid, addr_t *dtb) { status_t ret = VMI_FAILURE; addr_t _dtb = 0; if (!vmi->os_interface) return VMI_FAILURE; if ( !pid ) { *dtb = vmi->kpgd; return VMI_SUCCESS; } ret = pid_cache_get(vmi, pid, &_dtb); if ( VMI_FAILURE == ret ) { if (vmi->os_interface->os_pid_to_pgd) ret = vmi->os_interface->os_pid_to_pgd(vmi, pid, &_dtb); if ( VMI_SUCCESS == ret ) pid_cache_set(vmi, pid, _dtb); } *dtb = _dtb; return ret; }
// Below are wrapper functions for external API access to the cache void vmi_pidcache_add( vmi_instance_t vmi, vmi_pid_t pid, addr_t dtb) { return pid_cache_set(vmi, pid, dtb); }
/* finds the address of the page global directory for a given pid */ addr_t vmi_pid_to_dtb (vmi_instance_t vmi, vmi_pid_t pid) { addr_t dtb = 0; if (VMI_FAILURE == pid_cache_get(vmi, pid, &dtb)) { if (vmi->os_interface && vmi->os_interface->os_pid_to_pgd) { dtb = vmi->os_interface->os_pid_to_pgd(vmi, pid); } if (dtb) { pid_cache_set(vmi, pid, dtb); } } return dtb; }