Path: blob/master/arch/x86/kernel/cpu/hypervisor.c
10699 views
/*1* Common hypervisor code2*3* Copyright (C) 2008, VMware, Inc.4* Author : Alok N Kataria <[email protected]>5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2 of the License, or9* (at your option) any later version.10*11* This program is distributed in the hope that it will be useful, but12* WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or14* NON INFRINGEMENT. See the GNU General Public License for more15* details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.20*21*/2223#include <linux/module.h>24#include <asm/processor.h>25#include <asm/hypervisor.h>2627/*28* Hypervisor detect order. This is specified explicitly here because29* some hypervisors might implement compatibility modes for other30* hypervisors and therefore need to be detected in specific sequence.31*/32static const __initconst struct hypervisor_x86 * const hypervisors[] =33{34&x86_hyper_vmware,35&x86_hyper_ms_hyperv,36#ifdef CONFIG_XEN_PVHVM37&x86_hyper_xen_hvm,38#endif39};4041const struct hypervisor_x86 *x86_hyper;42EXPORT_SYMBOL(x86_hyper);4344static inline void __init45detect_hypervisor_vendor(void)46{47const struct hypervisor_x86 *h, * const *p;4849for (p = hypervisors; p < hypervisors + ARRAY_SIZE(hypervisors); p++) {50h = *p;51if (h->detect()) {52x86_hyper = h;53printk(KERN_INFO "Hypervisor detected: %s\n", h->name);54break;55}56}57}5859void __cpuinit init_hypervisor(struct cpuinfo_x86 *c)60{61if (x86_hyper && x86_hyper->set_cpu_features)62x86_hyper->set_cpu_features(c);63}6465void __init init_hypervisor_platform(void)66{6768detect_hypervisor_vendor();6970if (!x86_hyper)71return;7273init_hypervisor(&boot_cpu_data);7475if (x86_hyper->init_platform)76x86_hyper->init_platform();77}787980