diff options
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r-- | include/linux/kvm_host.h | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 928b0d59e9ba..398978972b7a 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
17 | #include <linux/preempt.h> | 17 | #include <linux/preempt.h> |
18 | #include <linux/marker.h> | ||
18 | #include <asm/signal.h> | 19 | #include <asm/signal.h> |
19 | 20 | ||
20 | #include <linux/kvm.h> | 21 | #include <linux/kvm.h> |
@@ -24,29 +25,18 @@ | |||
24 | 25 | ||
25 | #include <asm/kvm_host.h> | 26 | #include <asm/kvm_host.h> |
26 | 27 | ||
27 | #define KVM_MAX_VCPUS 4 | ||
28 | #define KVM_MEMORY_SLOTS 8 | ||
29 | /* memory slots that does not exposed to userspace */ | ||
30 | #define KVM_PRIVATE_MEM_SLOTS 4 | ||
31 | |||
32 | #define KVM_PIO_PAGE_OFFSET 1 | ||
33 | |||
34 | /* | 28 | /* |
35 | * vcpu->requests bit members | 29 | * vcpu->requests bit members |
36 | */ | 30 | */ |
37 | #define KVM_REQ_TLB_FLUSH 0 | 31 | #define KVM_REQ_TLB_FLUSH 0 |
38 | #define KVM_REQ_MIGRATE_TIMER 1 | 32 | #define KVM_REQ_MIGRATE_TIMER 1 |
39 | #define KVM_REQ_REPORT_TPR_ACCESS 2 | 33 | #define KVM_REQ_REPORT_TPR_ACCESS 2 |
34 | #define KVM_REQ_MMU_RELOAD 3 | ||
35 | #define KVM_REQ_TRIPLE_FAULT 4 | ||
40 | 36 | ||
41 | struct kvm_vcpu; | 37 | struct kvm_vcpu; |
42 | extern struct kmem_cache *kvm_vcpu_cache; | 38 | extern struct kmem_cache *kvm_vcpu_cache; |
43 | 39 | ||
44 | struct kvm_guest_debug { | ||
45 | int enabled; | ||
46 | unsigned long bp[4]; | ||
47 | int singlestep; | ||
48 | }; | ||
49 | |||
50 | /* | 40 | /* |
51 | * It would be nice to use something smarter than a linear search, TBD... | 41 | * It would be nice to use something smarter than a linear search, TBD... |
52 | * Thankfully we dont expect many devices to register (famous last words :), | 42 | * Thankfully we dont expect many devices to register (famous last words :), |
@@ -67,7 +57,9 @@ void kvm_io_bus_register_dev(struct kvm_io_bus *bus, | |||
67 | 57 | ||
68 | struct kvm_vcpu { | 58 | struct kvm_vcpu { |
69 | struct kvm *kvm; | 59 | struct kvm *kvm; |
60 | #ifdef CONFIG_PREEMPT_NOTIFIERS | ||
70 | struct preempt_notifier preempt_notifier; | 61 | struct preempt_notifier preempt_notifier; |
62 | #endif | ||
71 | int vcpu_id; | 63 | int vcpu_id; |
72 | struct mutex mutex; | 64 | struct mutex mutex; |
73 | int cpu; | 65 | int cpu; |
@@ -100,6 +92,10 @@ struct kvm_memory_slot { | |||
100 | unsigned long flags; | 92 | unsigned long flags; |
101 | unsigned long *rmap; | 93 | unsigned long *rmap; |
102 | unsigned long *dirty_bitmap; | 94 | unsigned long *dirty_bitmap; |
95 | struct { | ||
96 | unsigned long rmap_pde; | ||
97 | int write_count; | ||
98 | } *lpage_info; | ||
103 | unsigned long userspace_addr; | 99 | unsigned long userspace_addr; |
104 | int user_alloc; | 100 | int user_alloc; |
105 | }; | 101 | }; |
@@ -114,11 +110,11 @@ struct kvm { | |||
114 | KVM_PRIVATE_MEM_SLOTS]; | 110 | KVM_PRIVATE_MEM_SLOTS]; |
115 | struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; | 111 | struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; |
116 | struct list_head vm_list; | 112 | struct list_head vm_list; |
117 | struct file *filp; | ||
118 | struct kvm_io_bus mmio_bus; | 113 | struct kvm_io_bus mmio_bus; |
119 | struct kvm_io_bus pio_bus; | 114 | struct kvm_io_bus pio_bus; |
120 | struct kvm_vm_stat stat; | 115 | struct kvm_vm_stat stat; |
121 | struct kvm_arch arch; | 116 | struct kvm_arch arch; |
117 | atomic_t users_count; | ||
122 | }; | 118 | }; |
123 | 119 | ||
124 | /* The guest did something we don't support. */ | 120 | /* The guest did something we don't support. */ |
@@ -145,14 +141,19 @@ int kvm_init(void *opaque, unsigned int vcpu_size, | |||
145 | struct module *module); | 141 | struct module *module); |
146 | void kvm_exit(void); | 142 | void kvm_exit(void); |
147 | 143 | ||
144 | void kvm_get_kvm(struct kvm *kvm); | ||
145 | void kvm_put_kvm(struct kvm *kvm); | ||
146 | |||
148 | #define HPA_MSB ((sizeof(hpa_t) * 8) - 1) | 147 | #define HPA_MSB ((sizeof(hpa_t) * 8) - 1) |
149 | #define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB) | 148 | #define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB) |
150 | static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; } | 149 | static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; } |
151 | struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva); | 150 | struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva); |
152 | 151 | ||
153 | extern struct page *bad_page; | 152 | extern struct page *bad_page; |
153 | extern pfn_t bad_pfn; | ||
154 | 154 | ||
155 | int is_error_page(struct page *page); | 155 | int is_error_page(struct page *page); |
156 | int is_error_pfn(pfn_t pfn); | ||
156 | int kvm_is_error_hva(unsigned long addr); | 157 | int kvm_is_error_hva(unsigned long addr); |
157 | int kvm_set_memory_region(struct kvm *kvm, | 158 | int kvm_set_memory_region(struct kvm *kvm, |
158 | struct kvm_userspace_memory_region *mem, | 159 | struct kvm_userspace_memory_region *mem, |
@@ -166,8 +167,19 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
166 | int user_alloc); | 167 | int user_alloc); |
167 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); | 168 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); |
168 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); | 169 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); |
170 | unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn); | ||
169 | void kvm_release_page_clean(struct page *page); | 171 | void kvm_release_page_clean(struct page *page); |
170 | void kvm_release_page_dirty(struct page *page); | 172 | void kvm_release_page_dirty(struct page *page); |
173 | void kvm_set_page_dirty(struct page *page); | ||
174 | void kvm_set_page_accessed(struct page *page); | ||
175 | |||
176 | pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn); | ||
177 | void kvm_release_pfn_dirty(pfn_t); | ||
178 | void kvm_release_pfn_clean(pfn_t pfn); | ||
179 | void kvm_set_pfn_dirty(pfn_t pfn); | ||
180 | void kvm_set_pfn_accessed(pfn_t pfn); | ||
181 | void kvm_get_pfn(pfn_t pfn); | ||
182 | |||
171 | int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset, | 183 | int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset, |
172 | int len); | 184 | int len); |
173 | int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data, | 185 | int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data, |
@@ -188,6 +200,7 @@ void kvm_resched(struct kvm_vcpu *vcpu); | |||
188 | void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); | 200 | void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); |
189 | void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); | 201 | void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); |
190 | void kvm_flush_remote_tlbs(struct kvm *kvm); | 202 | void kvm_flush_remote_tlbs(struct kvm *kvm); |
203 | void kvm_reload_remote_mmus(struct kvm *kvm); | ||
191 | 204 | ||
192 | long kvm_arch_dev_ioctl(struct file *filp, | 205 | long kvm_arch_dev_ioctl(struct file *filp, |
193 | unsigned int ioctl, unsigned long arg); | 206 | unsigned int ioctl, unsigned long arg); |
@@ -223,6 +236,10 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, | |||
223 | struct kvm_sregs *sregs); | 236 | struct kvm_sregs *sregs); |
224 | int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | 237 | int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, |
225 | struct kvm_sregs *sregs); | 238 | struct kvm_sregs *sregs); |
239 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, | ||
240 | struct kvm_mp_state *mp_state); | ||
241 | int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, | ||
242 | struct kvm_mp_state *mp_state); | ||
226 | int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, | 243 | int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, |
227 | struct kvm_debug_guest *dbg); | 244 | struct kvm_debug_guest *dbg); |
228 | int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run); | 245 | int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run); |
@@ -255,6 +272,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm); | |||
255 | 272 | ||
256 | int kvm_cpu_get_interrupt(struct kvm_vcpu *v); | 273 | int kvm_cpu_get_interrupt(struct kvm_vcpu *v); |
257 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v); | 274 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v); |
275 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); | ||
258 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); | 276 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); |
259 | 277 | ||
260 | static inline void kvm_guest_enter(void) | 278 | static inline void kvm_guest_enter(void) |
@@ -296,5 +314,18 @@ struct kvm_stats_debugfs_item { | |||
296 | struct dentry *dentry; | 314 | struct dentry *dentry; |
297 | }; | 315 | }; |
298 | extern struct kvm_stats_debugfs_item debugfs_entries[]; | 316 | extern struct kvm_stats_debugfs_item debugfs_entries[]; |
317 | extern struct dentry *kvm_debugfs_dir; | ||
318 | |||
319 | #ifdef CONFIG_KVM_TRACE | ||
320 | int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg); | ||
321 | void kvm_trace_cleanup(void); | ||
322 | #else | ||
323 | static inline | ||
324 | int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg) | ||
325 | { | ||
326 | return -EINVAL; | ||
327 | } | ||
328 | #define kvm_trace_cleanup() ((void)0) | ||
329 | #endif | ||
299 | 330 | ||
300 | #endif | 331 | #endif |