WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Introduce is_running_on_xen() to test whether we are run

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Introduce is_running_on_xen() to test whether we are running on Xen before
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 19 May 2006 17:26:11 +0000
Delivery-date: Fri, 19 May 2006 10:28:33 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID b736d3335641c0ca531d2e59695ebde4fac1bf8b
# Parent  1855124935e2810ebb1e8c577dadacc079f6487e
Introduce is_running_on_xen() to test whether we are running on Xen before
initialising a Xen-specific driver or subsystem.

For ia64:
 * Call xen_init in setup_arch.
 * Remove xen_ksyms.c

Signed-off-by: Tristan Gingold <tristan.gingold@xxxxxxxx>
---
 linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c                  |   12 
----------
 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c                 |    1 
 linux-2.6-xen-sparse/arch/ia64/kernel/setup.c                   |    3 ++
 linux-2.6-xen-sparse/arch/ia64/xen/Makefile                     |    4 +--
 linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c       |    7 ++++-
 linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S                   |   12 
----------
 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c              |    4 +--
 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c              |    2 -
 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c            |    2 -
 linux-2.6-xen-sparse/drivers/xen/console/console.c              |    4 +--
 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c                  |    2 -
 linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c        |    3 ++
 linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c               |    7 +++++
 linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c                |    3 ++
 linux-2.6-xen-sparse/drivers/xen/netback/netback.c              |    3 ++
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c            |    3 ++
 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c              |    3 ++
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c          |    8 +-----
 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h |    2 -
 linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h              |    6 ++---
 linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h              |    5 ----
 21 files changed, 45 insertions(+), 51 deletions(-)

diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c   Fri May 19 15:22:11 
2006 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c   Fri May 19 15:35:19 
2006 +0100
@@ -191,6 +191,7 @@ swiotlb_init(void)
        if (swiotlb_force == 1) {
                swiotlb = 1;
        } else if ((swiotlb_force != -1) &&
+                  is_running_on_xen() &&
                   (xen_start_info->flags & SIF_INITDOMAIN)) {
                /* Domain 0 always has a swiotlb. */
                ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/arch/ia64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c     Fri May 19 15:22:11 
2006 +0100
+++ b/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c     Fri May 19 15:35:19 
2006 +0100
@@ -514,6 +514,9 @@ setup_arch (char **cmdline_p)
 #ifdef CONFIG_XEN
        if (running_on_xen) {
                extern shared_info_t *HYPERVISOR_shared_info;
+               extern int xen_init (void);
+
+               xen_init ();
 
                /* xen_start_info isn't setup yet, get the flags manually */
                if (HYPERVISOR_shared_info->arch.flags & SIF_INITDOMAIN) {
diff -r 1855124935e2 -r b736d3335641 linux-2.6-xen-sparse/arch/ia64/xen/Makefile
--- a/linux-2.6-xen-sparse/arch/ia64/xen/Makefile       Fri May 19 15:22:11 
2006 +0100
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/Makefile       Fri May 19 15:35:19 
2006 +0100
@@ -2,7 +2,7 @@
 # Makefile for Xen components
 #
 
-obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o 
xenconsole.o xen_ksyms.o
+obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o 
xenconsole.o
 
 obj-$(CONFIG_XEN_IA64_DOM0_VP) += hypervisor.o pci-dma-xen.o
-pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
\ No newline at end of file
+pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c Fri May 19 
15:35:19 2006 +0100
@@ -11,17 +11,20 @@ shared_info_t *HYPERVISOR_shared_info = 
 shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)XSI_BASE;
 EXPORT_SYMBOL(HYPERVISOR_shared_info);
 
-static int initialized;
 start_info_t *xen_start_info;
+
+int running_on_xen;
+EXPORT_SYMBOL(running_on_xen);
 
 int xen_init(void)
 {
+       static int initialized;
        shared_info_t *s = HYPERVISOR_shared_info;
 
        if (initialized)
                return running_on_xen ? 0 : -1;
 
-       if (!running_on_xen)
+       if (!is_running_on_xen())
                return -1;
 
        xen_start_info = __va(s->arch.start_info_pfn << PAGE_SHIFT);
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S     Fri May 19 15:22:11 
2006 +0100
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S     Fri May 19 15:35:19 
2006 +0100
@@ -7,12 +7,6 @@
 #include <linux/config.h>
 #include <asm/processor.h>
 #include <asm/asmmacro.h>
-
-       .data
-       .align 8
-       .globl running_on_xen
-running_on_xen:
-       data4 0
 
 #define isBP   p3      // are we the Bootstrap Processor?
 
@@ -27,9 +21,3 @@ GLOBAL_ENTRY(early_xen_setup)
 (p7)   mov cr.iva=r10
        br.ret.sptk.many rp;;
 END(early_xen_setup)
-
-GLOBAL_ENTRY(is_running_on_xen)
-       movl r9=running_on_xen;;
-       ld4 r8=[r9]
-       br.ret.sptk.many rp;;
-END(is_running_on_xen)
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Fri May 19 
15:35:19 2006 +0100
@@ -468,8 +468,8 @@ static int __init balloon_init(void)
 
        IPRINTK("Initialising balloon driver.\n");
 
-       if (xen_init() < 0)
-               return -1;
+       if (!is_running_on_xen())
+               return -ENODEV;
 
        current_pages = min(xen_start_info->nr_pages, max_pfn);
        totalram_pages = current_pages;
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Fri May 19 
15:35:19 2006 +0100
@@ -526,7 +526,7 @@ static int __init blkif_init(void)
        struct page *page;
        int i;
 
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return -ENODEV;
 
        mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Fri May 19 
15:35:19 2006 +0100
@@ -792,7 +792,7 @@ static struct xenbus_driver blkfront = {
 
 static int __init xlblk_init(void)
 {
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return -ENODEV;
 
        return xenbus_register_frontend(&blkfront);
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/console/console.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/console.c        Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c        Fri May 19 
15:35:19 2006 +0100
@@ -183,7 +183,7 @@ static struct console kcons_info = {
 #define __RETCODE 0
 static int __init xen_console_init(void)
 {
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return __RETCODE;
 
        if (xen_start_info->flags & SIF_INITDOMAIN) {
@@ -566,7 +566,7 @@ static int __init xencons_init(void)
 {
        int rc;
 
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return -ENODEV;
 
        if (xc_mode == XC_OFF)
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Fri May 19 15:22:11 
2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Fri May 19 15:35:19 
2006 +0100
@@ -443,7 +443,7 @@ gnttab_init(void)
 {
        int i;
 
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return -ENODEV;
 
        if (gnttab_resume() < 0)
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c  Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c  Fri May 19 
15:35:19 2006 +0100
@@ -49,6 +49,9 @@ static struct kobj_type hyp_sysfs_kobj_t
 
 static int __init hypervisor_subsys_init(void)
 {
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
        return subsystem_register(&hypervisor_subsys);
 }
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c Fri May 19 15:22:11 
2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c Fri May 19 15:35:19 
2006 +0100
@@ -276,7 +276,12 @@ static void xen_properties_destroy(void)
 
 static int __init hyper_sysfs_init(void)
 {
-       int ret = xen_sysfs_type_init();
+       int ret;
+
+       if (!is_running_on_xen())
+               return -ENODEV;
+
+       ret = xen_sysfs_type_init();
        if (ret)
                goto out;
        ret = xen_sysfs_version_init();
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c
--- a/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c  Fri May 19 15:22:11 
2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c  Fri May 19 15:35:19 
2006 +0100
@@ -429,6 +429,9 @@ static int __init evtchn_init(void)
 {
        int err;
 
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        spin_lock_init(&port_user_lock);
        memset(port_user, 0, sizeof(port_user));
 
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Fri May 19 
15:35:19 2006 +0100
@@ -810,6 +810,9 @@ static int __init netback_init(void)
        int i;
        struct page *page;
 
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        /* We can increase reservation by this much in net_rx_action(). */
        balloon_update_driver_allowance(NET_RX_RING_SIZE);
 
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Fri May 19 
15:35:19 2006 +0100
@@ -1454,6 +1454,9 @@ static struct notifier_block notifier_in
 
 static int __init netif_init(void)
 {
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        if (xen_start_info->flags & SIF_INITDOMAIN)
                return 0;
 
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c        Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c        Fri May 19 
15:35:19 2006 +0100
@@ -271,6 +271,9 @@ static int capabilities_read(char *page,
 
 static int __init privcmd_init(void)
 {
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        /* Set of hypercalls that privileged applications may execute. */
        set_bit(__HYPERVISOR_acm_op,           hypercall_permission_map);
        set_bit(__HYPERVISOR_dom0_op,          hypercall_permission_map);
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Fri May 19 
15:35:19 2006 +0100
@@ -966,10 +966,8 @@ static int __init xenbus_probe_init(void
 
        DPRINTK("");
 
-       if (xen_init() < 0) {
-               DPRINTK("failed");
+       if (!is_running_on_xen())
                return -ENODEV;
-       }
 
        /* Register ourselves with the kernel bus subsystem */
        bus_register(&xenbus_frontend.bus);
@@ -1069,10 +1067,8 @@ static int __init wait_for_devices(void)
 {
        unsigned long timeout = jiffies + 10*HZ;
 
-       if (xen_init() < 0) {
-               DPRINTK("failed");
+       if (!is_running_on_xen())
                return -ENODEV;
-       }
 
        while (time_before(jiffies, timeout)) {
                if (all_devices_ready())
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h   Fri May 
19 15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h   Fri May 
19 15:35:19 2006 +0100
@@ -118,7 +118,7 @@ u64 jiffies_to_st(unsigned long jiffies)
 #define MULTI_UVMDOMID_INDEX 4
 #endif
 
-#define xen_init()     (0)
+#define is_running_on_xen() 1
 
 static inline int
 HYPERVISOR_yield(
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h        Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h        Fri May 19 
15:35:19 2006 +0100
@@ -53,7 +53,7 @@ extern start_info_t *xen_start_info;
 
 void force_evtchn_callback(void);
 
-int xen_init(void);
+#define is_running_on_xen() running_on_xen
 
 /* Turn jiffies into Xen system time. XXX Implement me. */
 #define jiffies_to_st(j)       0
@@ -147,7 +147,7 @@ xen_create_contiguous_region(unsigned lo
                              unsigned int order, unsigned int address_bits)
 {
        int ret = 0;
-       if (running_on_xen) {
+       if (is_running_on_xen()) {
                ret = __xen_create_contiguous_region(vstart, order,
                                                     address_bits);
        }
@@ -158,7 +158,7 @@ static inline void
 static inline void
 xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
 {
-       if (running_on_xen)
+       if (is_running_on_xen())
                __xen_destroy_contiguous_region(vstart, order);
 }
 #else
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h        Fri May 19 
15:22:11 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h        Fri May 19 
15:35:19 2006 +0100
@@ -41,12 +41,7 @@
 #endif
 
 #ifndef __ASSEMBLY__
-#ifdef MODULE
-extern int is_running_on_xen(void);
-#define running_on_xen (is_running_on_xen())
-#else
 extern int running_on_xen;
-#endif
 
 #define        XEN_HYPER_SSM_I                 asm("break 0x7");
 #define        XEN_HYPER_GET_IVR               asm("break 0x8");
diff -r 1855124935e2 -r b736d3335641 
linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c    Fri May 19 15:22:11 
2006 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * Architecture-specific kernel symbols
- *
- * Don't put any exports here unless it's defined in an assembler file.
- * All other exports should be put directly after the definition.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-extern int is_running_on_xen(void);
-EXPORT_SYMBOL(is_running_on_xen);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Introduce is_running_on_xen() to test whether we are running on Xen before, Xen patchbot-unstable <=