source: trunk/packages/xen-common/xen-common/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 7.0 KB
Line 
1/******************************************************************************
2 * hypervisor.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002-2004, K A Fraser
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation; or, when distributed
11 * separately from the Linux kernel or incorporated into other
12 * software packages, subject to the following license:
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this source file (the "Software"), to deal in the Software without
16 * restriction, including without limitation the rights to use, copy, modify,
17 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18 * and to permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 * IN THE SOFTWARE.
31 */
32
33#ifndef __HYPERVISOR_H__
34#define __HYPERVISOR_H__
35
36#include <linux/types.h>
37#include <linux/kernel.h>
38#include <linux/version.h>
39#include <linux/errno.h>
40#include <xen/interface/xen.h>
41#include <xen/interface/platform.h>
42#include <xen/interface/event_channel.h>
43#include <xen/interface/physdev.h>
44#include <xen/interface/sched.h>
45#include <xen/interface/nmi.h>
46#include <asm/ptrace.h>
47#include <asm/page.h>
48#if defined(__i386__)
49#  ifdef CONFIG_X86_PAE
50#   include <asm-generic/pgtable-nopud.h>
51#  else
52#   include <asm-generic/pgtable-nopmd.h>
53#  endif
54#endif
55
56extern shared_info_t *HYPERVISOR_shared_info;
57
58#define vcpu_info(cpu) (HYPERVISOR_shared_info->vcpu_info + (cpu))
59#ifdef CONFIG_SMP
60#define current_vcpu_info() vcpu_info(smp_processor_id())
61#else
62#define current_vcpu_info() vcpu_info(0)
63#endif
64
65#ifdef CONFIG_X86_32
66extern unsigned long hypervisor_virt_start;
67#endif
68
69/* arch/xen/i386/kernel/setup.c */
70extern start_info_t *xen_start_info;
71#ifdef CONFIG_XEN_PRIVILEGED_GUEST
72#define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN)
73#else
74#define is_initial_xendomain() 0
75#endif
76
77/* arch/xen/kernel/evtchn.c */
78/* Force a proper event-channel callback from Xen. */
79void force_evtchn_callback(void);
80
81/* arch/xen/kernel/process.c */
82void xen_cpu_idle (void);
83
84/* arch/xen/i386/kernel/hypervisor.c */
85void do_hypervisor_callback(struct pt_regs *regs);
86
87/* arch/xen/i386/mm/hypervisor.c */
88/*
89 * NB. ptr values should be PHYSICAL, not MACHINE. 'vals' should be already
90 * be MACHINE addresses.
91 */
92
93void xen_pt_switch(unsigned long ptr);
94void xen_new_user_pt(unsigned long ptr); /* x86_64 only */
95void xen_load_gs(unsigned int selector); /* x86_64 only */
96void xen_tlb_flush(void);
97void xen_invlpg(unsigned long ptr);
98
99void xen_l1_entry_update(pte_t *ptr, pte_t val);
100void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
101void xen_l3_entry_update(pud_t *ptr, pud_t val); /* x86_64/PAE */
102void xen_l4_entry_update(pgd_t *ptr, pgd_t val); /* x86_64 only */
103void xen_pgd_pin(unsigned long ptr);
104void xen_pgd_unpin(unsigned long ptr);
105
106void xen_set_ldt(unsigned long ptr, unsigned long bytes);
107
108#ifdef CONFIG_SMP
109#include <linux/cpumask.h>
110void xen_tlb_flush_all(void);
111void xen_invlpg_all(unsigned long ptr);
112void xen_tlb_flush_mask(cpumask_t *mask);
113void xen_invlpg_mask(cpumask_t *mask, unsigned long ptr);
114#endif
115
116/* Returns zero on success else negative errno. */
117int xen_create_contiguous_region(
118    unsigned long vstart, unsigned int order, unsigned int address_bits);
119void xen_destroy_contiguous_region(
120    unsigned long vstart, unsigned int order);
121
122/* Turn jiffies into Xen system time. */
123u64 jiffies_to_st(unsigned long jiffies);
124
125#ifdef CONFIG_XEN_SCRUB_PAGES
126#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
127#else
128#define scrub_pages(_p,_n) ((void)0)
129#endif
130
131#include <xen/hypercall.h>
132
133#if defined(CONFIG_X86_64)
134#define MULTI_UVMFLAGS_INDEX 2
135#define MULTI_UVMDOMID_INDEX 3
136#else
137#define MULTI_UVMFLAGS_INDEX 3
138#define MULTI_UVMDOMID_INDEX 4
139#endif
140
141#define is_running_on_xen() 1
142
143static inline int
144HYPERVISOR_yield(
145        void)
146{
147        int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
148
149#if CONFIG_XEN_COMPAT <= 0x030002
150        if (rc == -ENOSYS)
151                rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
152#endif
153
154        return rc;
155}
156
157static inline int
158HYPERVISOR_block(
159        void)
160{
161        int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
162
163#if CONFIG_XEN_COMPAT <= 0x030002
164        if (rc == -ENOSYS)
165                rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
166#endif
167
168        return rc;
169}
170
171static inline int
172HYPERVISOR_shutdown(
173        unsigned int reason)
174{
175        struct sched_shutdown sched_shutdown = {
176                .reason = reason
177        };
178
179        int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
180
181#if CONFIG_XEN_COMPAT <= 0x030002
182        if (rc == -ENOSYS)
183                rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
184#endif
185
186        return rc;
187}
188
189static inline int
190HYPERVISOR_poll(
191        evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
192{
193        int rc;
194        struct sched_poll sched_poll = {
195                .nr_ports = nr_ports,
196                .timeout = jiffies_to_st(timeout)
197        };
198        set_xen_guest_handle(sched_poll.ports, ports);
199
200        rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
201#if CONFIG_XEN_COMPAT <= 0x030002
202        if (rc == -ENOSYS)
203                rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
204#endif
205
206        return rc;
207}
208
209static inline void
210MULTI_update_va_mapping(
211    multicall_entry_t *mcl, unsigned long va,
212    pte_t new_val, unsigned long flags)
213{
214    mcl->op = __HYPERVISOR_update_va_mapping;
215    mcl->args[0] = va;
216#if defined(CONFIG_X86_64)
217    mcl->args[1] = new_val.pte;
218#elif defined(CONFIG_X86_PAE)
219    mcl->args[1] = new_val.pte_low;
220    mcl->args[2] = new_val.pte_high;
221#else
222    mcl->args[1] = new_val.pte_low;
223    mcl->args[2] = 0;
224#endif
225    mcl->args[MULTI_UVMFLAGS_INDEX] = flags;
226}
227
228static inline void
229MULTI_grant_table_op(multicall_entry_t *mcl, unsigned int cmd,
230                     void *uop, unsigned int count)
231{
232    mcl->op = __HYPERVISOR_grant_table_op;
233    mcl->args[0] = cmd;
234    mcl->args[1] = (unsigned long)uop;
235    mcl->args[2] = count;
236}
237
238static inline void
239MULTI_update_va_mapping_otherdomain(
240    multicall_entry_t *mcl, unsigned long va,
241    pte_t new_val, unsigned long flags, domid_t domid)
242{
243    mcl->op = __HYPERVISOR_update_va_mapping_otherdomain;
244    mcl->args[0] = va;
245#if defined(CONFIG_X86_64)
246    mcl->args[1] = new_val.pte;
247#elif defined(CONFIG_X86_PAE)
248    mcl->args[1] = new_val.pte_low;
249    mcl->args[2] = new_val.pte_high;
250#else
251    mcl->args[1] = new_val.pte_low;
252    mcl->args[2] = 0;
253#endif
254    mcl->args[MULTI_UVMFLAGS_INDEX] = flags;
255    mcl->args[MULTI_UVMDOMID_INDEX] = domid;
256}
257
258#endif /* __HYPERVISOR_H__ */
Note: See TracBrowser for help on using the repository browser.