Skip to contentSkip to conversation

PATCH: fix transparent virtualization issue

PATCH Tristan Gingold 2 participants 6 messages May 17, 2006 – May 19, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

this patch fixes a few transparent virtualization (ie running xenolinux on bare platform) issues for xen/ia64.

Tristan.

# HG changeset patch
# User [email protected]
# Node ID 5e930cae1bb9b32655214cbb47ccf1e26ea44a4d
# Parent f2118e8d303fff0b42f7b2fa4df9fccd52757c2f
Keep transparent virtualzation working (net front & back, swiotlb).

linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c +1 -0
diff -r f2118e8d303f -r 5e930cae1bb9 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
@@ -191,6 +191,7 @@
 	if (swiotlb_force == 1) {
 		swiotlb = 1;
 	} else if ((swiotlb_force != -1) &&
+		   xen_start_info &&
 		   (xen_start_info->flags & SIF_INITDOMAIN)) {
 		/* Domain 0 always has a swiotlb. */
 		ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
linux-2.6-xen-sparse/drivers/xen/netback/netback.c +3 -0
diff -r f2118e8d303f -r 5e930cae1bb9 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
@@ -808,6 +808,9 @@
 	int i;
 	struct page *page;
 
+	if (xen_init () < 0)
+		return 0;
+
 	/* We can increase reservation by this much in net_rx_action(). */
 	balloon_update_driver_allowance(NET_RX_RING_SIZE);
 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +1 -1
diff -r f2118e8d303f -r 5e930cae1bb9 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
@@ -1341,7 +1341,7 @@
 {
 	int err = 0;
 
-	if (xen_start_info->flags & SIF_INITDOMAIN)
+	if (xen_start_info == NULL || xen_start_info->flags & SIF_INITDOMAIN)
 		return 0;
 
 	if ((err = xennet_proc_init()) != 0)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 2 lines · Tristan Gingold

this patch fixes a few transparent virtualization (ie running xenolinux on bare platform) issues for xen/ia64.

Why not call xen_init() in the two places you added NULL check for xen_start_info? Especially in netfront -- you already call xen_init() in blkfront, so it seems weird not to do so in netfront. I see no reason not to call it in swiotlb.c too.

xen_init() is a pretty bad name by the way, seeing as it's called all over the place so it's not really initialising xen state at every call site. Given that it is used in most places for the caller to determine if you are running on Xen or not, why not call it running_on_xen() and have the initialisation on the first call just be a hidden side effect?

-- Keir

#2 lore raw
Quoted 10 lines · Keir Fraser
Quoted 3 lines · Tristan Gingold

this patch fixes a few transparent virtualization (ie running xenolinux on
bare platform) issues for xen/ia64.

Why not call xen_init() in the two places you added NULL check for xen_start_info? Especially in netfront -- you already call xen_init() in blkfront, so it seems weird not to do so in netfront. I see no reason not to call it in swiotlb.c too.

Quoted 5 lines

xen_init() is a pretty bad name by the way, seeing as it's called all over the place so it's not really initialising xen state at every call site. Given that it is used in most places for the caller to determine if you are running on Xen or not, why not call it running_on_xen() and have the initialisation on the first call just be a hidden side effect?

Sure.

Tristan.

#3 lore raw

PATCH: fix transparent virtualization issue (Re)

In reply to Keir Fraser
Quoted 10 lines · Keir Fraser
Quoted 3 lines · Tristan Gingold

this patch fixes a few transparent virtualization (ie running xenolinux on
bare platform) issues for xen/ia64.

Why not call xen_init() in the two places you added NULL check for xen_start_info? Especially in netfront -- you already call xen_init() in blkfront, so it seems weird not to do so in netfront. I see no reason not to call it in swiotlb.c too.

Quoted 5 lines

xen_init() is a pretty bad name by the way, seeing as it's called all over the place so it's not really initialising xen state at every call site. Given that it is used in most places for the caller to determine if you are running on Xen or not, why not call it running_on_xen() and have the initialisation on the first call just be a hidden side effect?

Hi,

here are two patches for transparent virtualization. xen-transvirt4.diffs replaces uses of xen_init() by running_on_xen on common and x86 code.

xen-transvirt3.diffs is for xen/ia64: it add a call to xen_init() very early.

I think this is cleaner than previous way.

Tristan.

# HG changeset patch
# User [email protected]
# Node ID ce125e557225bc409186d82afe86aecdef6356dc # Parent d2f6e3d70f223f37ef468ffe7a5dcaa82cfc7c1e Replace xen_init() by running_on_xen.
Check running_on_xen before setting up a Xen driver.

linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c +1 -0
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
@@ -191,6 +191,7 @@
 	if (swiotlb_force == 1) {
 		swiotlb = 1;
 	} else if ((swiotlb_force != -1) &&
+		   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);
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c +2 -2
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
@@ -468,8 +468,8 @@
 
 	IPRINTK("Initialising balloon driver.\n");
 
-	if (xen_init() < 0)
-		return -1;
+	if (!running_on_xen)
+		return -ENODEV;
 
 	current_pages = min(xen_start_info->nr_pages, max_pfn);
 	totalram_pages = current_pages;
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c +1 -1
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
@@ -526,7 +526,7 @@
 	struct page *page;
 	int i;
 
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return -ENODEV;
 
 	mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +1 -1
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
@@ -792,7 +792,7 @@
 
 static int __init xlblk_init(void)
 {
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return -ENODEV;
 
 	return xenbus_register_frontend(&blkfront);
linux-2.6-xen-sparse/drivers/xen/console/console.c +2 -2
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/console/console.c
@@ -183,7 +183,7 @@
 #define __RETCODE 0
 static int __init xen_console_init(void)
 {
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return __RETCODE;
 
 	if (xen_start_info->flags & SIF_INITDOMAIN) {
@@ -566,7 +566,7 @@
 {
 	int rc;
 
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return -ENODEV;
 
 	if (xc_mode == XC_OFF)
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c +1 -1
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
@@ -443,7 +443,7 @@
 {
 	int i;
 
-	if (xen_init() < 0)
+	if (!running_on_xen)
 		return -ENODEV;
 
 	if (gnttab_resume() < 0)
linux-2.6-xen-sparse/drivers/xen/netback/netback.c +3 -0
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
@@ -808,6 +808,9 @@
 	int i;
 	struct page *page;
 
+	if (!running_on_xen)
+		return -ENODEV;
+
 	/* We can increase reservation by this much in net_rx_action(). */
 	balloon_update_driver_allowance(NET_RX_RING_SIZE);
 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +3 -0
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
@@ -1341,6 +1341,9 @@
 {
 	int err = 0;
 
+	if (!running_on_xen)
+		return -ENODEV;
+
 	if (xen_start_info->flags & SIF_INITDOMAIN)
 		return 0;
 
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c +3 -0
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
@@ -271,6 +271,9 @@
 
 static int __init privcmd_init(void)
 {
+	if (!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);
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +2 -6
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
@@ -966,10 +966,8 @@
 
 	DPRINTK("");
 
-	if (xen_init() < 0) {
-		DPRINTK("failed");
+	if (!running_on_xen)
 		return -ENODEV;
-	}
 
 	/* Register ourselves with the kernel bus subsystem */
 	bus_register(&xenbus_frontend.bus);
@@ -1069,10 +1067,8 @@
 {
 	unsigned long timeout = jiffies + 10*HZ;
 
-	if (xen_init() < 0) {
-		DPRINTK("failed");
+	if (!running_on_xen)
 		return -ENODEV;
-	}
 
 	while (time_before(jiffies, timeout)) {
 		if (all_devices_ready())
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h +1 -1
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
@@ -118,7 +118,7 @@
 #define MULTI_UVMDOMID_INDEX 4
 #endif
 
-#define xen_init()	(0)
+#define running_on_xen 1
 
 static inline int
 HYPERVISOR_yield(

# HG changeset patch
# User [email protected]
# Node ID 7e53a91d47ae3354779a16119f9ccb9cc40f3808
# Parent ce125e557225bc409186d82afe86aecdef6356dc Sync with transparent virtualization running_on_xen. Call xen_init in setup_arch.
Declare running_on_xen in xenia64_init.c, remove running_on_xen and is_running_on_xen from xensetup.S
Remove xen_ksyms.c

linux-2.6-xen-sparse/arch/ia64/kernel/setup.c +3 -0
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/kernel/setup.c
@@ -514,6 +514,9 @@
 #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) {
linux-2.6-xen-sparse/arch/ia64/xen/Makefile +2 -2
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/Makefile
@@ -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 util.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
linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c +4 -1
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c
@@ -11,11 +11,14 @@
 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)
linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S +0 -12
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S
@@ -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?
 
@@ -28,9 +22,3 @@
 (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)
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h +2 -1
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
@@ -53,7 +53,8 @@
 
 void force_evtchn_callback(void);
 
-int xen_init(void);
+/* True if running on xen.  */
+extern int running_on_xen;
 
 /* Turn jiffies into Xen system time. XXX Implement me. */
 #define jiffies_to_st(j)	0
linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h +0 -5
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h
@@ -42,12 +42,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 %0" : : "i" (HYPERPRIVOP_SSM_I))
 #define	XEN_HYPER_GET_IVR	asm("break %0" : : "i" (HYPERPRIVOP_GET_IVR))
linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c deleted +0 -12
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c
@@ -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-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw

Re: PATCH: fix transparent virtualization issue (Re)

Quoted 7 lines · Tristan Gingold

here are two patches for transparent virtualization. xen-transvirt4.diffs replaces uses of xen_init() by running_on_xen on common and x86 code.

xen-transvirt3.diffs is for xen/ia64: it add a call to xen_init() very early.

I think this is cleaner than previous way.

Please make running_on_xen a function rather than a variable. I see you end up turning it into a function for modules anyway, and I'd rather have a function wrapper around a variable than a variable wrapper around a function. :-) It'll give us a bit more flexibility in future too.

-- Keir

#5 lore raw

Re: PATCH: fix transparent virtualization issue (Re)

Quoted 9 lines · Keir Fraser
Quoted 8 lines · Tristan Gingold

here are two patches for transparent virtualization. xen-transvirt4.diffs replaces uses of xen_init() by running_on_xen on common
and x86 code.

xen-transvirt3.diffs is for xen/ia64: it add a call to xen_init() very early.

Quoted 7 lines
Quoted 1 line

I think this is cleaner than previous way.

Please make running_on_xen a function rather than a variable. I see you end up turning it into a function for modules anyway, and I'd rather have a function wrapper around a variable than a variable wrapper around a function. :-) It'll give us a bit more flexibility in future too.

Hi,

here is the updated patch.
The function is now: is_running_on_xen().

Tested on ia64 bare box and on xen/ia64.

Tristan.

# HG changeset patch
# User gingold@virtu10
# Node ID c317d53af7a217096ffffb7abfa1c2870e2475ca # Parent 2fa8573b248f78f716a8926b29e294f97e99e631 Check wether Xen is running before setting up a Xen driver.

Replace calls to xen_init() by is_running_on_xen().

linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c +1 -0
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
@@ -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);
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c +2 -2
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
@@ -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;
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c +1 -1
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
@@ -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;
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +1 -1
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
@@ -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);
linux-2.6-xen-sparse/drivers/xen/console/console.c +2 -2
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/console/console.c
@@ -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)
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c +1 -1
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
@@ -443,7 +443,7 @@ gnttab_init(void)
 {
 	int i;
 
-	if (xen_init() < 0)
+	if (!is_running_on_xen())
 		return -ENODEV;
 
 	if (gnttab_resume() < 0)
linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c +3 -0
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c
@@ -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);
 }
linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c +6 -1
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c
@@ -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();
linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c +3 -0
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c
@@ -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));
 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c +3 -0
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
@@ -808,6 +808,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);
 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +3 -0
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
@@ -1341,6 +1341,9 @@ static int __init netif_init(void)
 {
 	int err = 0;
 
+	if (!is_running_on_xen())
+		return -ENODEV;
+
 	if (xen_start_info->flags & SIF_INITDOMAIN)
 		return 0;
 
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c +3 -0
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
@@ -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);
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +2 -6
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
@@ -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())
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h +1 -1
diff -r 2fa8573b248f -r c317d53af7a2 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
@@ -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(

# HG changeset patch
# User gingold@virtu10
# Node ID 115ca492cdbb1b5313aa6b69e1f2ff7aad75a62a
# Parent c317d53af7a217096ffffb7abfa1c2870e2475ca
Sync with transparent virtualization: call is_running_on_xen() to check wether Xen is running.

Call xen_init in setup_arch.
Declare running_on_xen in xenia64_init.c, remove running_on_xen and is_running_on_xen from xensetup.S
Remove xen_ksyms.c

linux-2.6-xen-sparse/arch/ia64/kernel/setup.c +3 -0
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/arch/ia64/kernel/setup.c
@@ -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) {
linux-2.6-xen-sparse/arch/ia64/xen/Makefile +2 -2
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/arch/ia64/xen/Makefile
@@ -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 util.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
linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c +5 -2
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c
@@ -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);
linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S +0 -12
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S
@@ -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?
 
@@ -28,9 +22,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)
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h +3 -3
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
@@ -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
@@ -158,7 +158,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);
 	}
@@ -169,7 +169,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);
 }
 
linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h +0 -5
diff -r c317d53af7a2 -r 115ca492cdbb linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h
@@ -42,12 +42,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 %0" : : "i" (HYPERPRIVOP_SSM_I))
 #define	XEN_HYPER_GET_IVR	asm("break %0" : : "i" (HYPERPRIVOP_GET_IVR))

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel