예제 #1
0
파일: debug.c 프로젝트: 2asoft/freebsd
static void
xendebug_identify(driver_t *driver, device_t parent)
{

	KASSERT(xen_domain(),
	    ("Trying to add Xen debug device to non-xen guest"));

	if (xen_hvm_domain() && !xen_vector_callback_enabled)
		return;

	if (BUS_ADD_CHILD(parent, 0, "debug", 0) == NULL)
		panic("Unable to add Xen debug device.");
}
예제 #2
0
파일: manage.c 프로젝트: mdamt/linux
int xen_setup_shutdown_event(void)
{
	static struct notifier_block xenstore_notifier = {
		.notifier_call = shutdown_event
	};

	if (!xen_domain())
		return -ENODEV;
	register_xenstore_notifier(&xenstore_notifier);
	register_reboot_notifier(&xen_reboot_nb);

	return 0;
}
예제 #3
0
static int __devinit gnttab_init(void)
{
	int i;
	unsigned int max_nr_glist_frames, nr_glist_frames;
	unsigned int nr_init_grefs;

	if (!xen_domain())
		return -ENODEV;

	nr_grant_frames = 1;
	boot_max_nr_grant_frames = __max_nr_grant_frames();

	/* Determine the maximum number of frames required for the
	 * grant reference free list on the current hypervisor.
	 */
	max_nr_glist_frames = (boot_max_nr_grant_frames *
			       GREFS_PER_GRANT_FRAME / RPP);

	gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *),
			      GFP_KERNEL);
	if (gnttab_list == NULL)
		return -ENOMEM;

	nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;
	for (i = 0; i < nr_glist_frames; i++) {
		gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL);
		if (gnttab_list[i] == NULL)
			goto ini_nomem;
	}

	if (gnttab_resume() < 0)
		return -ENODEV;

	nr_init_grefs = nr_grant_frames * GREFS_PER_GRANT_FRAME;

	for (i = NR_RESERVED_ENTRIES; i < nr_init_grefs - 1; i++)
		gnttab_entry(i) = i + 1;

	gnttab_entry(nr_init_grefs - 1) = GNTTAB_LIST_END;
	gnttab_free_count = nr_init_grefs - NR_RESERVED_ENTRIES;
	gnttab_free_head  = NR_RESERVED_ENTRIES;

	printk("Grant table initialized\n");
	return 0;

 ini_nomem:
	for (i--; i >= 0; i--)
		free_page((unsigned long)gnttab_list[i]);
	kfree(gnttab_list);
	return -ENOMEM;
}
예제 #4
0
static int __init xenkbd_init(void)
{
	if (!xen_domain())
		return -ENODEV;

	/* Nothing to do if running in dom0. */
	if (xen_initial_domain())
		return -ENODEV;

	if (!xen_has_pv_devices())
		return -ENODEV;

	return xenbus_register_frontend(&xenkbd_driver);
}
예제 #5
0
/*
 * This one is odd - it determines whether you want to run PV _and_
 * legacy (IDE) drivers together. This combination is only possible
 * under HVM.
 */
bool xen_has_pv_and_legacy_disk_devices(void)
{
	if (!xen_domain())
		return false;

	/* N.B. This is only ever used in HVM mode */
	if (xen_pv_domain())
		return false;

	if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY)
		return true;

	return false;
}
예제 #6
0
static int __init xenbus_init(void)
{
	int err = 0;

	if (!xen_domain())
		return -ENODEV;

	if (xen_hvm_domain()) {
		uint64_t v = 0;
		err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
		if (err)
			goto out_error;
		xen_store_evtchn = (int)v;
		err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
		if (err)
			goto out_error;
		xen_store_mfn = (unsigned long)v;
		xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
	} else {
		xen_store_evtchn = xen_start_info->store_evtchn;
		xen_store_mfn = xen_start_info->store_mfn;
		if (xen_store_evtchn)
			xenstored_ready = 1;
		else {
			err = xenstored_local_init();
			if (err)
				goto out_error;
		}
		xen_store_interface = mfn_to_virt(xen_store_mfn);
	}

	/* Initialize the interface to xenstore. */
	err = xs_init();
	if (err) {
		printk(KERN_WARNING
		       "XENBUS: Error initializing xenstore comms: %i\n", err);
		goto out_error;
	}

#ifdef CONFIG_XEN_COMPAT_XENFS
	/*
	 * Create xenfs mountpoint in /proc for compatibility with
	 * utilities that expect to find "xenbus" under "/proc/xen".
	 */
	proc_mkdir("xen", NULL);
#endif

out_error:
	return err;
}
예제 #7
0
파일: dom0_mm_misc.c 프로젝트: 0day-ci/dpdk
static int __init
dom0_init(void)
{
	if (!xen_domain())
		return -ENODEV;

	if (rsv_memsize > DOM0_CONFIG_MEMSIZE) {
		XEN_ERR("The reserved memory size cannot be greater than %d\n",
			DOM0_CONFIG_MEMSIZE);
		return -EINVAL;
	}

	/* Setup the misc device */
	dom0_dev.miscdev.minor = MISC_DYNAMIC_MINOR;
	dom0_dev.miscdev.name = "dom0_mm";
	dom0_dev.miscdev.fops = &data_fops;

	/* register misc char device */
	if (misc_register(&dom0_dev.miscdev) != 0) {
		XEN_ERR("Misc device registration failed\n");
		return -EPERM;
	}

	mutex_init(&dom0_dev.data_lock);
	dom0_kobj = kobject_create_and_add("dom0-mm", mm_kobj);

	if (!dom0_kobj) {
		XEN_ERR("dom0-mm object creation failed\n");
		misc_deregister(&dom0_dev.miscdev);
		return -ENOMEM;
	}

	if (sysfs_create_group(dom0_kobj, &dev_attr_grp)) {
		kobject_put(dom0_kobj);
		misc_deregister(&dom0_dev.miscdev);
		return -EPERM;
	}

	if (dom0_memory_reserve(rsv_memsize) < 0) {
		sysfs_remove_group(dom0_kobj, &dev_attr_grp);
		kobject_put(dom0_kobj);
		misc_deregister(&dom0_dev.miscdev);
		return -ENOMEM;
	}

	XEN_PRINT("####### DPDK Xen Dom0 module loaded  #######\n");

	return 0;
}
static int __init balloon_init(void)
{
	if (!xen_domain())
		return -ENODEV;

	pr_info("xen-balloon: Initialising balloon driver.\n");

	register_balloon(&balloon_dev);

	register_xen_selfballooning(&balloon_dev);

	register_xenstore_notifier(&xenstore_notifier);

	return 0;
}
예제 #9
0
static int __init balloon_init(void)
{
	unsigned long pfn,num_physpages,max_pfn;
	struct page *page;

	if (!xen_domain())
		return -ENODEV;

	pr_info("xen_balloon: Initialising balloon driver.\n");

	num_physpages = get_num_physpages();

	if (xen_pv_domain())
               max_pfn = xen_start_info->nr_pages;
    	else
               max_pfn = num_physpages;

   	balloon_stats.current_pages = min(num_physpages,max_pfn);
    totalram_bias = balloon_stats.current_pages - totalram_pages;
    old_totalram_pages = totalram_pages;
	balloon_stats.target_pages  = balloon_stats.current_pages;
	balloon_stats.balloon_low   = 0;
	balloon_stats.balloon_high  = 0;
	balloon_stats.driver_pages  = 0UL;
    pr_info("current_pages=%luKB, totalram_pages=%luKB, totalram_bias=%luKB\n",balloon_stats.current_pages*4, totalram_pages*4, totalram_bias*4);

	init_timer(&balloon_timer);
	balloon_timer.data = 0;
	balloon_timer.function = balloon_alarm;

	register_balloon(&balloon_sysdev);

	/* Initialise the balloon with excess memory space. */
#ifdef CONFIG_PVM
	for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
		page = pfn_to_page(pfn);
		if (!PageReserved(page))
			balloon_append(page);
	}
#endif
	target_watch.callback = watch_target;
	xenstore_notifier.notifier_call = balloon_init_watcher;

	register_xenstore_notifier(&xenstore_notifier);

	return 0;
}
/*
 * On a 10 second timeout, wait for all devices currently configured.  We need
 * to do this to guarantee that the filesystems and / or network devices
 * needed for boot are available, before we can allow the boot to proceed.
 *
 * This needs to be on a late_initcall, to happen after the frontend device
 * drivers have been initialised, but before the root fs is mounted.
 *
 * A possible improvement here would be to have the tools add a per-device
 * flag to the store entry, indicating whether it is needed at boot time.
 * This would allow people who knew what they were doing to accelerate their
 * boot slightly, but of course needs tools or manual intervention to set up
 * those flags correctly.
 */
static void wait_for_devices(struct xenbus_driver *xendrv)
{
	unsigned long timeout = jiffies + 10*HZ;
	struct device_driver *drv = xendrv ? &xendrv->driver : NULL;

	if (!ready_to_wait_for_devices || !xen_domain())
		return;

	while (exists_disconnected_device(drv)) {
		if (time_after(jiffies, timeout))
			break;
		schedule_timeout_interruptible(HZ/10);
	}

	bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
			 print_device_status);
}
예제 #11
0
static int __init xen_init_events(void)
{
	if (!xen_domain() || xen_events_irq < 0)
		return -ENODEV;

	xen_init_IRQ();

	if (request_percpu_irq(xen_events_irq, xen_arm_callback,
			"events", &xen_vcpu)) {
		pr_err("Error requesting IRQ %d\n", xen_events_irq);
		return -EINVAL;
	}

	on_each_cpu(xen_percpu_init, NULL, 0);

	return 0;
}
예제 #12
0
static void
xenpv_identify(driver_t *driver, device_t parent)
{
	if (!xen_domain())
		return;

	/* Make sure there's only one xenpv device. */
	if (devclass_get_device(xenpv_devclass, 0))
		return;

	/*
	 * The xenpv bus should be the last to attach in order
	 * to properly detect if an ISA bus has already been added.
	 */
	if (BUS_ADD_CHILD(parent, UINT_MAX, "xenpv", 0) == NULL)
		panic("Unable to attach xenpv bus.");
}
예제 #13
0
static int __init hyper_sysfs_init(void)
{
	int ret;

	if (!xen_domain())
		return -ENODEV;

	ret = xen_sysfs_type_init();
	if (ret)
		goto out;
	ret = xen_sysfs_version_init();
	if (ret)
		goto version_out;
	ret = xen_compilation_init();
	if (ret)
		goto comp_out;
	ret = xen_sysfs_uuid_init();
	if (ret)
		goto uuid_out;
	ret = xen_properties_init();
	if (ret)
		goto prop_out;
#ifdef CONFIG_XEN_HAVE_VPMU
	if (xen_initial_domain()) {
		ret = xen_pmu_init();
		if (ret) {
			sysfs_remove_group(hypervisor_kobj,
					   &xen_properties_group);
			goto prop_out;
		}
	}
#endif
	goto out;

prop_out:
	sysfs_remove_file(hypervisor_kobj, &uuid_attr.attr);
uuid_out:
	sysfs_remove_group(hypervisor_kobj, &xen_compilation_group);
comp_out:
	sysfs_remove_group(hypervisor_kobj, &version_group);
version_out:
	sysfs_remove_file(hypervisor_kobj, &type_attr.attr);
out:
	return ret;
}
예제 #14
0
static int __init balloon_init(void)
{
	if (!xen_domain())
		return -ENODEV;

	pr_info("xen-balloon: Initialising balloon driver.\n");

	register_balloon(&balloon_sysdev);

	register_xen_selfballooning(&balloon_sysdev);

	target_watch.callback = watch_target;
	xenstore_notifier.notifier_call = balloon_init_watcher;

	register_xenstore_notifier(&xenstore_notifier);

	return 0;
}
예제 #15
0
/**
 * Initializes the OpenXT input module.
 */
static int __init oxtkbd_init(void)
{
    //If we're not on Xen, we definitely don't apply.
    if (!xen_domain())
        return -ENODEV;

    //For now, there's no sense in running this from dom0,
    //as it has direct access to the keyboard. This may change,
    //depending on disaggregation specifics.
    if (xen_initial_domain())
        return -ENODEV;

    //If we can't use the XenBus, fail out.
    if (!xen_has_pv_devices())
        return -ENODEV;

    //Otheriwse, register our driver!
    return xenbus_register_frontend(&oxtkbd_driver);
}
static int __init xenbus_init(void)
{
    int err = 0;
    unsigned long page = 0;

    DPRINTK("");

    err = -ENODEV;
    if (!xen_domain())
        return err;

    /*
     * Domain0 doesn't have a store_evtchn or store_mfn yet.
     */
    if (xen_initial_domain()) {
        struct evtchn_alloc_unbound alloc_unbound;

        /* Allocate Xenstore page */
        page = get_zeroed_page(GFP_KERNEL);
        if (!page)
            goto out_error;

        xen_store_mfn = xen_start_info->store_mfn =
                            pfn_to_mfn(virt_to_phys((void *)page) >>
                                       PAGE_SHIFT);

        /* Next allocate a local port which xenstored can bind to */
        alloc_unbound.dom        = DOMID_SELF;
        alloc_unbound.remote_dom = 0;

        err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
                                          &alloc_unbound);
        if (err == -ENOSYS)
            goto out_error;

        BUG_ON(err);
        xen_store_evtchn = xen_start_info->store_evtchn =
                               alloc_unbound.port;

        xen_store_interface = mfn_to_virt(xen_store_mfn);
    } else {
        if (xen_hvm_domain()) {
예제 #17
0
파일: gvt.c 프로젝트: igithubaccount/linux
/**
 * intel_gvt_init_host - Load MPT modules and detect if we're running in host
 * @gvt: intel gvt device
 *
 * This function is called at the driver loading stage. If failed to find a
 * loadable MPT module or detect currently we're running in a VM, then GVT-g
 * will be disabled
 *
 * Returns:
 * Zero on success, negative error code if failed.
 *
 */
int intel_gvt_init_host(void)
{
	int ret;

	if (intel_gvt_host.initialized)
		return 0;

	/* Xen DOM U */
	if (xen_domain() && !xen_initial_domain())
		return -ENODEV;

	/* Try to load MPT modules for hypervisors */
	if (xen_initial_domain()) {
		/* In Xen dom0 */
		intel_gvt_host.mpt = try_then_request_module(
				symbol_get(xengt_mpt), "xengt");
		intel_gvt_host.hypervisor_type = INTEL_GVT_HYPERVISOR_XEN;
	} else {
#if IS_ENABLED(CONFIG_DRM_I915_GVT_KVMGT)
		/* not in Xen. Try KVMGT */
		intel_gvt_host.mpt = try_then_request_module(
				symbol_get(kvmgt_mpt), "kvmgt");
		intel_gvt_host.hypervisor_type = INTEL_GVT_HYPERVISOR_KVM;
#endif
	}

	/* Fail to load MPT modules - bail out */
	if (!intel_gvt_host.mpt)
		return -EINVAL;

	/* Try to detect if we're running in host instead of VM. */
	ret = intel_gvt_hypervisor_detect_host();
	if (ret)
		return -ENODEV;

	gvt_dbg_core("Running with hypervisor %s in host mode\n",
			supported_hypervisors[intel_gvt_host.hypervisor_type]);

	intel_gvt_host.initialized = true;
	return 0;
}
예제 #18
0
static int __init hyper_sysfs_init(void)
{
	int ret;

	if (!xen_domain())
		return -ENODEV;

	ret = xen_sysfs_type_init();
	if (ret)
		goto out;
	ret = xen_sysfs_version_init();
	if (ret)
		goto version_out;
	ret = xen_compilation_init();
	if (ret)
		goto comp_out;
	ret = xen_sysfs_uuid_init();
	if (ret)
		goto uuid_out;
	ret = xen_properties_init();
	if (ret)
		goto prop_out;
	ret = xen_vmcoreinfo_init();
	if (ret)
		goto vmcoreinfo_out;

	goto out;

vmcoreinfo_out:
	xen_properties_destroy();
prop_out:
	xen_sysfs_uuid_destroy();
uuid_out:
	xen_compilation_destroy();
comp_out:
	xen_sysfs_version_destroy();
version_out:
	xen_sysfs_type_destroy();
out:
	return ret;
}
예제 #19
0
static int __init evtchn_init(void)
{
	int err;

	if (!xen_domain())
		return -ENODEV;

	spin_lock_init(&port_user_lock);
	memset(port_user, 0, sizeof(port_user));

	/* Create '/dev/misc/evtchn'. */
	err = misc_register(&evtchn_miscdev);
	if (err != 0) {
		printk(KERN_ALERT "Could not register /dev/misc/evtchn\n");
		return err;
	}

	printk(KERN_INFO "Event-channel device installed.\n");

	return 0;
}
예제 #20
0
static int setup_cpu_watcher(struct notifier_block *notifier,
			      unsigned long event, void *data)
{
	int cpu;
	static struct xenbus_watch cpu_watch = {
		.node = "cpu",
		.callback = handle_vcpu_hotplug_event};

	(void)register_xenbus_watch(&cpu_watch);

	for_each_possible_cpu(cpu) {
		if (vcpu_online(cpu) == 0) {
			(void)cpu_down(cpu);
			set_cpu_present(cpu, false);
		}
	}

	return NOTIFY_DONE;
}

static int __init setup_vcpu_hotplug_event(void)
{
	static struct notifier_block xsn_cpu = {
		.notifier_call = setup_cpu_watcher };

#ifdef CONFIG_X86
	if (!xen_pv_domain() && !xen_pvh_domain())
#else
	if (!xen_domain())
#endif
		return -ENODEV;

	register_xenstore_notifier(&xsn_cpu);

	return 0;
}

arch_initcall(setup_vcpu_hotplug_event);
예제 #21
0
/*
 * Allocate and fill in the hypcall page.
 */
int
xen_hvm_init_hypercall_stubs(enum xen_hvm_init_type init_type)
{
	uint32_t regs[4];

	/* Legacy PVH will get here without the cpuid leaf being set. */
	if (cpuid_base == 0)
		cpuid_base = xen_hvm_cpuid_base();
	if (cpuid_base == 0)
		return (ENXIO);

	if (xen_domain() && init_type == XEN_HVM_INIT_LATE) {
		/*
		 * If the domain type is already set we can assume that the
		 * hypercall page has been populated too, so just print the
		 * version (and apply any quirks) and exit.
		 */
		hypervisor_version();
		return 0;
	}

	if (init_type == XEN_HVM_INIT_LATE)
		hypervisor_version();

	/*
	 * Find the hypercall pages.
	 */
	do_cpuid(cpuid_base + 2, regs);
	if (regs[0] != 1)
		return (EINVAL);

	wrmsr(regs[1], (init_type == XEN_HVM_INIT_EARLY)
	    ? ((vm_paddr_t)&hypercall_page - KERNBASE)
	    : vtophys(&hypercall_page));

	return (0);
}
예제 #22
0
파일: omx_xen.c 프로젝트: ananos/xen2mx
int omx_xenfront_init(void)
{
	int ret = 0;
	dprintk_in();

	if (!xen_domain() || xen_initial_domain()) {
		ret = -ENODEV;
		printk_err
		    ("We are not running under Xen, or this "
		     "*is* a privileged domain\n");
		goto out;
	}

	ret = xenbus_register_frontend(&omx_xenfront_driver);
	if (ret) {
		printk_err("XenBus Registration Failed\n");
		goto out;
	}

	printk_inf("init\n");
out:
	dprintk_out();
	return ret;
}
/*
 * On a 5-minute timeout, wait for all devices currently configured.  We need
 * to do this to guarantee that the filesystems and / or network devices
 * needed for boot are available, before we can allow the boot to proceed.
 *
 * This needs to be on a late_initcall, to happen after the frontend device
 * drivers have been initialised, but before the root fs is mounted.
 *
 * A possible improvement here would be to have the tools add a per-device
 * flag to the store entry, indicating whether it is needed at boot time.
 * This would allow people who knew what they were doing to accelerate their
 * boot slightly, but of course needs tools or manual intervention to set up
 * those flags correctly.
 */
static void wait_for_devices(struct xenbus_driver *xendrv)
{
	unsigned long start = jiffies;
	struct device_driver *drv = xendrv ? &xendrv->driver : NULL;
	unsigned int seconds_waited = 0;

	if (!ready_to_wait_for_devices || !xen_domain())
		return;

	while (exists_non_essential_connecting_device(drv))
		if (wait_loop(start, 30, &seconds_waited))
			break;

	/* Skips PVKB and PVFB check.*/
	while (exists_essential_connecting_device(drv))
		if (wait_loop(start, 270, &seconds_waited))
			break;

	if (seconds_waited)
		printk("\n");

	bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
			 print_device_status);
}
예제 #24
0
static int __init evtchn_init(void)
{
	int err;

	if (!xen_domain())
		return -ENODEV;

	port_user = kcalloc(NR_EVENT_CHANNELS, sizeof(*port_user), GFP_KERNEL);
	if (port_user == NULL)
		return -ENOMEM;

	spin_lock_init(&port_user_lock);

	/* Create '/dev/misc/evtchn'. */
	err = misc_register(&evtchn_miscdev);
	if (err != 0) {
		printk(KERN_ALERT "Could not register /dev/misc/evtchn\n");
		return err;
	}

	printk(KERN_INFO "Event-channel device installed.\n");

	return 0;
}
예제 #25
0
static int __init xenbus_init(void)
{
	int err = 0;

	DPRINTK("");

	err = -ENODEV;
	if (!xen_domain())
		goto out_error;

	/* Register ourselves with the kernel bus subsystem */
	err = bus_register(&xenbus_frontend.bus);
	if (err)
		goto out_error;

	err = xenbus_backend_bus_register();
	if (err)
		goto out_unreg_front;

	/*
	 * Domain0 doesn't have a store_evtchn or store_mfn yet.
	 */
	if (xen_initial_domain()) {
		/* dom0 not yet supported */
	} else {
		if (xen_hvm_domain()) {
			uint64_t v = 0;
			err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
			if (err)
				goto out_error;
			xen_store_evtchn = (int)v;
			err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
			if (err)
				goto out_error;
			xen_store_mfn = (unsigned long)v;
			xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
		} else {
			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);
			xenstored_ready = 1;
		}
	}

	/* Initialize the interface to xenstore. */
	err = xs_init();
	if (err) {
		printk(KERN_WARNING
		       "XENBUS: Error initializing xenstore comms: %i\n", err);
		goto out_unreg_back;
	}

#ifdef CONFIG_XEN_COMPAT_XENFS
	/*
	 * Create xenfs mountpoint in /proc for compatibility with
	 * utilities that expect to find "xenbus" under "/proc/xen".
	 */
	proc_mkdir("xen", NULL);
#endif

	return 0;

  out_unreg_back:
	xenbus_backend_bus_unregister();

  out_unreg_front:
	bus_unregister(&xenbus_frontend.bus);

  out_error:
	return err;
}
예제 #26
0
}

MTX_SYSINIT(gnttab, &gnttab_list_lock, "GNTTAB LOCK", MTX_DEF); 

/*------------------ Private Device Attachment Functions  --------------------*/
/**
 * \brief Identify instances of this device type in the system.
 *
 * \param driver  The driver performing this identify action.
 * \param parent  The NewBus parent device for any devices this method adds.
 */
static void
granttable_identify(driver_t *driver __unused, device_t parent)
{

	KASSERT(xen_domain(),
	    ("Trying to attach grant-table device on non Xen domain"));
	/*
	 * A single device instance for our driver is always present
	 * in a system operating under Xen.
	 */
	if (BUS_ADD_CHILD(parent, 0, driver->name, 0) == NULL)
		panic("unable to attach Xen Grant-table device");
}

/**
 * \brief Probe for the existence of the Xen Grant-table device
 *
 * \param dev  NewBus device_t for this instance.
 *
 * \return  Always returns 0 indicating success.
예제 #27
0
static int __init xenbus_init(void)
{
	int err = 0;
	enum xenstore_init usage = UNKNOWN;
	uint64_t v = 0;

	if (!xen_domain())
		return -ENODEV;

	xenbus_ring_ops_init();

	if (xen_pv_domain())
		usage = PV;
	if (xen_hvm_domain())
		usage = HVM;
	if (xen_hvm_domain() && xen_initial_domain())
		usage = LOCAL;
	if (xen_pv_domain() && !xen_start_info->store_evtchn)
		usage = LOCAL;
	if (xen_pv_domain() && xen_start_info->store_evtchn)
		xenstored_ready = 1;

	switch (usage) {
	case LOCAL:
		err = xenstored_local_init();
		if (err)
			goto out_error;
		xen_store_interface = mfn_to_virt(xen_store_mfn);
		break;
	case PV:
		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);
		break;
	case HVM:
		err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
		if (err)
			goto out_error;
		xen_store_evtchn = (int)v;
		err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
		if (err)
			goto out_error;
		xen_store_mfn = (unsigned long)v;
		xen_store_interface =
			xen_remap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
		break;
	default:
		pr_warn("Xenstore state unknown\n");
		break;
	}

	/* Initialize the interface to xenstore. */
	err = xs_init();
	if (err) {
		printk(KERN_WARNING
		       "XENBUS: Error initializing xenstore comms: %i\n", err);
		goto out_error;
	}

#ifdef CONFIG_XEN_COMPAT_XENFS
	/*
	 * Create xenfs mountpoint in /proc for compatibility with
	 * utilities that expect to find "xenbus" under "/proc/xen".
	 */
	proc_mkdir("xen", NULL);
#endif

out_error:
	return err;
}
static int __init xenbus_probe_init(void)
{
	int err = 0;

	DPRINTK("");

	err = -ENODEV;
	if (!xen_domain())
		goto out_error;

	/* Register ourselves with the kernel bus subsystem */
	err = bus_register(&xenbus_frontend.bus);
	if (err)
		goto out_error;

	err = xenbus_backend_bus_register();
	if (err)
		goto out_unreg_front;

	/*
	 * Domain0 doesn't have a store_evtchn or store_mfn yet.
	 */
	if (xen_initial_domain()) {
		/* dom0 not yet supported */
	} else {
		xenstored_ready = 1;
		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);

	/* Initialize the interface to xenstore. */
	err = xs_init();
	if (err) {
		printk(KERN_WARNING
		       "XENBUS: Error initializing xenstore comms: %i\n", err);
		goto out_unreg_back;
	}

	if (!xen_initial_domain())
		xenbus_probe(NULL);

#ifdef CONFIG_XEN_COMPAT_XENFS
	/*
	 * Create xenfs mountpoint in /proc for compatibility with
	 * utilities that expect to find "xenbus" under "/proc/xen".
	 */
	proc_mkdir("xen", NULL);
#endif

	return 0;

  out_unreg_back:
	xenbus_backend_bus_unregister();

  out_unreg_front:
	bus_unregister(&xenbus_frontend.bus);

  out_error:
	return err;
}
예제 #29
0
파일: xenbus_probe.c 프로젝트: 020gzh/linux
static int __init xenbus_init(void)
{
	int err = 0;
	uint64_t v = 0;
	xen_store_domain_type = XS_UNKNOWN;

	if (!xen_domain())
		return -ENODEV;

	xenbus_ring_ops_init();

	if (xen_pv_domain())
		xen_store_domain_type = XS_PV;
	if (xen_hvm_domain())
		xen_store_domain_type = XS_HVM;
	if (xen_hvm_domain() && xen_initial_domain())
		xen_store_domain_type = XS_LOCAL;
	if (xen_pv_domain() && !xen_start_info->store_evtchn)
		xen_store_domain_type = XS_LOCAL;
	if (xen_pv_domain() && xen_start_info->store_evtchn)
		xenstored_ready = 1;

	switch (xen_store_domain_type) {
	case XS_LOCAL:
		err = xenstored_local_init();
		if (err)
			goto out_error;
		xen_store_interface = gfn_to_virt(xen_store_gfn);
		break;
	case XS_PV:
		xen_store_evtchn = xen_start_info->store_evtchn;
		xen_store_gfn = xen_start_info->store_mfn;
		xen_store_interface = gfn_to_virt(xen_store_gfn);
		break;
	case XS_HVM:
		err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
		if (err)
			goto out_error;
		xen_store_evtchn = (int)v;
		err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
		if (err)
			goto out_error;
		xen_store_gfn = (unsigned long)v;
		xen_store_interface =
			xen_remap(xen_store_gfn << XEN_PAGE_SHIFT,
				  XEN_PAGE_SIZE);
		break;
	default:
		pr_warn("Xenstore state unknown\n");
		break;
	}

	/* Initialize the interface to xenstore. */
	err = xs_init();
	if (err) {
		pr_warn("Error initializing xenstore comms: %i\n", err);
		goto out_error;
	}

	if ((xen_store_domain_type != XS_LOCAL) &&
	    (xen_store_domain_type != XS_UNKNOWN))
		xen_resume_notifier_register(&xenbus_resume_nb);

#ifdef CONFIG_XEN_COMPAT_XENFS
	/*
	 * Create xenfs mountpoint in /proc for compatibility with
	 * utilities that expect to find "xenbus" under "/proc/xen".
	 */
	proc_mkdir("xen", NULL);
#endif

out_error:
	return err;
}