]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
xen: clean up domain mode predicates
authorJeremy Fitzhardinge <jeremy@goop.org>
Tue, 19 Aug 2008 20:16:17 +0000 (13:16 -0700)
committerIngo Molnar <mingo@elte.hu>
Wed, 20 Aug 2008 10:40:07 +0000 (12:40 +0200)
There are four operating modes Xen code may find itself running in:
 - native
 - hvm domain
 - pv dom0
 - pv domU

Clean up predicates for testing for these states to make them more consistent.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Xen-devel <xen-devel@lists.xensource.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/xen/enlighten.c
drivers/block/xen-blkfront.c
drivers/char/hvc_xen.c
drivers/input/xen-kbdfront.c
drivers/net/xen-netfront.c
drivers/video/xen-fbfront.c
drivers/xen/balloon.c
drivers/xen/grant-table.c
drivers/xen/xenbus/xenbus_probe.c
include/asm-x86/xen/hypervisor.h

index 53afa14eb3145c86e157f614f5a85f3cb0fc6091..b106e825d2661812168059c736dbdb7ba3d54f9c 100644 (file)
@@ -56,6 +56,9 @@ EXPORT_SYMBOL_GPL(hypercall_page);
 DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
 DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);
 
+enum xen_domain_type xen_domain_type = XEN_NATIVE;
+EXPORT_SYMBOL_GPL(xen_domain_type);
+
 /*
  * Identity map, in addition to plain kernel map.  This needs to be
  * large enough to allocate page table pages to allocate the rest.
@@ -1613,6 +1616,8 @@ asmlinkage void __init xen_start_kernel(void)
        if (!xen_start_info)
                return;
 
+       xen_domain_type = XEN_PV_DOMAIN;
+
        BUG_ON(memcmp(xen_start_info->magic, "xen-3", 5) != 0);
 
        xen_setup_features();
@@ -1650,7 +1655,7 @@ asmlinkage void __init xen_start_kernel(void)
 
        /* Prevent unwanted bits from being set in PTEs. */
        __supported_pte_mask &= ~_PAGE_GLOBAL;
-       if (!is_initial_xendomain())
+       if (!xen_initial_domain())
                __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD);
 
        /* Don't do the full vcpu_info placement stuff until we have a
@@ -1685,7 +1690,7 @@ asmlinkage void __init xen_start_kernel(void)
        boot_params.hdr.ramdisk_size = xen_start_info->mod_len;
        boot_params.hdr.cmd_line_ptr = __pa(xen_start_info->cmd_line);
 
-       if (!is_initial_xendomain()) {
+       if (!xen_initial_domain()) {
                add_preferred_console("xenboot", 0, NULL);
                add_preferred_console("tty", 0, NULL);
                add_preferred_console("hvc", 0, NULL);
index 3ca643cafccdc6be26bb24532db09ccddeff12f9..d5e753255153cb2e40232d72ab8b9be4551ec44b 100644 (file)
@@ -1032,7 +1032,7 @@ static struct xenbus_driver blkfront = {
 
 static int __init xlblk_init(void)
 {
-       if (!is_running_on_xen())
+       if (!xen_domain())
                return -ENODEV;
 
        if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) {
index 6b70aa66a587883bf56f4ca3163ac7828afc3eae..538ceea5e7df364a1f059a482b6cc0adc1d68bc6 100644 (file)
@@ -108,8 +108,8 @@ static int __init xen_init(void)
 {
        struct hvc_struct *hp;
 
-       if (!is_running_on_xen() ||
-           is_initial_xendomain() ||
+       if (!xen_pv_domain() ||
+           xen_initial_domain() ||
            !xen_start_info->console.domU.evtchn)
                return -ENODEV;
 
@@ -142,7 +142,7 @@ static void __exit xen_fini(void)
 
 static int xen_cons_init(void)
 {
-       if (!is_running_on_xen())
+       if (!xen_pv_domain())
                return 0;
 
        hvc_instantiate(HVC_COOKIE, 0, &hvc_ops);
index 9ce3b3baf3a20b3cac63695bbe327048cab4b246..3ab6362f043c0e9db3d08f00b5f60db92da1f795 100644 (file)
@@ -335,11 +335,11 @@ static struct xenbus_driver xenkbd = {
 
 static int __init xenkbd_init(void)
 {
-       if (!is_running_on_xen())
+       if (!xen_domain())
                return -ENODEV;
 
        /* Nothing to do if running in dom0. */
-       if (is_initial_xendomain())
+       if (xen_initial_domain())
                return -ENODEV;
 
        return xenbus_register_frontend(&xenkbd);
index c749bdba214ce1fb686daaa2c80eda4237f49fcc..3c3dd403f5ddd9f58bed9f632baad6b72409e0ee 100644 (file)
@@ -1794,10 +1794,10 @@ static struct xenbus_driver netfront = {
 
 static int __init netif_init(void)
 {
-       if (!is_running_on_xen())
+       if (!xen_domain())
                return -ENODEV;
 
-       if (is_initial_xendomain())
+       if (xen_initial_domain())
                return 0;
 
        printk(KERN_INFO "Initialising Xen virtual ethernet driver.\n");
@@ -1809,7 +1809,7 @@ module_init(netif_init);
 
 static void __exit netif_exit(void)
 {
-       if (is_initial_xendomain())
+       if (xen_initial_domain())
                return;
 
        xenbus_unregister_driver(&netfront);
index 47ed39b52f9c32162e5265404a5aacff9f9fbebe..a463b3dd837b5b9d6db40f68081fca7f89678e0f 100644 (file)
@@ -680,11 +680,11 @@ static struct xenbus_driver xenfb = {
 
 static int __init xenfb_init(void)
 {
-       if (!is_running_on_xen())
+       if (!xen_domain())
                return -ENODEV;
 
        /* Nothing to do if running in dom0. */
-       if (is_initial_xendomain())
+       if (xen_initial_domain())
                return -ENODEV;
 
        return xenbus_register_frontend(&xenfb);
index fff987b10e0f2fdd54da38f5692f9540d74713ca..a51f3e17a5fd724b8a4d282b3d2518e40172f26f 100644 (file)
@@ -419,7 +419,7 @@ static int __init balloon_init(void)
        unsigned long pfn;
        struct page *page;
 
-       if (!is_running_on_xen())
+       if (!xen_pv_domain())
                return -ENODEV;
 
        pr_info("xen_balloon: Initialising balloon driver.\n");
index e9e11168616af7a014b3d51db4a9ccc35208bbf5..06592b9da83c454a0117d8d9bf6c86633787e3d7 100644 (file)
@@ -508,7 +508,7 @@ static int __devinit gnttab_init(void)
        unsigned int max_nr_glist_frames, nr_glist_frames;
        unsigned int nr_init_grefs;
 
-       if (!is_running_on_xen())
+       if (!xen_domain())
                return -ENODEV;
 
        nr_grant_frames = 1;
index 57ceb5346b749338e153ccdbeaf4bf5ceb09c19f..7f24a98a446f53e0a7fd2bd0ec518494ca7e72cd 100644 (file)
@@ -814,7 +814,7 @@ static int __init xenbus_probe_init(void)
        DPRINTK("");
 
        err = -ENODEV;
-       if (!is_running_on_xen())
+       if (!xen_domain())
                goto out_error;
 
        /* Register ourselves with the kernel bus subsystem */
@@ -829,7 +829,7 @@ static int __init xenbus_probe_init(void)
        /*
         * Domain0 doesn't have a store_evtchn or store_mfn yet.
         */
-       if (is_initial_xendomain()) {
+       if (xen_initial_domain()) {
                /* dom0 not yet supported */
        } else {
                xenstored_ready = 1;
@@ -846,7 +846,7 @@ static int __init xenbus_probe_init(void)
                goto out_unreg_back;
        }
 
-       if (!is_initial_xendomain())
+       if (!xen_initial_domain())
                xenbus_probe(NULL);
 
        return 0;
@@ -937,7 +937,7 @@ 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 || !is_running_on_xen())
+       if (!ready_to_wait_for_devices || !xen_domain())
                return;
 
        while (exists_disconnected_device(drv)) {
index 8e15dd28c91fc18d116f34e0f69b030d444f3305..d9dd28caa50856da8dd6ff8e4075766482c4c98e 100644 (file)
@@ -55,7 +55,6 @@
 /* arch/i386/kernel/setup.c */
 extern struct shared_info *HYPERVISOR_shared_info;
 extern struct start_info *xen_start_info;
-#define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN)
 
 /* arch/i386/mach-xen/evtchn.c */
 /* Force a proper event-channel callback from Xen. */
@@ -68,6 +67,17 @@ u64 jiffies_to_st(unsigned long jiffies);
 #define MULTI_UVMFLAGS_INDEX 3
 #define MULTI_UVMDOMID_INDEX 4
 
-#define is_running_on_xen()    (xen_start_info ? 1 : 0)
+enum xen_domain_type {
+       XEN_NATIVE,
+       XEN_PV_DOMAIN,
+       XEN_HVM_DOMAIN,
+};
+
+extern enum xen_domain_type xen_domain_type;
+
+#define xen_domain()           (xen_domain_type != XEN_NATIVE)
+#define xen_pv_domain()                (xen_domain_type == XEN_PV_DOMAIN)
+#define xen_initial_domain()   (xen_pv_domain() && xen_start_info->flags & SIF_INITDOMAIN)
+#define xen_hvm_domain()       (xen_domain_type == XEN_HVM_DOMAIN)
 
 #endif /* __HYPERVISOR_H__ */