diff options
Diffstat (limited to 'arch/x86/include/asm/kvm_host.h')
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 81 |
1 files changed, 72 insertions, 9 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index c52e2eb40a1e..9e6fe391094e 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -236,10 +236,14 @@ struct kvm_pio_request { | |||
236 | */ | 236 | */ |
237 | struct kvm_mmu { | 237 | struct kvm_mmu { |
238 | void (*new_cr3)(struct kvm_vcpu *vcpu); | 238 | void (*new_cr3)(struct kvm_vcpu *vcpu); |
239 | void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long root); | ||
240 | unsigned long (*get_cr3)(struct kvm_vcpu *vcpu); | ||
239 | int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err); | 241 | int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err); |
242 | void (*inject_page_fault)(struct kvm_vcpu *vcpu); | ||
240 | void (*free)(struct kvm_vcpu *vcpu); | 243 | void (*free)(struct kvm_vcpu *vcpu); |
241 | gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access, | 244 | gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access, |
242 | u32 *error); | 245 | u32 *error); |
246 | gpa_t (*translate_gpa)(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access); | ||
243 | void (*prefetch_page)(struct kvm_vcpu *vcpu, | 247 | void (*prefetch_page)(struct kvm_vcpu *vcpu, |
244 | struct kvm_mmu_page *page); | 248 | struct kvm_mmu_page *page); |
245 | int (*sync_page)(struct kvm_vcpu *vcpu, | 249 | int (*sync_page)(struct kvm_vcpu *vcpu, |
@@ -249,13 +253,18 @@ struct kvm_mmu { | |||
249 | int root_level; | 253 | int root_level; |
250 | int shadow_root_level; | 254 | int shadow_root_level; |
251 | union kvm_mmu_page_role base_role; | 255 | union kvm_mmu_page_role base_role; |
256 | bool direct_map; | ||
252 | 257 | ||
253 | u64 *pae_root; | 258 | u64 *pae_root; |
259 | u64 *lm_root; | ||
254 | u64 rsvd_bits_mask[2][4]; | 260 | u64 rsvd_bits_mask[2][4]; |
261 | |||
262 | bool nx; | ||
263 | |||
264 | u64 pdptrs[4]; /* pae */ | ||
255 | }; | 265 | }; |
256 | 266 | ||
257 | struct kvm_vcpu_arch { | 267 | struct kvm_vcpu_arch { |
258 | u64 host_tsc; | ||
259 | /* | 268 | /* |
260 | * rip and regs accesses must go through | 269 | * rip and regs accesses must go through |
261 | * kvm_{register,rip}_{read,write} functions. | 270 | * kvm_{register,rip}_{read,write} functions. |
@@ -272,7 +281,6 @@ struct kvm_vcpu_arch { | |||
272 | unsigned long cr4_guest_owned_bits; | 281 | unsigned long cr4_guest_owned_bits; |
273 | unsigned long cr8; | 282 | unsigned long cr8; |
274 | u32 hflags; | 283 | u32 hflags; |
275 | u64 pdptrs[4]; /* pae */ | ||
276 | u64 efer; | 284 | u64 efer; |
277 | u64 apic_base; | 285 | u64 apic_base; |
278 | struct kvm_lapic *apic; /* kernel irqchip context */ | 286 | struct kvm_lapic *apic; /* kernel irqchip context */ |
@@ -282,7 +290,41 @@ struct kvm_vcpu_arch { | |||
282 | u64 ia32_misc_enable_msr; | 290 | u64 ia32_misc_enable_msr; |
283 | bool tpr_access_reporting; | 291 | bool tpr_access_reporting; |
284 | 292 | ||
293 | /* | ||
294 | * Paging state of the vcpu | ||
295 | * | ||
296 | * If the vcpu runs in guest mode with two level paging this still saves | ||
297 | * the paging mode of the l1 guest. This context is always used to | ||
298 | * handle faults. | ||
299 | */ | ||
285 | struct kvm_mmu mmu; | 300 | struct kvm_mmu mmu; |
301 | |||
302 | /* | ||
303 | * Paging state of an L2 guest (used for nested npt) | ||
304 | * | ||
305 | * This context will save all necessary information to walk page tables | ||
306 | * of the an L2 guest. This context is only initialized for page table | ||
307 | * walking and not for faulting since we never handle l2 page faults on | ||
308 | * the host. | ||
309 | */ | ||
310 | struct kvm_mmu nested_mmu; | ||
311 | |||
312 | /* | ||
313 | * Pointer to the mmu context currently used for | ||
314 | * gva_to_gpa translations. | ||
315 | */ | ||
316 | struct kvm_mmu *walk_mmu; | ||
317 | |||
318 | /* | ||
319 | * This struct is filled with the necessary information to propagate a | ||
320 | * page fault into the guest | ||
321 | */ | ||
322 | struct { | ||
323 | u64 address; | ||
324 | unsigned error_code; | ||
325 | bool nested; | ||
326 | } fault; | ||
327 | |||
286 | /* only needed in kvm_pv_mmu_op() path, but it's hot so | 328 | /* only needed in kvm_pv_mmu_op() path, but it's hot so |
287 | * put it here to avoid allocation */ | 329 | * put it here to avoid allocation */ |
288 | struct kvm_pv_mmu_op_buffer mmu_op_buffer; | 330 | struct kvm_pv_mmu_op_buffer mmu_op_buffer; |
@@ -336,9 +378,15 @@ struct kvm_vcpu_arch { | |||
336 | 378 | ||
337 | gpa_t time; | 379 | gpa_t time; |
338 | struct pvclock_vcpu_time_info hv_clock; | 380 | struct pvclock_vcpu_time_info hv_clock; |
339 | unsigned int hv_clock_tsc_khz; | 381 | unsigned int hw_tsc_khz; |
340 | unsigned int time_offset; | 382 | unsigned int time_offset; |
341 | struct page *time_page; | 383 | struct page *time_page; |
384 | u64 last_host_tsc; | ||
385 | u64 last_guest_tsc; | ||
386 | u64 last_kernel_ns; | ||
387 | u64 last_tsc_nsec; | ||
388 | u64 last_tsc_write; | ||
389 | bool tsc_catchup; | ||
342 | 390 | ||
343 | bool nmi_pending; | 391 | bool nmi_pending; |
344 | bool nmi_injected; | 392 | bool nmi_injected; |
@@ -367,9 +415,9 @@ struct kvm_vcpu_arch { | |||
367 | }; | 415 | }; |
368 | 416 | ||
369 | struct kvm_arch { | 417 | struct kvm_arch { |
370 | unsigned int n_free_mmu_pages; | 418 | unsigned int n_used_mmu_pages; |
371 | unsigned int n_requested_mmu_pages; | 419 | unsigned int n_requested_mmu_pages; |
372 | unsigned int n_alloc_mmu_pages; | 420 | unsigned int n_max_mmu_pages; |
373 | atomic_t invlpg_counter; | 421 | atomic_t invlpg_counter; |
374 | struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; | 422 | struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; |
375 | /* | 423 | /* |
@@ -394,8 +442,14 @@ struct kvm_arch { | |||
394 | gpa_t ept_identity_map_addr; | 442 | gpa_t ept_identity_map_addr; |
395 | 443 | ||
396 | unsigned long irq_sources_bitmap; | 444 | unsigned long irq_sources_bitmap; |
397 | u64 vm_init_tsc; | ||
398 | s64 kvmclock_offset; | 445 | s64 kvmclock_offset; |
446 | spinlock_t tsc_write_lock; | ||
447 | u64 last_tsc_nsec; | ||
448 | u64 last_tsc_offset; | ||
449 | u64 last_tsc_write; | ||
450 | u32 virtual_tsc_khz; | ||
451 | u32 virtual_tsc_mult; | ||
452 | s8 virtual_tsc_shift; | ||
399 | 453 | ||
400 | struct kvm_xen_hvm_config xen_hvm_config; | 454 | struct kvm_xen_hvm_config xen_hvm_config; |
401 | 455 | ||
@@ -505,6 +559,7 @@ struct kvm_x86_ops { | |||
505 | void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr, | 559 | void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr, |
506 | bool has_error_code, u32 error_code, | 560 | bool has_error_code, u32 error_code, |
507 | bool reinject); | 561 | bool reinject); |
562 | void (*cancel_injection)(struct kvm_vcpu *vcpu); | ||
508 | int (*interrupt_allowed)(struct kvm_vcpu *vcpu); | 563 | int (*interrupt_allowed)(struct kvm_vcpu *vcpu); |
509 | int (*nmi_allowed)(struct kvm_vcpu *vcpu); | 564 | int (*nmi_allowed)(struct kvm_vcpu *vcpu); |
510 | bool (*get_nmi_mask)(struct kvm_vcpu *vcpu); | 565 | bool (*get_nmi_mask)(struct kvm_vcpu *vcpu); |
@@ -517,11 +572,16 @@ struct kvm_x86_ops { | |||
517 | u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); | 572 | u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); |
518 | int (*get_lpage_level)(void); | 573 | int (*get_lpage_level)(void); |
519 | bool (*rdtscp_supported)(void); | 574 | bool (*rdtscp_supported)(void); |
575 | void (*adjust_tsc_offset)(struct kvm_vcpu *vcpu, s64 adjustment); | ||
576 | |||
577 | void (*set_tdp_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3); | ||
520 | 578 | ||
521 | void (*set_supported_cpuid)(u32 func, struct kvm_cpuid_entry2 *entry); | 579 | void (*set_supported_cpuid)(u32 func, struct kvm_cpuid_entry2 *entry); |
522 | 580 | ||
523 | bool (*has_wbinvd_exit)(void); | 581 | bool (*has_wbinvd_exit)(void); |
524 | 582 | ||
583 | void (*write_tsc_offset)(struct kvm_vcpu *vcpu, u64 offset); | ||
584 | |||
525 | const struct trace_print_flags *exit_reasons_str; | 585 | const struct trace_print_flags *exit_reasons_str; |
526 | }; | 586 | }; |
527 | 587 | ||
@@ -544,7 +604,7 @@ void kvm_mmu_zap_all(struct kvm *kvm); | |||
544 | unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm); | 604 | unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm); |
545 | void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages); | 605 | void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages); |
546 | 606 | ||
547 | int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); | 607 | int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3); |
548 | 608 | ||
549 | int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, | 609 | int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, |
550 | const void *val, int bytes); | 610 | const void *val, int bytes); |
@@ -608,8 +668,11 @@ void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr); | |||
608 | void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); | 668 | void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); |
609 | void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr); | 669 | void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr); |
610 | void kvm_requeue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); | 670 | void kvm_requeue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); |
611 | void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, | 671 | void kvm_inject_page_fault(struct kvm_vcpu *vcpu); |
612 | u32 error_code); | 672 | int kvm_read_guest_page_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, |
673 | gfn_t gfn, void *data, int offset, int len, | ||
674 | u32 access); | ||
675 | void kvm_propagate_fault(struct kvm_vcpu *vcpu); | ||
613 | bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl); | 676 | bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl); |
614 | 677 | ||
615 | int kvm_pic_set_irq(void *opaque, int irq, int level); | 678 | int kvm_pic_set_irq(void *opaque, int irq, int level); |