|
@@ -44,51 +44,49 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
|
|
|
const struct hypervisor_x86 *x86_hyper;
|
|
|
EXPORT_SYMBOL(x86_hyper);
|
|
|
|
|
|
-static inline void __init
|
|
|
+static inline const struct hypervisor_x86 * __init
|
|
|
detect_hypervisor_vendor(void)
|
|
|
{
|
|
|
- const struct hypervisor_x86 *h, * const *p;
|
|
|
+ const struct hypervisor_x86 *h = NULL, * const *p;
|
|
|
uint32_t pri, max_pri = 0;
|
|
|
|
|
|
for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
|
|
|
- h = *p;
|
|
|
- pri = h->detect();
|
|
|
- if (pri != 0 && pri > max_pri) {
|
|
|
+ pri = (*p)->detect();
|
|
|
+ if (pri > max_pri) {
|
|
|
max_pri = pri;
|
|
|
- x86_hyper = h;
|
|
|
+ h = *p;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (max_pri)
|
|
|
- pr_info("Hypervisor detected: %s\n", x86_hyper->name);
|
|
|
+ if (h)
|
|
|
+ pr_info("Hypervisor detected: %s\n", h->name);
|
|
|
+
|
|
|
+ return h;
|
|
|
}
|
|
|
|
|
|
-void __init init_hypervisor_platform(void)
|
|
|
+static void __init copy_array(const void *src, void *target, unsigned int size)
|
|
|
{
|
|
|
+ unsigned int i, n = size / sizeof(void *);
|
|
|
+ const void * const *from = (const void * const *)src;
|
|
|
+ const void **to = (const void **)target;
|
|
|
|
|
|
- detect_hypervisor_vendor();
|
|
|
-
|
|
|
- if (!x86_hyper)
|
|
|
- return;
|
|
|
-
|
|
|
- if (x86_hyper->init_platform)
|
|
|
- x86_hyper->init_platform();
|
|
|
+ for (i = 0; i < n; i++)
|
|
|
+ if (from[i])
|
|
|
+ to[i] = from[i];
|
|
|
}
|
|
|
|
|
|
-bool __init hypervisor_x2apic_available(void)
|
|
|
+void __init init_hypervisor_platform(void)
|
|
|
{
|
|
|
- return x86_hyper &&
|
|
|
- x86_hyper->x2apic_available &&
|
|
|
- x86_hyper->x2apic_available();
|
|
|
-}
|
|
|
+ const struct hypervisor_x86 *h;
|
|
|
|
|
|
-void hypervisor_pin_vcpu(int cpu)
|
|
|
-{
|
|
|
- if (!x86_hyper)
|
|
|
+ h = detect_hypervisor_vendor();
|
|
|
+
|
|
|
+ if (!h)
|
|
|
return;
|
|
|
|
|
|
- if (x86_hyper->pin_vcpu)
|
|
|
- x86_hyper->pin_vcpu(cpu);
|
|
|
- else
|
|
|
- WARN_ONCE(1, "vcpu pinning requested but not supported!\n");
|
|
|
+ copy_array(&h->init, &x86_init.hyper, sizeof(h->init));
|
|
|
+ copy_array(&h->runtime, &x86_platform.hyper, sizeof(h->runtime));
|
|
|
+
|
|
|
+ x86_hyper = h;
|
|
|
+ x86_init.hyper.init_platform();
|
|
|
}
|