ia64/xen-unstable

annotate xen/include/asm-x86/hvm/support.h @ 10892:0d2ba35c0cf2

[XEN] Add hypercall support for HVM guests. This is
fairly useless at the moment, since all of the hypercalls
fail, since copy_from_user doesn't work correctly in HVM
domains.

Signed-off-by: Steven Smith <ssmith@xensource.com>

Add a CPUID hypervisor platform interface at leaf
0x40000000. Allow hypercall transfer page to be filled
in via MSR 0x40000000.

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