1 /******************************************************************************
2 * asm-x86/guest/hypervisor.h
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms and conditions of the GNU General Public
6 * License, version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public
14 * License along with this program; If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Copyright (c) 2019 Microsoft.
17 */
18
19 #ifndef __X86_HYPERVISOR_H__
20 #define __X86_HYPERVISOR_H__
21
22 #include <xen/cpumask.h>
23
24 #include <asm/e820.h>
25
26 struct hypervisor_ops {
27 /* Name of the hypervisor */
28 const char *name;
29 /* Main setup routine */
30 void (*setup)(void);
31 /* AP setup */
32 int (*ap_setup)(void);
33 /* Resume from suspension */
34 void (*resume)(void);
35 /* Fix up e820 map */
36 void (*e820_fixup)(struct e820map *e820);
37 /* L0 assisted TLB flush */
38 int (*flush_tlb)(const cpumask_t *mask, const void *va, unsigned int flags);
39 };
40
41 #ifdef CONFIG_GUEST
42
43 const char *hypervisor_probe(void);
44 void hypervisor_setup(void);
45 int hypervisor_ap_setup(void);
46 void hypervisor_resume(void);
47 void hypervisor_e820_fixup(struct e820map *e820);
48 /*
49 * L0 assisted TLB flush.
50 * mask: cpumask of the dirty vCPUs that should be flushed.
51 * va: linear address to flush, or NULL for entire address space.
52 * flags: flags for flushing, including the order of va.
53 */
54 int hypervisor_flush_tlb(const cpumask_t *mask, const void *va,
55 unsigned int flags);
56
57 #else
58
59 #include <xen/lib.h>
60 #include <xen/types.h>
61
hypervisor_probe(void)62 static inline const char *hypervisor_probe(void) { return NULL; }
hypervisor_setup(void)63 static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
hypervisor_ap_setup(void)64 static inline int hypervisor_ap_setup(void) { return 0; }
hypervisor_resume(void)65 static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
hypervisor_e820_fixup(struct e820map * e820)66 static inline void hypervisor_e820_fixup(struct e820map *e820) {}
hypervisor_flush_tlb(const cpumask_t * mask,const void * va,unsigned int flags)67 static inline int hypervisor_flush_tlb(const cpumask_t *mask, const void *va,
68 unsigned int flags)
69 {
70 return -EOPNOTSUPP;
71 }
72
73 #endif /* CONFIG_GUEST */
74
75 #endif /* __X86_HYPERVISOR_H__ */
76
77 /*
78 * Local variables:
79 * mode: C
80 * c-file-style: "BSD"
81 * c-basic-offset: 4
82 * tab-width: 4
83 * indent-tabs-mode: nil
84 * End:
85 */
86