ia64/xen-unstable

view xen/include/asm-x86/hvm/support.h @ 10908:a6cb8ba24a91

[HVM] Place all APIC registers into one page in native format.
With this change we can re-use code at include/asm-x86/apicdef.h,
making the code much cleaner. Also it help for future enhancement.

This patch does not change any logic except the change to
CONTROL_REG_ACCESS_NUM, which should be 0xf for CR8 access.

Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com
author kfraser@localhost.localdomain
date Wed Aug 02 10:07:03 2006 +0100 (2006-08-02)
parents 0d2ba35c0cf2
children 415614d3a1ee
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 static inline int iopacket_port(struct vcpu *v)
48 {
49 return get_vio(v->domain, v->vcpu_id)->vp_eport;
50 }
52 /* XXX these are really VMX specific */
53 #define TYPE_MOV_TO_DR (0 << 4)
54 #define TYPE_MOV_FROM_DR (1 << 4)
55 #define TYPE_MOV_TO_CR (0 << 4)
56 #define TYPE_MOV_FROM_CR (1 << 4)
57 #define TYPE_CLTS (2 << 4)
58 #define TYPE_LMSW (3 << 4)
60 enum hval_bitmaps {
61 EXCEPTION_BITMAP_TABLE=0,
62 };
64 #define EXCEPTION_BITMAP_DE (1 << 0) /* Divide Error */
65 #define EXCEPTION_BITMAP_DB (1 << 1) /* Debug */
66 #define EXCEPTION_BITMAP_NMI (1 << 2) /* NMI */
67 #define EXCEPTION_BITMAP_BP (1 << 3) /* Breakpoint */
68 #define EXCEPTION_BITMAP_OF (1 << 4) /* Overflow */
69 #define EXCEPTION_BITMAP_BR (1 << 5) /* BOUND Range Exceeded */
70 #define EXCEPTION_BITMAP_UD (1 << 6) /* Invalid Opcode */
71 #define EXCEPTION_BITMAP_NM (1 << 7) /* Device Not Available */
72 #define EXCEPTION_BITMAP_DF (1 << 8) /* Double Fault */
73 /* reserved */
74 #define EXCEPTION_BITMAP_TS (1 << 10) /* Invalid TSS */
75 #define EXCEPTION_BITMAP_NP (1 << 11) /* Segment Not Present */
76 #define EXCEPTION_BITMAP_SS (1 << 12) /* Stack-Segment Fault */
77 #define EXCEPTION_BITMAP_GP (1 << 13) /* General Protection */
78 #define EXCEPTION_BITMAP_PG (1 << 14) /* Page Fault */
79 #define EXCEPTION_BITMAP_MF (1 << 16) /* x87 FPU Floating-Point Error (Math Fault) */
80 #define EXCEPTION_BITMAP_AC (1 << 17) /* Alignment Check */
81 #define EXCEPTION_BITMAP_MC (1 << 18) /* Machine Check */
82 #define EXCEPTION_BITMAP_XF (1 << 19) /* SIMD Floating-Point Exception */
84 /* Pending Debug exceptions */
85 #define PENDING_DEBUG_EXC_BP (1 << 12) /* break point */
86 #define PENDING_DEBUG_EXC_BS (1 << 14) /* Single step */
88 #ifdef XEN_DEBUGGER
89 #define MONITOR_DEFAULT_EXCEPTION_BITMAP \
90 ( EXCEPTION_BITMAP_PG | \
91 EXCEPTION_BITMAP_DB | \
92 EXCEPTION_BITMAP_BP | \
93 EXCEPTION_BITMAP_GP )
94 #else
95 #define MONITOR_DEFAULT_EXCEPTION_BITMAP \
96 ( EXCEPTION_BITMAP_PG | \
97 EXCEPTION_BITMAP_BP )
98 #endif
100 #define PC_DEBUG_PORT 0x80
102 #define VMX_DELIVER_NO_ERROR_CODE -1
104 /*
105 * This works for both 32bit & 64bit eflags filteration
106 * done in construct_init_vmc[sb]_guest()
107 */
108 #define HVM_EFLAGS_RESERVED_0 0xffc08028 /* bitmap for 0 */
109 #define HVM_EFLAGS_RESERVED_1 0x00000002 /* bitmap for 1 */
111 #if HVM_DEBUG
112 #define DBG_LEVEL_0 (1 << 0)
113 #define DBG_LEVEL_1 (1 << 1)
114 #define DBG_LEVEL_2 (1 << 2)
115 #define DBG_LEVEL_3 (1 << 3)
116 #define DBG_LEVEL_IO (1 << 4)
117 #define DBG_LEVEL_VMMU (1 << 5)
118 #define DBG_LEVEL_VLAPIC (1 << 6)
119 #define DBG_LEVEL_VLAPIC_TIMER (1 << 7)
120 #define DBG_LEVEL_VLAPIC_INTERRUPT (1 << 8)
121 #define DBG_LEVEL_IOAPIC (1 << 9)
123 extern unsigned int opt_hvm_debug_level;
124 #define HVM_DBG_LOG(level, _f, _a...) \
125 if ( (level) & opt_hvm_debug_level ) \
126 printk("[HVM:%d.%d] <%s> " _f "\n", \
127 current->domain->domain_id, current->vcpu_id, __func__, ## _a)
128 #else
129 #define HVM_DBG_LOG(level, _f, _a...)
130 #endif
132 #define __hvm_bug(regs) \
133 do { \
134 printk("__hvm_bug at %s:%d\n", __FILE__, __LINE__); \
135 show_execution_state(regs); \
136 domain_crash_synchronous(); \
137 } while (0)
139 extern int hvm_enabled;
141 enum { HVM_COPY_IN = 0, HVM_COPY_OUT };
142 extern int hvm_copy(void *buf, unsigned long vaddr, int size, int dir);
144 extern void hvm_setup_platform(struct domain* d);
145 extern int hvm_mmio_intercept(ioreq_t *p);
146 extern int hvm_io_intercept(ioreq_t *p, int type);
147 extern void hvm_hooks_assist(struct vcpu *v);
148 extern void hvm_print_line(struct vcpu *v, const char c);
149 extern void hlt_timer_fn(void *data);
151 void hvm_do_hypercall(struct cpu_user_regs *pregs);
153 #endif /* __ASM_X86_HVM_SUPPORT_H__ */