• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * xen-stub.c - stub drivers to reserve space for Xen
4  *
5  * Copyright (C) 2012 Intel Corporation
6  *    Author: Liu Jinsong <jinsong.liu@intel.com>
7  *    Author: Jiang Yunhong <yunhong.jiang@intel.com>
8  *
9  * Copyright (C) 2012 Oracle Inc
10  *    Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11  */
12 
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/export.h>
16 #include <linux/types.h>
17 #include <linux/acpi.h>
18 #include <xen/acpi.h>
19 
20 #ifdef CONFIG_ACPI
21 
22 /*--------------------------------------------
23 	stub driver for Xen memory hotplug
24 --------------------------------------------*/
25 
26 static const struct acpi_device_id memory_device_ids[] = {
27 	{ACPI_MEMORY_DEVICE_HID, 0},
28 	{"", 0},
29 };
30 
31 static struct acpi_driver xen_stub_memory_device_driver = {
32 	/* same name as native memory driver to block native loaded */
33 	.name = "acpi_memhotplug",
34 	.class = ACPI_MEMORY_DEVICE_CLASS,
35 	.ids = memory_device_ids,
36 };
37 
xen_stub_memory_device_init(void)38 int xen_stub_memory_device_init(void)
39 {
40 	if (!xen_initial_domain())
41 		return -ENODEV;
42 
43 	/* just reserve space for Xen, block native driver loaded */
44 	return acpi_bus_register_driver(&xen_stub_memory_device_driver);
45 }
46 EXPORT_SYMBOL_GPL(xen_stub_memory_device_init);
47 subsys_initcall(xen_stub_memory_device_init);
48 
xen_stub_memory_device_exit(void)49 void xen_stub_memory_device_exit(void)
50 {
51 	acpi_bus_unregister_driver(&xen_stub_memory_device_driver);
52 }
53 EXPORT_SYMBOL_GPL(xen_stub_memory_device_exit);
54 
55 
56 /*--------------------------------------------
57 	stub driver for Xen cpu hotplug
58 --------------------------------------------*/
59 
60 static const struct acpi_device_id processor_device_ids[] = {
61 	{ACPI_PROCESSOR_OBJECT_HID, 0},
62 	{ACPI_PROCESSOR_DEVICE_HID, 0},
63 	{"", 0},
64 };
65 
66 static struct acpi_driver xen_stub_processor_driver = {
67 	/* same name as native processor driver to block native loaded */
68 	.name = "processor",
69 	.class = ACPI_PROCESSOR_CLASS,
70 	.ids = processor_device_ids,
71 };
72 
xen_stub_processor_init(void)73 int xen_stub_processor_init(void)
74 {
75 	if (!xen_initial_domain())
76 		return -ENODEV;
77 
78 	/* just reserve space for Xen, block native driver loaded */
79 	return acpi_bus_register_driver(&xen_stub_processor_driver);
80 }
81 EXPORT_SYMBOL_GPL(xen_stub_processor_init);
82 subsys_initcall(xen_stub_processor_init);
83 
xen_stub_processor_exit(void)84 void xen_stub_processor_exit(void)
85 {
86 	acpi_bus_unregister_driver(&xen_stub_processor_driver);
87 }
88 EXPORT_SYMBOL_GPL(xen_stub_processor_exit);
89 
90 #endif
91