ia64/xen-unstable

view xen/include/asm-x86/hvm/hvm.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 f0e14b4e535c
children 857e7b864bb0
line source
1 /*
2 * hvm.h: Hardware virtual machine assist interface definitions.
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 */
20 #ifndef __ASM_X86_HVM_HVM_H__
21 #define __ASM_X86_HVM_HVM_H__
23 /*
24 * The hardware virtual machine (HVM) interface abstracts away from the
25 * x86/x86_64 CPU virtualization assist specifics. Currently this interface
26 * supports Intel's VT-x and AMD's SVM extensions.
27 */
29 struct hvm_function_table {
30 /*
31 * Disable HVM functionality
32 */
33 void (*disable)(void);
35 /*
36 * Initialize/relinguish HVM guest resources
37 */
38 int (*initialize_guest_resources)(struct vcpu *v);
39 void (*relinquish_guest_resources)(struct domain *d);
41 /*
42 * Store and load guest state:
43 * 1) load/store guest register state,
44 * 2) modify guest state (e.g., set debug flags).
45 */
46 void (*store_cpu_guest_regs)(
47 struct vcpu *v, struct cpu_user_regs *r, unsigned long *crs);
48 void (*load_cpu_guest_regs)(
49 struct vcpu *v, struct cpu_user_regs *r);
50 /*
51 * Examine specifics of the guest state:
52 * 1) determine whether the guest is in real or vm8086 mode,
53 * 2) determine whether paging is enabled,
54 * 3) return the length of the instruction that caused an exit.
55 * 4) return the current guest control-register value
56 */
57 int (*realmode)(struct vcpu *v);
58 int (*paging_enabled)(struct vcpu *v);
59 int (*instruction_length)(struct vcpu *v);
60 unsigned long (*get_guest_ctrl_reg)(struct vcpu *v, unsigned int num);
62 void (*init_ap_context)(struct vcpu_guest_context *ctxt,
63 int vcpuid, int trampoline_vector);
65 void (*init_hypercall_page)(struct domain *d, void *hypercall_page);
66 };
68 extern struct hvm_function_table hvm_funcs;
70 /*
71 * For convenience, we use short hands.
72 */
73 static inline void
74 hvm_disable(void)
75 {
76 if ( hvm_funcs.disable )
77 hvm_funcs.disable();
78 }
80 static inline int
81 hvm_initialize_guest_resources(struct vcpu *v)
82 {
83 if ( hvm_funcs.initialize_guest_resources )
84 return hvm_funcs.initialize_guest_resources(v);
85 return 0;
86 }
88 static inline void
89 hvm_relinquish_guest_resources(struct domain *d)
90 {
91 if (hvm_funcs.relinquish_guest_resources)
92 hvm_funcs.relinquish_guest_resources(d);
93 }
95 static inline void
96 hvm_store_cpu_guest_regs(
97 struct vcpu *v, struct cpu_user_regs *r, unsigned long *crs)
98 {
99 hvm_funcs.store_cpu_guest_regs(v, r, crs);
100 }
102 static inline void
103 hvm_load_cpu_guest_regs(struct vcpu *v, struct cpu_user_regs *r)
104 {
105 hvm_funcs.load_cpu_guest_regs(v, r);
106 }
108 static inline int
109 hvm_realmode(struct vcpu *v)
110 {
111 return hvm_funcs.realmode(v);
112 }
114 static inline int
115 hvm_paging_enabled(struct vcpu *v)
116 {
117 return hvm_funcs.paging_enabled(v);
118 }
120 static inline int
121 hvm_instruction_length(struct vcpu *v)
122 {
123 return hvm_funcs.instruction_length(v);
124 }
126 void hvm_hypercall_page_initialise(struct domain *d,
127 void *hypercall_page);
129 static inline unsigned long
130 hvm_get_guest_ctrl_reg(struct vcpu *v, unsigned int num)
131 {
132 if ( hvm_funcs.get_guest_ctrl_reg )
133 return hvm_funcs.get_guest_ctrl_reg(v, num);
134 return 0; /* force to fail */
135 }
137 static inline void
138 hvm_init_ap_context(struct vcpu_guest_context *ctxt,
139 int vcpuid, int trampoline_vector)
140 {
141 return hvm_funcs.init_ap_context(ctxt, vcpuid, trampoline_vector);
142 }
144 extern int hvm_bringup_ap(int vcpuid, int trampoline_vector);
146 #endif /* __ASM_X86_HVM_HVM_H__ */