1 /******************************************************************************
4 * Linux-specific hypervisor handling.
6 * Copyright (c) 2002-2004, K A Fraser
8 * This file may be distributed separately from the Linux kernel, or
9 * incorporated into other software packages, subject to the following license:
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this source file (the "Software"), to deal in the Software without
13 * restriction, including without limitation the rights to use, copy, modify,
14 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
15 * and to permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #ifndef __HYPERVISOR_H__
31 #define __HYPERVISOR_H__
33 #include <linux/config.h>
34 #include <linux/types.h>
35 #include <linux/kernel.h>
36 #include <linux/version.h>
37 #include <asm-xen/xen-public/xen.h>
38 #include <asm-xen/xen-public/dom0_ops.h>
39 #include <asm-xen/xen-public/io/domain_controller.h>
40 #include <asm/ptrace.h>
43 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
44 #include <asm-generic/pgtable-nopmd.h>
48 /* arch/xen/i386/kernel/setup.c */
49 union xen_start_info_union
51 start_info_t xen_start_info;
54 extern union xen_start_info_union xen_start_info_union;
55 #define xen_start_info (xen_start_info_union.xen_start_info)
57 /* arch/xen/kernel/evtchn.c */
58 /* Force a proper event-channel callback from Xen. */
59 void force_evtchn_callback(void);
61 /* arch/xen/kernel/process.c */
62 void xen_cpu_idle (void);
64 /* arch/xen/i386/kernel/hypervisor.c */
65 void do_hypervisor_callback(struct pt_regs *regs);
67 /* arch/xen/i386/kernel/head.S */
68 void lgdt_finish(void);
70 /* arch/xen/i386/mm/hypervisor.c */
72 * NB. ptr values should be PHYSICAL, not MACHINE. 'vals' should be already
73 * be MACHINE addresses.
76 void xen_pt_switch(unsigned long ptr);
77 void xen_new_user_pt(unsigned long ptr); /* x86_64 only */
78 void xen_load_gs(unsigned int selector); /* x86_64 only */
79 void xen_tlb_flush(void);
80 void xen_invlpg(unsigned long ptr);
82 #ifndef CONFIG_XEN_SHADOW_MODE
83 void xen_l1_entry_update(pte_t *ptr, unsigned long val);
84 void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
86 void xen_l3_entry_update(pud_t *ptr, pud_t val); /* x86_64 only */
88 void xen_l4_entry_update(pgd_t *ptr, pgd_t val); /* x86_64 only */
89 void xen_pgd_pin(unsigned long ptr);
90 void xen_pgd_unpin(unsigned long ptr);
91 void xen_pud_pin(unsigned long ptr); /* x86_64 only */
92 void xen_pud_unpin(unsigned long ptr); /* x86_64 only */
93 void xen_pmd_pin(unsigned long ptr); /* x86_64 only */
94 void xen_pmd_unpin(unsigned long ptr); /* x86_64 only */
95 void xen_pte_pin(unsigned long ptr);
96 void xen_pte_unpin(unsigned long ptr);
98 #define xen_l1_entry_update(_p, _v) set_pte((_p), (pte_t){(_v)})
99 #define xen_l2_entry_update(_p, _v) set_pgd((_p), (pgd_t){(_v)})
100 #define xen_pgd_pin(_p) ((void)0)
101 #define xen_pgd_unpin(_p) ((void)0)
102 #define xen_pte_pin(_p) ((void)0)
103 #define xen_pte_unpin(_p) ((void)0)
106 void xen_set_ldt(unsigned long ptr, unsigned long bytes);
107 void xen_machphys_update(unsigned long mfn, unsigned long pfn);
110 #include <linux/cpumask.h>
111 void xen_tlb_flush_all(void);
112 void xen_invlpg_all(unsigned long ptr);
113 void xen_tlb_flush_mask(cpumask_t mask);
114 void xen_invlpg_mask(cpumask_t mask, unsigned long ptr);
117 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
119 ** XXX SMH: 2.4 doesn't have percpu.h (or support SMP guests) so just
120 ** include sufficient #defines to allow the below to build.
122 #define DEFINE_PER_CPU(type, name) \
123 __typeof__(type) per_cpu__##name
125 #define per_cpu(var, cpu) (*((void)cpu, &per_cpu__##var))
126 #define __get_cpu_var(var) per_cpu__##var
127 #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
129 #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
130 #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
131 #endif /* linux < 2.6.0 */
133 #ifdef CONFIG_XEN_PHYSDEV_ACCESS
134 /* Allocate a contiguous empty region of low memory. Return virtual start. */
135 unsigned long allocate_empty_lowmem_region(unsigned long pages);
138 #include <asm/hypercall.h>
140 #endif /* __HYPERVISOR_H__ */