Le Jeudi 18 Mai 2006 00:35, Keir Fraser a écrit :
> On 17 May 2006, at 12:17, Tristan Gingold wrote:
> > 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?
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.
Signed-off-by: Tristan Gingold <[EMAIL PROTECTED]>
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Thu May 18 06:29:28 2006
@@ -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);
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Thu May 18 06:29:28 2006
@@ -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;
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Thu May 18 06:29:28 2006
@@ -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;
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Thu May 18 06:29:28 2006
@@ -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);
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/console/console.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/console.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c Thu May 18 06:29:28 2006
@@ -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)
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Thu May 18 06:29:28 2006
@@ -443,7 +443,7 @@
{
int i;
- if (xen_init() < 0)
+ if (!running_on_xen)
return -ENODEV;
if (gnttab_resume() < 0)
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Thu May 18 06:29:28 2006
@@ -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);
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Thu May 18 06:29:28 2006
@@ -1341,6 +1341,9 @@
{
int err = 0;
+ if (!running_on_xen)
+ return -ENODEV;
+
if (xen_start_info->flags & SIF_INITDOMAIN)
return 0;
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Thu May 18 06:29:28 2006
@@ -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);
diff -r d2f6e3d70f22 -r ce125e557225 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Thu May 18 06:29:28 2006
@@ -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())
diff -r d2f6e3d70f22 -r ce125e557225 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 Wed May 17 22:31:46 2006
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h Thu May 18 06:29:28 2006
@@ -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
Signed-off-by: Tristan Gingold <[EMAIL PROTECTED]>
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c Thu May 18 06:33:04 2006
@@ -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) {
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/Makefile
--- a/linux-2.6-xen-sparse/arch/ia64/xen/Makefile Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/Makefile Thu May 18 06:33:04 2006
@@ -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
diff -r ce125e557225 -r 7e53a91d47ae 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 Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c Thu May 18 06:33:04 2006
@@ -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)
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S Thu May 18 06:33:04 2006
@@ -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)
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Thu May 18 06:33:04 2006
@@ -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
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h Thu May 18 06:29:28 2006
+++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h Thu May 18 06:33:04 2006
@@ -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))
diff -r ce125e557225 -r 7e53a91d47ae linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c Thu May 18 06:29:28 2006
+++ /dev/null Thu May 18 06:33:04 2006
@@ -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-ia64-devel mailing list
[email protected]
http://lists.xensource.com/xen-ia64-devel