diff options
author | Liu Jinsong <jinsong.liu@intel.com> | 2013-01-24 07:16:59 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2013-02-19 22:02:25 -0500 |
commit | dcb93b96cec723783a81e8cac7df62feaf964792 (patch) | |
tree | 475c9e6d52c87d6063a7a94511a29d25c294921d /drivers/xen | |
parent | 07d0c943663f82d9682856c0a7db7145a6c911d6 (diff) |
xen/stub: driver for memory hotplug
This patch create a file (xen-stub.c) for Xen stub drivers.
Xen stub drivers are used to reserve space for Xen drivers, i.e.
memory hotplug and cpu hotplug, and to block native drivers loaded,
so that real Xen drivers can be modular and loaded on demand.
This patch is specific for Xen memory hotplug (other Xen logic
can add stub drivers on their own). The xen stub driver will
occupied earlier via subsys_initcall (than native memory hotplug
driver via module_init and so blocking native). Later real Xen
memory hotplug logic will unregister the stub driver and register
itself to take effect on demand.
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/Kconfig | 11 | ||||
-rw-r--r-- | drivers/xen/Makefile | 1 | ||||
-rw-r--r-- | drivers/xen/xen-stub.c | 66 |
3 files changed, 78 insertions, 0 deletions
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig index cabfa97f4674..c1c8566c6840 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig | |||
@@ -180,6 +180,17 @@ config XEN_PRIVCMD | |||
180 | depends on XEN | 180 | depends on XEN |
181 | default m | 181 | default m |
182 | 182 | ||
183 | config XEN_STUB | ||
184 | bool "Xen stub drivers" | ||
185 | depends on XEN && X86_64 | ||
186 | default n | ||
187 | help | ||
188 | Allow kernel to install stub drivers, to reserve space for Xen drivers, | ||
189 | i.e. memory hotplug and cpu hotplug, and to block native drivers loaded, | ||
190 | so that real Xen drivers can be modular. | ||
191 | |||
192 | To enable Xen features like cpu and memory hotplug, select Y here. | ||
193 | |||
183 | config XEN_ACPI_PROCESSOR | 194 | config XEN_ACPI_PROCESSOR |
184 | tristate "Xen ACPI processor" | 195 | tristate "Xen ACPI processor" |
185 | depends on XEN && X86 && ACPI_PROCESSOR && CPU_FREQ | 196 | depends on XEN && X86 && ACPI_PROCESSOR && CPU_FREQ |
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile index fb213cf81a7b..b63edd824ad4 100644 --- a/drivers/xen/Makefile +++ b/drivers/xen/Makefile | |||
@@ -30,6 +30,7 @@ obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o | |||
30 | obj-$(CONFIG_XEN_MCE_LOG) += mcelog.o | 30 | obj-$(CONFIG_XEN_MCE_LOG) += mcelog.o |
31 | obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/ | 31 | obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/ |
32 | obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o | 32 | obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o |
33 | obj-$(CONFIG_XEN_STUB) += xen-stub.o | ||
33 | obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o | 34 | obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o |
34 | xen-evtchn-y := evtchn.o | 35 | xen-evtchn-y := evtchn.o |
35 | xen-gntdev-y := gntdev.o | 36 | xen-gntdev-y := gntdev.o |
diff --git a/drivers/xen/xen-stub.c b/drivers/xen/xen-stub.c new file mode 100644 index 000000000000..811152f67137 --- /dev/null +++ b/drivers/xen/xen-stub.c | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * xen-stub.c - stub drivers to reserve space for Xen | ||
3 | * | ||
4 | * Copyright (C) 2012 Intel Corporation | ||
5 | * Author: Liu Jinsong <jinsong.liu@intel.com> | ||
6 | * Author: Jiang Yunhong <yunhong.jiang@intel.com> | ||
7 | * | ||
8 | * Copyright (C) 2012 Oracle Inc | ||
9 | * Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or (at | ||
14 | * your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
19 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
20 | * details. | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/export.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/acpi.h> | ||
28 | #include <acpi/acpi_drivers.h> | ||
29 | #include <xen/acpi.h> | ||
30 | |||
31 | /*-------------------------------------------- | ||
32 | stub driver for Xen memory hotplug | ||
33 | --------------------------------------------*/ | ||
34 | |||
35 | #ifdef CONFIG_ACPI | ||
36 | |||
37 | static const struct acpi_device_id memory_device_ids[] = { | ||
38 | {ACPI_MEMORY_DEVICE_HID, 0}, | ||
39 | {"", 0}, | ||
40 | }; | ||
41 | |||
42 | static struct acpi_driver xen_stub_memory_device_driver = { | ||
43 | /* same name as native memory driver to block native loaded */ | ||
44 | .name = "acpi_memhotplug", | ||
45 | .class = ACPI_MEMORY_DEVICE_CLASS, | ||
46 | .ids = memory_device_ids, | ||
47 | }; | ||
48 | |||
49 | int xen_stub_memory_device_init(void) | ||
50 | { | ||
51 | if (!xen_initial_domain()) | ||
52 | return -ENODEV; | ||
53 | |||
54 | /* just reserve space for Xen, block native driver loaded */ | ||
55 | return acpi_bus_register_driver(&xen_stub_memory_device_driver); | ||
56 | } | ||
57 | EXPORT_SYMBOL_GPL(xen_stub_memory_device_init); | ||
58 | subsys_initcall(xen_stub_memory_device_init); | ||
59 | |||
60 | void xen_stub_memory_device_exit(void) | ||
61 | { | ||
62 | acpi_bus_unregister_driver(&xen_stub_memory_device_driver); | ||
63 | } | ||
64 | EXPORT_SYMBOL_GPL(xen_stub_memory_device_exit); | ||
65 | |||
66 | #endif | ||