2008-10-28 00:41:46 +07:00
|
|
|
/*
|
|
|
|
* Common hypervisor code
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008, VMware, Inc.
|
|
|
|
* Author : Alok N Kataria <akataria@vmware.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
|
|
|
|
* NON INFRINGEMENT. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-05-10 12:46:54 +07:00
|
|
|
#include <linux/module.h>
|
2008-10-28 00:41:46 +07:00
|
|
|
#include <asm/processor.h>
|
2008-11-22 04:56:17 +07:00
|
|
|
#include <asm/hypervisor.h>
|
2008-10-28 00:41:46 +07:00
|
|
|
|
2010-05-08 06:57:28 +07:00
|
|
|
static const __initconst struct hypervisor_x86 * const hypervisors[] =
|
2008-10-28 00:41:46 +07:00
|
|
|
{
|
2015-05-04 22:02:15 +07:00
|
|
|
#ifdef CONFIG_XEN
|
|
|
|
&x86_hyper_xen,
|
2010-07-27 00:38:45 +07:00
|
|
|
#endif
|
2011-07-09 01:42:50 +07:00
|
|
|
&x86_hyper_vmware,
|
|
|
|
&x86_hyper_ms_hyperv,
|
2012-07-18 15:48:50 +07:00
|
|
|
#ifdef CONFIG_KVM_GUEST
|
2012-07-07 00:47:39 +07:00
|
|
|
&x86_hyper_kvm,
|
2012-07-18 15:48:50 +07:00
|
|
|
#endif
|
2010-05-08 06:57:28 +07:00
|
|
|
};
|
2008-10-28 00:41:46 +07:00
|
|
|
|
2010-05-08 06:57:28 +07:00
|
|
|
const struct hypervisor_x86 *x86_hyper;
|
2010-05-09 15:10:34 +07:00
|
|
|
EXPORT_SYMBOL(x86_hyper);
|
2010-05-08 06:57:28 +07:00
|
|
|
|
|
|
|
static inline void __init
|
|
|
|
detect_hypervisor_vendor(void)
|
2008-11-01 02:01:58 +07:00
|
|
|
{
|
2010-05-08 06:57:28 +07:00
|
|
|
const struct hypervisor_x86 *h, * const *p;
|
2013-07-25 15:54:35 +07:00
|
|
|
uint32_t pri, max_pri = 0;
|
2010-05-08 06:57:28 +07:00
|
|
|
|
|
|
|
for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {
|
|
|
|
h = *p;
|
2013-07-25 15:54:35 +07:00
|
|
|
pri = h->detect();
|
|
|
|
if (pri != 0 && pri > max_pri) {
|
|
|
|
max_pri = pri;
|
2010-05-08 06:57:28 +07:00
|
|
|
x86_hyper = h;
|
|
|
|
}
|
|
|
|
}
|
2013-07-25 15:54:35 +07:00
|
|
|
|
|
|
|
if (max_pri)
|
2016-02-02 10:45:02 +07:00
|
|
|
pr_info("Hypervisor detected: %s\n", x86_hyper->name);
|
2008-11-01 02:01:58 +07:00
|
|
|
}
|
|
|
|
|
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-19 05:23:59 +07:00
|
|
|
void init_hypervisor(struct cpuinfo_x86 *c)
|
2008-10-28 00:41:46 +07:00
|
|
|
{
|
2010-05-08 06:57:28 +07:00
|
|
|
if (x86_hyper && x86_hyper->set_cpu_features)
|
|
|
|
x86_hyper->set_cpu_features(c);
|
2008-10-28 00:41:46 +07:00
|
|
|
}
|
2009-08-20 22:06:25 +07:00
|
|
|
|
|
|
|
void __init init_hypervisor_platform(void)
|
|
|
|
{
|
2010-05-08 06:57:28 +07:00
|
|
|
|
|
|
|
detect_hypervisor_vendor();
|
|
|
|
|
|
|
|
if (!x86_hyper)
|
|
|
|
return;
|
|
|
|
|
2009-08-20 22:06:25 +07:00
|
|
|
init_hypervisor(&boot_cpu_data);
|
2010-05-08 06:57:28 +07:00
|
|
|
|
|
|
|
if (x86_hyper->init_platform)
|
|
|
|
x86_hyper->init_platform();
|
2009-08-20 22:06:25 +07:00
|
|
|
}
|
2013-01-18 06:44:42 +07:00
|
|
|
|
|
|
|
bool __init hypervisor_x2apic_available(void)
|
|
|
|
{
|
|
|
|
return x86_hyper &&
|
|
|
|
x86_hyper->x2apic_available &&
|
|
|
|
x86_hyper->x2apic_available();
|
|
|
|
}
|