static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma) { size_t size = vma->vm_end - vma->vm_start; int old; int rc; old = atomic_cmpxchg(&xenbus_xsd_state, XENBUS_XSD_UNCOMMITTED, XENBUS_XSD_LOCAL_INIT); switch (old) { case XENBUS_XSD_UNCOMMITTED: rc = xb_init_comms(); if (rc != 0) return rc; break; case XENBUS_XSD_FOREIGN_INIT: case XENBUS_XSD_FOREIGN_READY: return -EBUSY; case XENBUS_XSD_LOCAL_INIT: case XENBUS_XSD_LOCAL_READY: default: break; } if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0)) return -EINVAL; if (remap_pfn_range(vma, vma->vm_start, mfn_to_pfn(xen_store_mfn), size, vma->vm_page_prot)) return -EAGAIN; return 0; }
void xenbus_resume(void) { xb_init_comms(); xs_resume(); bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev); xenbus_backend_resume(resume_dev); }
void xenbus_resume(void) { xb_init_comms(); xs_resume(); if (!xenbus_frontend.error) bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev); xenbus_backend_resume(resume_dev); xen_unplug_emulated_devices(); }
void xenbus_resume(void) { xb_init_comms(); xs_resume(); if (!xenbus_frontend.error) bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev); #ifdef CONFIG_XEN bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev); #endif }
int xenbus_conn(domid_t remote_dom, unsigned long *grant_ref, evtchn_port_t *local_port) { struct evtchn_alloc_unbound alloc_unbound; int rc, rc2; BUG_ON(atomic_read(&xenbus_xsd_state) != XENBUS_XSD_FOREIGN_INIT); BUG_ON(!is_initial_xendomain()); #if defined(CONFIG_PROC_FS) && defined(CONFIG_XEN_PRIVILEGED_GUEST) remove_xen_proc_entry("xsd_kva"); remove_xen_proc_entry("xsd_port"); #endif rc = xb_free_port(xen_store_evtchn); if (rc != 0) goto fail0; alloc_unbound.dom = DOMID_SELF; alloc_unbound.remote_dom = remote_dom; rc = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &alloc_unbound); if (rc != 0) goto fail0; *local_port = xen_store_evtchn = alloc_unbound.port; /* keep the old page (xen_store_mfn, xen_store_interface) */ rc = gnttab_grant_foreign_access(remote_dom, xen_store_mfn, GTF_permit_access); if (rc < 0) goto fail1; *grant_ref = rc; rc = xb_init_comms(); if (rc != 0) goto fail1; return 0; fail1: rc2 = xb_free_port(xen_store_evtchn); if (rc2 != 0) printk(KERN_WARNING "XENBUS: Error freeing xenstore event channel: %d\n", rc2); fail0: xen_store_evtchn = -1; return rc; }
#endif xen_store_interface = mfn_to_virt(xen_store_mfn); } else { atomic_set(&xenbus_xsd_state, XENBUS_XSD_FOREIGN_READY); #ifdef CONFIG_XEN xen_store_evtchn = xen_start_info->store_evtchn; xen_store_mfn = xen_start_info->store_mfn; xen_store_interface = mfn_to_virt(xen_store_mfn); #else xen_store_evtchn = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN); xen_store_mfn = hvm_get_parameter(HVM_PARAM_STORE_PFN); xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE); #endif /* Initialize the shared memory rings to talk to xenstored */ err = xb_init_comms(); if (err) goto err; } xenbus_dev_init(); /* Initialize the interface to xenstore. */ err = xs_init(); if (err) { printk(KERN_WARNING "XENBUS: Error initializing xenstore comms: %i\n", err); goto err; } /* Register ourselves with the kernel device subsystem */
static int xenbus_resume(device_t dev) { device_t *kids; struct xenbus_device_ivars *ivars; int i, count, error; char *statepath; xb_init_comms(); xs_resume(); /* * We must re-examine each device and find the new path for * its backend. */ if (device_get_children(dev, &kids, &count) == 0) { for (i = 0; i < count; i++) { if (device_get_state(kids[i]) == DS_NOTPRESENT) continue; ivars = device_get_ivars(kids[i]); unregister_xenbus_watch( &ivars->xd_otherend_watch); ivars->xd_state = XenbusStateInitialising; /* * Find the new backend details and * re-register our watch. */ free(ivars->xd_otherend_path, M_DEVBUF); error = xenbus_gather(XBT_NIL, ivars->xd_node, "backend-id", "%i", &ivars->xd_otherend_id, "backend", NULL, &ivars->xd_otherend_path, NULL); if (error) return (error); DEVICE_RESUME(kids[i]); statepath = malloc(strlen(ivars->xd_otherend_path) + strlen("/state") + 1, M_DEVBUF, M_WAITOK); sprintf(statepath, "%s/state", ivars->xd_otherend_path); free(ivars->xd_otherend_watch.node, M_DEVBUF); ivars->xd_otherend_watch.node = statepath; register_xenbus_watch( &ivars->xd_otherend_watch); #if 0 /* * Can't do this yet since we are running in * the xenwatch thread and if we sleep here, * we will stop delivering watch notifications * and the device will never come back online. */ sx_xlock(&ivars->xd_lock); while (ivars->xd_state != XenbusStateClosed && ivars->xd_state != XenbusStateConnected) sx_sleep(&ivars->xd_state, &ivars->xd_lock, 0, "xdresume", 0); sx_xunlock(&ivars->xd_lock); #endif } free(kids, M_TEMP); } return (0); }