Loading...
1/*
2 * Copyright (C) 2008, VMware, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 * NON INFRINGEMENT. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20#ifndef _ASM_X86_HYPERVISOR_H
21#define _ASM_X86_HYPERVISOR_H
22
23/* x86 hypervisor types */
24enum x86_hypervisor_type {
25 X86_HYPER_NATIVE = 0,
26 X86_HYPER_VMWARE,
27 X86_HYPER_MS_HYPERV,
28 X86_HYPER_XEN_PV,
29 X86_HYPER_XEN_HVM,
30 X86_HYPER_KVM,
31 X86_HYPER_JAILHOUSE,
32};
33
34#ifdef CONFIG_HYPERVISOR_GUEST
35
36#include <asm/kvm_para.h>
37#include <asm/x86_init.h>
38#include <asm/xen/hypervisor.h>
39
40struct hypervisor_x86 {
41 /* Hypervisor name */
42 const char *name;
43
44 /* Detection routine */
45 uint32_t (*detect)(void);
46
47 /* Hypervisor type */
48 enum x86_hypervisor_type type;
49
50 /* init time callbacks */
51 struct x86_hyper_init init;
52
53 /* runtime callbacks */
54 struct x86_hyper_runtime runtime;
55};
56
57extern enum x86_hypervisor_type x86_hyper_type;
58extern void init_hypervisor_platform(void);
59static inline bool hypervisor_is_type(enum x86_hypervisor_type type)
60{
61 return x86_hyper_type == type;
62}
63#else
64static inline void init_hypervisor_platform(void) { }
65static inline bool hypervisor_is_type(enum x86_hypervisor_type type)
66{
67 return type == X86_HYPER_NATIVE;
68}
69#endif /* CONFIG_HYPERVISOR_GUEST */
70#endif /* _ASM_X86_HYPERVISOR_H */
1/*
2 * Copyright (C) 2008, VMware, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 * NON INFRINGEMENT. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20#ifndef _ASM_X86_HYPERVISOR_H
21#define _ASM_X86_HYPERVISOR_H
22
23#include <asm/kvm_para.h>
24#include <asm/xen/hypervisor.h>
25
26extern void init_hypervisor(struct cpuinfo_x86 *c);
27extern void init_hypervisor_platform(void);
28
29/*
30 * x86 hypervisor information
31 */
32struct hypervisor_x86 {
33 /* Hypervisor name */
34 const char *name;
35
36 /* Detection routine */
37 bool (*detect)(void);
38
39 /* Adjust CPU feature bits (run once per CPU) */
40 void (*set_cpu_features)(struct cpuinfo_x86 *);
41
42 /* Platform setup (run once per boot) */
43 void (*init_platform)(void);
44};
45
46extern const struct hypervisor_x86 *x86_hyper;
47
48/* Recognized hypervisors */
49extern const struct hypervisor_x86 x86_hyper_vmware;
50extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
51extern const struct hypervisor_x86 x86_hyper_xen_hvm;
52
53static inline bool hypervisor_x2apic_available(void)
54{
55 if (kvm_para_available())
56 return true;
57 if (xen_x2apic_para_available())
58 return true;
59 return false;
60}
61
62#endif