aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/xen/platform-pci-unplug.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/xen/platform-pci-unplug.c')
-rw-r--r--arch/x86/xen/platform-pci-unplug.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/arch/x86/xen/platform-pci-unplug.c b/arch/x86/xen/platform-pci-unplug.c
index 0a7852483ffe..ab84ac198a9a 100644
--- a/arch/x86/xen/platform-pci-unplug.c
+++ b/arch/x86/xen/platform-pci-unplug.c
@@ -69,6 +69,80 @@ static int check_platform_magic(void)
69 return 0; 69 return 0;
70} 70}
71 71
72bool xen_has_pv_devices()
73{
74 if (!xen_domain())
75 return false;
76
77 /* PV domains always have them. */
78 if (xen_pv_domain())
79 return true;
80
81 /* And user has xen_platform_pci=0 set in guest config as
82 * driver did not modify the value. */
83 if (xen_platform_pci_unplug == 0)
84 return false;
85
86 if (xen_platform_pci_unplug & XEN_UNPLUG_NEVER)
87 return false;
88
89 if (xen_platform_pci_unplug & XEN_UNPLUG_ALL)
90 return true;
91
92 /* This is an odd one - we are going to run legacy
93 * and PV drivers at the same time. */
94 if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY)
95 return true;
96
97 /* And the caller has to follow with xen_pv_{disk,nic}_devices
98 * to be certain which driver can load. */
99 return false;
100}
101EXPORT_SYMBOL_GPL(xen_has_pv_devices);
102
103static bool __xen_has_pv_device(int state)
104{
105 /* HVM domains might or might not */
106 if (xen_hvm_domain() && (xen_platform_pci_unplug & state))
107 return true;
108
109 return xen_has_pv_devices();
110}
111
112bool xen_has_pv_nic_devices(void)
113{
114 return __xen_has_pv_device(XEN_UNPLUG_ALL_NICS | XEN_UNPLUG_ALL);
115}
116EXPORT_SYMBOL_GPL(xen_has_pv_nic_devices);
117
118bool xen_has_pv_disk_devices(void)
119{
120 return __xen_has_pv_device(XEN_UNPLUG_ALL_IDE_DISKS |
121 XEN_UNPLUG_AUX_IDE_DISKS | XEN_UNPLUG_ALL);
122}
123EXPORT_SYMBOL_GPL(xen_has_pv_disk_devices);
124
125/*
126 * This one is odd - it determines whether you want to run PV _and_
127 * legacy (IDE) drivers together. This combination is only possible
128 * under HVM.
129 */
130bool xen_has_pv_and_legacy_disk_devices(void)
131{
132 if (!xen_domain())
133 return false;
134
135 /* N.B. This is only ever used in HVM mode */
136 if (xen_pv_domain())
137 return false;
138
139 if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY)
140 return true;
141
142 return false;
143}
144EXPORT_SYMBOL_GPL(xen_has_pv_and_legacy_disk_devices);
145
72void xen_unplug_emulated_devices(void) 146void xen_unplug_emulated_devices(void)
73{ 147{
74 int r; 148 int r;