/*
* Event control functions
*/
status_t xen_set_mem_access(vmi_instance_t vmi, addr_t gpfn,
vmi_mem_access_t page_access_flag, uint16_t altp2m_idx)
{
int rc;
xenmem_access_t access;
xen_instance_t *xen = xen_get_instance(vmi);
xc_interface * xch = xen_get_xchandle(vmi);
domid_t dom = xen_get_domainid(vmi);
#ifdef ENABLE_SAFETY_CHECKS
if ( !xch ) {
errprint("%s error: invalid xc_interface handle\n", __FUNCTION__);
return VMI_FAILURE;
}
if ( dom == (domid_t)VMI_INVALID_DOMID ) {
errprint("%s error: invalid domid\n", __FUNCTION__);
return VMI_FAILURE;
}
#endif
if ( VMI_FAILURE == convert_vmi_flags_to_xenmem(page_access_flag, &access) )
return VMI_FAILURE;
if ( !altp2m_idx )
rc = xen->libxcw.xc_set_mem_access(xch, dom, access, gpfn, 1); // 1 page at a time
else
rc = xen->libxcw.xc_altp2m_set_mem_access(xch, dom, altp2m_idx, gpfn, access);
if (rc) {
errprint("xc_hvm_set_mem_access failed with code: %d\n", rc);
return VMI_FAILURE;
}
dbprint(VMI_DEBUG_XEN, "--Done Setting memaccess on GPFN: %"PRIu64"\n", gpfn);
return VMI_SUCCESS;
}
🌱 Back to Garden