ia64/xen-unstable

view xen/include/asm-x86/hvm/support.h @ 11002:415614d3a1ee

[hvm/qemu] Flip the device model over to using the new Xen event channels
support.

Signed-off-by: Steven Smith <ssmith@xensource.com>
author sos22@douglas.cl.cam.ac.uk
date Tue Aug 08 11:19:29 2006 +0100 (2006-08-08)
parents a6cb8ba24a91
children dc7b56b8cfb5
line source
1 /*
2 * support.h: HVM support routines used by VT-x and SVM.
3 *
4 * Leendert van Doorn, leendert@watson.ibm.com
5 * Copyright (c) 2005, International Business Machines Corporation.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 * Place - Suite 330, Boston, MA 02111-1307 USA.
19 */
21 #ifndef __ASM_X86_HVM_SUPPORT_H__
22 #define __ASM_X86_HVM_SUPPORT_H__
24 #include <xen/sched.h>
25 #include <asm/types.h>
26 #include <asm/regs.h>
27 #include <asm/processor.h>
29 #ifndef NDEBUG
30 #define HVM_DEBUG 1
31 #else
32 #define HVM_DEBUG 1
33 #endif
35 #define hvm_guest(v) ((v)->arch.guest_context.flags & VGCF_HVM_GUEST)
37 static inline shared_iopage_t *get_sp(struct domain *d)
38 {
39 return (shared_iopage_t *) d->arch.hvm_domain.shared_page_va;
40 }
42 static inline vcpu_iodata_t *get_vio(struct domain *d, unsigned long cpu)
43 {
44 return &get_sp(d)->vcpu_iodata[cpu];
45 }
47 /* XXX these are really VMX specific */
48 #define TYPE_MOV_TO_DR (0 << 4)
49 #define TYPE_MOV_FROM_DR (1 << 4)
50 #define TYPE_MOV_TO_CR (0 << 4)
51 #define TYPE_MOV_FROM_CR (1 << 4)
52 #define TYPE_CLTS (2 << 4)
53 #define TYPE_LMSW (3 << 4)
55 enum hval_bitmaps {
56 EXCEPTION_BITMAP_TABLE=0,
57 };
59 #define EXCEPTION_BITMAP_DE (1 << 0) /* Divide Error */
60 #define EXCEPTION_BITMAP_DB (1 << 1) /* Debug */
61 #define EXCEPTION_BITMAP_NMI (1 << 2) /* NMI */
62 #define EXCEPTION_BITMAP_BP (1 << 3) /* Breakpoint */
63 #define EXCEPTION_BITMAP_OF (1 << 4) /* Overflow */
64 #define EXCEPTION_BITMAP_BR (1 << 5) /* BOUND Range Exceeded */
65 #define EXCEPTION_BITMAP_UD (1 << 6) /* Invalid Opcode */
66 #define EXCEPTION_BITMAP_NM (1 << 7) /* Device Not Available */
67 #define EXCEPTION_BITMAP_DF (1 << 8) /* Double Fault */
68 /* reserved */
69 #define EXCEPTION_BITMAP_TS (1 << 10) /* Invalid TSS */
70 #define EXCEPTION_BITMAP_NP (1 << 11) /* Segment Not Present */
71 #define EXCEPTION_BITMAP_SS (1 << 12) /* Stack-Segment Fault */
72 #define EXCEPTION_BITMAP_GP (1 << 13) /* General Protection */
73 #define EXCEPTION_BITMAP_PG (1 << 14) /* Page Fault */
74 #define EXCEPTION_BITMAP_MF (1 << 16) /* x87 FPU Floating-Point Error (Math Fault) */
75 #define EXCEPTION_BITMAP_AC (1 << 17) /* Alignment Check */
76 #define EXCEPTION_BITMAP_MC (1 << 18) /* Machine Check */
77 #define EXCEPTION_BITMAP_XF (1 << 19) /* SIMD Floating-Point Exception */
79 /* Pending Debug exceptions */
80 #define PENDING_DEBUG_EXC_BP (1 << 12) /* break point */
81 #define PENDING_DEBUG_EXC_BS (1 << 14) /* Single step */
83 #ifdef XEN_DEBUGGER
84 #define MONITOR_DEFAULT_EXCEPTION_BITMAP \
85 ( EXCEPTION_BITMAP_PG | \
86 EXCEPTION_BITMAP_DB | \
87 EXCEPTION_BITMAP_BP | \
88 EXCEPTION_BITMAP_GP )
89 #else
90 #define MONITOR_DEFAULT_EXCEPTION_BITMAP \
91 ( EXCEPTION_BITMAP_PG | \
92 EXCEPTION_BITMAP_BP )
93 #endif
95 #define PC_DEBUG_PORT 0x80
97 #define VMX_DELIVER_NO_ERROR_CODE -1
99 /*
100 * This works for both 32bit & 64bit eflags filteration
101 * done in construct_init_vmc[sb]_guest()
102 */
103 #define HVM_EFLAGS_RESERVED_0 0xffc08028 /* bitmap for 0 */
104 #define HVM_EFLAGS_RESERVED_1 0x00000002 /* bitmap for 1 */
106 #if HVM_DEBUG
107 #define DBG_LEVEL_0 (1 << 0)
108 #define DBG_LEVEL_1 (1 << 1)
109 #define DBG_LEVEL_2 (1 << 2)
110 #define DBG_LEVEL_3 (1 << 3)
111 #define DBG_LEVEL_IO (1 << 4)
112 #define DBG_LEVEL_VMMU (1 << 5)
113 #define DBG_LEVEL_VLAPIC (1 << 6)
114 #define DBG_LEVEL_VLAPIC_TIMER (1 << 7)
115 #define DBG_LEVEL_VLAPIC_INTERRUPT (1 << 8)
116 #define DBG_LEVEL_IOAPIC (1 << 9)
118 extern unsigned int opt_hvm_debug_level;
119 #define HVM_DBG_LOG(level, _f, _a...) \
120 if ( (level) & opt_hvm_debug_level ) \
121 printk("[HVM:%d.%d] <%s> " _f "\n", \
122 current->domain->domain_id, current->vcpu_id, __func__, ## _a)
123 #else
124 #define HVM_DBG_LOG(level, _f, _a...)
125 #endif
127 #define __hvm_bug(regs) \
128 do { \
129 printk("__hvm_bug at %s:%d\n", __FILE__, __LINE__); \
130 show_execution_state(regs); \
131 domain_crash_synchronous(); \
132 } while (0)
134 extern int hvm_enabled;
136 enum { HVM_COPY_IN = 0, HVM_COPY_OUT };
137 extern int hvm_copy(void *buf, unsigned long vaddr, int size, int dir);
139 extern void hvm_setup_platform(struct domain* d);
140 extern int hvm_mmio_intercept(ioreq_t *p);
141 extern int hvm_io_intercept(ioreq_t *p, int type);
142 extern void hvm_hooks_assist(struct vcpu *v);
143 extern void hvm_print_line(struct vcpu *v, const char c);
144 extern void hlt_timer_fn(void *data);
146 void hvm_do_hypercall(struct cpu_user_regs *pregs);
148 void hvm_prod_vcpu(struct vcpu *v);
150 #endif /* __ASM_X86_HVM_SUPPORT_H__ */