diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2010-05-14 07:44:30 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-07-27 02:13:25 -0400 |
commit | c1c5413ad58cb73267d328e6020268aa2e50d8ca (patch) | |
tree | f2c66141ab8d9fdb7b16a13d4d510ad09b2430ed /arch/x86 | |
parent | 409771d258e9dd71c30f3c9520fd2b796ffc40f0 (diff) |
x86: Unplug emulated disks and nics.
Add a xen_emul_unplug command line option to the kernel to unplug
xen emulated disks and nics.
Set the default value of xen_emul_unplug depending on whether or
not the Xen PV frontends and the Xen platform PCI driver have
been compiled for this kernel (modules or built-in are both OK).
The user can specify xen_emul_unplug=ignore to enable PV drivers on HVM
even if the host platform doesn't support unplug.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/xen/Makefile | 2 | ||||
-rw-r--r-- | arch/x86/xen/enlighten.c | 1 | ||||
-rw-r--r-- | arch/x86/xen/platform-pci-unplug.c | 135 | ||||
-rw-r--r-- | arch/x86/xen/xen-ops.h | 1 |
4 files changed, 138 insertions, 1 deletions
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile index 3bb4fc21f4f2..930954685980 100644 --- a/arch/x86/xen/Makefile +++ b/arch/x86/xen/Makefile | |||
@@ -12,7 +12,7 @@ CFLAGS_mmu.o := $(nostackp) | |||
12 | 12 | ||
13 | obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \ | 13 | obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \ |
14 | time.o xen-asm.o xen-asm_$(BITS).o \ | 14 | time.o xen-asm.o xen-asm_$(BITS).o \ |
15 | grant-table.o suspend.o | 15 | grant-table.o suspend.o platform-pci-unplug.o |
16 | 16 | ||
17 | obj-$(CONFIG_SMP) += smp.o | 17 | obj-$(CONFIG_SMP) += smp.o |
18 | obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o | 18 | obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o |
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index a90172963884..157c93b62dd4 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -1314,6 +1314,7 @@ static void __init xen_hvm_guest_init(void) | |||
1314 | if (xen_feature(XENFEAT_hvm_callback_vector)) | 1314 | if (xen_feature(XENFEAT_hvm_callback_vector)) |
1315 | xen_have_vector_callback = 1; | 1315 | xen_have_vector_callback = 1; |
1316 | register_cpu_notifier(&xen_hvm_cpu_notifier); | 1316 | register_cpu_notifier(&xen_hvm_cpu_notifier); |
1317 | xen_unplug_emulated_devices(); | ||
1317 | have_vcpu_info_placement = 0; | 1318 | have_vcpu_info_placement = 0; |
1318 | x86_init.irqs.intr_init = xen_init_IRQ; | 1319 | x86_init.irqs.intr_init = xen_init_IRQ; |
1319 | xen_hvm_init_time_ops(); | 1320 | xen_hvm_init_time_ops(); |
diff --git a/arch/x86/xen/platform-pci-unplug.c b/arch/x86/xen/platform-pci-unplug.c new file mode 100644 index 000000000000..2f7f3fb34777 --- /dev/null +++ b/arch/x86/xen/platform-pci-unplug.c | |||
@@ -0,0 +1,135 @@ | |||
1 | /****************************************************************************** | ||
2 | * platform-pci-unplug.c | ||
3 | * | ||
4 | * Xen platform PCI device driver | ||
5 | * Copyright (c) 2010, Citrix | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms and conditions of the GNU General Public License, | ||
9 | * version 2, as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along with | ||
17 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
18 | * Place - Suite 330, Boston, MA 02111-1307 USA. | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/init.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/module.h> | ||
25 | |||
26 | #include <xen/platform_pci.h> | ||
27 | |||
28 | #define XEN_PLATFORM_ERR_MAGIC -1 | ||
29 | #define XEN_PLATFORM_ERR_PROTOCOL -2 | ||
30 | #define XEN_PLATFORM_ERR_BLACKLIST -3 | ||
31 | |||
32 | /* store the value of xen_emul_unplug after the unplug is done */ | ||
33 | int xen_platform_pci_unplug; | ||
34 | EXPORT_SYMBOL_GPL(xen_platform_pci_unplug); | ||
35 | static int xen_emul_unplug; | ||
36 | |||
37 | static int __init check_platform_magic(void) | ||
38 | { | ||
39 | short magic; | ||
40 | char protocol; | ||
41 | |||
42 | magic = inw(XEN_IOPORT_MAGIC); | ||
43 | if (magic != XEN_IOPORT_MAGIC_VAL) { | ||
44 | printk(KERN_ERR "Xen Platform PCI: unrecognised magic value\n"); | ||
45 | return XEN_PLATFORM_ERR_MAGIC; | ||
46 | } | ||
47 | |||
48 | protocol = inb(XEN_IOPORT_PROTOVER); | ||
49 | |||
50 | printk(KERN_DEBUG "Xen Platform PCI: I/O protocol version %d\n", | ||
51 | protocol); | ||
52 | |||
53 | switch (protocol) { | ||
54 | case 1: | ||
55 | outw(XEN_IOPORT_LINUX_PRODNUM, XEN_IOPORT_PRODNUM); | ||
56 | outl(XEN_IOPORT_LINUX_DRVVER, XEN_IOPORT_DRVVER); | ||
57 | if (inw(XEN_IOPORT_MAGIC) != XEN_IOPORT_MAGIC_VAL) { | ||
58 | printk(KERN_ERR "Xen Platform: blacklisted by host\n"); | ||
59 | return XEN_PLATFORM_ERR_BLACKLIST; | ||
60 | } | ||
61 | break; | ||
62 | default: | ||
63 | printk(KERN_WARNING "Xen Platform PCI: unknown I/O protocol version"); | ||
64 | return XEN_PLATFORM_ERR_PROTOCOL; | ||
65 | } | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | void __init xen_unplug_emulated_devices(void) | ||
71 | { | ||
72 | int r; | ||
73 | |||
74 | /* check the version of the xen platform PCI device */ | ||
75 | r = check_platform_magic(); | ||
76 | /* If the version matches enable the Xen platform PCI driver. | ||
77 | * Also enable the Xen platform PCI driver if the version is really old | ||
78 | * and the user told us to ignore it. */ | ||
79 | if (r && !(r == XEN_PLATFORM_ERR_MAGIC && | ||
80 | (xen_emul_unplug & XEN_UNPLUG_IGNORE))) | ||
81 | return; | ||
82 | /* Set the default value of xen_emul_unplug depending on whether or | ||
83 | * not the Xen PV frontends and the Xen platform PCI driver have | ||
84 | * been compiled for this kernel (modules or built-in are both OK). */ | ||
85 | if (!xen_emul_unplug) { | ||
86 | if (xen_must_unplug_nics()) { | ||
87 | printk(KERN_INFO "Netfront and the Xen platform PCI driver have " | ||
88 | "been compiled for this kernel: unplug emulated NICs.\n"); | ||
89 | xen_emul_unplug |= XEN_UNPLUG_ALL_NICS; | ||
90 | } | ||
91 | if (xen_must_unplug_disks()) { | ||
92 | printk(KERN_INFO "Blkfront and the Xen platform PCI driver have " | ||
93 | "been compiled for this kernel: unplug emulated disks.\n" | ||
94 | "You might have to change the root device\n" | ||
95 | "from /dev/hd[a-d] to /dev/xvd[a-d]\n" | ||
96 | "in your root= kernel command line option\n"); | ||
97 | xen_emul_unplug |= XEN_UNPLUG_ALL_IDE_DISKS; | ||
98 | } | ||
99 | } | ||
100 | /* Now unplug the emulated devices */ | ||
101 | if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE)) | ||
102 | outw(xen_emul_unplug, XEN_IOPORT_UNPLUG); | ||
103 | xen_platform_pci_unplug = xen_emul_unplug; | ||
104 | } | ||
105 | |||
106 | static int __init parse_xen_emul_unplug(char *arg) | ||
107 | { | ||
108 | char *p, *q; | ||
109 | int l; | ||
110 | |||
111 | for (p = arg; p; p = q) { | ||
112 | q = strchr(p, ','); | ||
113 | if (q) { | ||
114 | l = q - p; | ||
115 | q++; | ||
116 | } else { | ||
117 | l = strlen(p); | ||
118 | } | ||
119 | if (!strncmp(p, "all", l)) | ||
120 | xen_emul_unplug |= XEN_UNPLUG_ALL; | ||
121 | else if (!strncmp(p, "ide-disks", l)) | ||
122 | xen_emul_unplug |= XEN_UNPLUG_ALL_IDE_DISKS; | ||
123 | else if (!strncmp(p, "aux-ide-disks", l)) | ||
124 | xen_emul_unplug |= XEN_UNPLUG_AUX_IDE_DISKS; | ||
125 | else if (!strncmp(p, "nics", l)) | ||
126 | xen_emul_unplug |= XEN_UNPLUG_ALL_NICS; | ||
127 | else if (!strncmp(p, "ignore", l)) | ||
128 | xen_emul_unplug |= XEN_UNPLUG_IGNORE; | ||
129 | else | ||
130 | printk(KERN_WARNING "unrecognised option '%s' " | ||
131 | "in parameter 'xen_emul_unplug'\n", p); | ||
132 | } | ||
133 | return 0; | ||
134 | } | ||
135 | early_param("xen_emul_unplug", parse_xen_emul_unplug); | ||
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 089d18923d2b..ed776949024c 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h | |||
@@ -40,6 +40,7 @@ void xen_vcpu_restore(void); | |||
40 | 40 | ||
41 | void xen_callback_vector(void); | 41 | void xen_callback_vector(void); |
42 | void xen_hvm_init_shared_info(void); | 42 | void xen_hvm_init_shared_info(void); |
43 | void __init xen_unplug_emulated_devices(void); | ||
43 | 44 | ||
44 | void __init xen_build_dynamic_phys_to_machine(void); | 45 | void __init xen_build_dynamic_phys_to_machine(void); |
45 | 46 | ||