Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/xen/gntdev/gntdev.c
Show First 20 Lines • Show All 362 Lines • ▼ Show 20 Lines | gntdev_alloc_gref(struct ioctl_gntdev_alloc_gref *arg) | ||||
/* Allocate grefs. */ | /* Allocate grefs. */ | ||||
grefs = malloc(sizeof(*grefs) * arg->count, M_GNTDEV, M_WAITOK); | grefs = malloc(sizeof(*grefs) * arg->count, M_GNTDEV, M_WAITOK); | ||||
for (i = 0; i < arg->count; i++) { | for (i = 0; i < arg->count; i++) { | ||||
grefs[i].file_index = file_offset + i * PAGE_SIZE; | grefs[i].file_index = file_offset + i * PAGE_SIZE; | ||||
grefs[i].gref_id = GRANT_REF_INVALID; | grefs[i].gref_id = GRANT_REF_INVALID; | ||||
grefs[i].notify = NULL; | grefs[i].notify = NULL; | ||||
grefs[i].page = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL | grefs[i].page = vm_page_alloc_noobj(VM_ALLOC_NORMAL | | ||||
| VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | VM_ALLOC_ZERO); | VM_ALLOC_WIRED | VM_ALLOC_ZERO); | ||||
if (grefs[i].page == NULL) { | if (grefs[i].page == NULL) { | ||||
log(LOG_ERR, "Page allocation failed."); | log(LOG_ERR, "Page allocation failed."); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
break; | break; | ||||
} | |||||
if ((grefs[i].page->flags & PG_ZERO) == 0) { | |||||
/* | |||||
* Zero the allocated page, as we don't want to | |||||
* leak our memory to other domains. | |||||
*/ | |||||
pmap_zero_page(grefs[i].page); | |||||
} | } | ||||
grefs[i].page->valid = VM_PAGE_BITS_ALL; | grefs[i].page->valid = VM_PAGE_BITS_ALL; | ||||
error = gnttab_grant_foreign_access(arg->domid, | error = gnttab_grant_foreign_access(arg->domid, | ||||
(VM_PAGE_TO_PHYS(grefs[i].page) >> PAGE_SHIFT), | (VM_PAGE_TO_PHYS(grefs[i].page) >> PAGE_SHIFT), | ||||
readonly, &grefs[i].gref_id); | readonly, &grefs[i].gref_id); | ||||
if (error != 0) { | if (error != 0) { | ||||
log(LOG_ERR, "Grant Table Hypercall failed."); | log(LOG_ERR, "Grant Table Hypercall failed."); | ||||
▲ Show 20 Lines • Show All 898 Lines • Show Last 20 Lines |