diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-14 20:43:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-14 20:43:43 -0400 |
commit | 69def9f05dfce3281bb06599057e6b8097385d39 (patch) | |
tree | 7d826b22924268ddbfad101993b248996d40e2ec /include | |
parent | 353f6dd2dec992ddd34620a94b051b0f76227379 (diff) | |
parent | 8e616fc8d343bd7f0f0a0c22407fdcb77f6d22b1 (diff) |
Merge branch 'kvm-updates/2.6.32' of git://git.kernel.org/pub/scm/virt/kvm/kvm
* 'kvm-updates/2.6.32' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (202 commits)
MAINTAINERS: update KVM entry
KVM: correct error-handling code
KVM: fix compile warnings on s390
KVM: VMX: Check cpl before emulating debug register access
KVM: fix misreporting of coalesced interrupts by kvm tracer
KVM: x86: drop duplicate kvm_flush_remote_tlb calls
KVM: VMX: call vmx_load_host_state() only if msr is cached
KVM: VMX: Conditionally reload debug register 6
KVM: Use thread debug register storage instead of kvm specific data
KVM guest: do not batch pte updates from interrupt context
KVM: Fix coalesced interrupt reporting in IOAPIC
KVM guest: fix bogus wallclock physical address calculation
KVM: VMX: Fix cr8 exiting control clobbering by EPT
KVM: Optimize kvm_mmu_unprotect_page_virt() for tdp
KVM: Document KVM_CAP_IRQCHIP
KVM: Protect update_cr8_intercept() when running without an apic
KVM: VMX: Fix EPT with WP bit change during paging
KVM: Use kvm_{read,write}_guest_virt() to read and write segment descriptors
KVM: x86 emulator: Add adc and sbb missing decoder flags
KVM: Add missing #include
...
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/Kbuild.asm | 5 | ||||
-rw-r--r-- | include/linux/Kbuild | 4 | ||||
-rw-r--r-- | include/linux/kvm.h | 127 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 114 | ||||
-rw-r--r-- | include/linux/kvm_para.h | 1 | ||||
-rw-r--r-- | include/trace/events/kvm.h | 151 |
6 files changed, 323 insertions, 79 deletions
diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm index 290910e4ede4..96d7c9804dc1 100644 --- a/include/asm-generic/Kbuild.asm +++ b/include/asm-generic/Kbuild.asm | |||
@@ -3,6 +3,11 @@ ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \ | |||
3 | header-y += kvm.h | 3 | header-y += kvm.h |
4 | endif | 4 | endif |
5 | 5 | ||
6 | ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \ | ||
7 | $(srctree)/include/asm-$(SRCARCH)/kvm_para.h),) | ||
8 | header-y += kvm_para.h | ||
9 | endif | ||
10 | |||
6 | ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \ | 11 | ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \ |
7 | $(srctree)/include/asm-$(SRCARCH)/a.out.h),) | 12 | $(srctree)/include/asm-$(SRCARCH)/a.out.h),) |
8 | unifdef-y += a.out.h | 13 | unifdef-y += a.out.h |
diff --git a/include/linux/Kbuild b/include/linux/Kbuild index 334a3593cdfd..cff4a101f266 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild | |||
@@ -268,6 +268,10 @@ ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \ | |||
268 | $(srctree)/include/asm-$(SRCARCH)/kvm.h),) | 268 | $(srctree)/include/asm-$(SRCARCH)/kvm.h),) |
269 | unifdef-y += kvm.h | 269 | unifdef-y += kvm.h |
270 | endif | 270 | endif |
271 | ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \ | ||
272 | $(srctree)/include/asm-$(SRCARCH)/kvm_para.h),) | ||
273 | unifdef-y += kvm_para.h | ||
274 | endif | ||
271 | unifdef-y += llc.h | 275 | unifdef-y += llc.h |
272 | unifdef-y += loop.h | 276 | unifdef-y += loop.h |
273 | unifdef-y += lp.h | 277 | unifdef-y += lp.h |
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 3db5d8d37485..f8f8900fc5ec 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | #define KVM_API_VERSION 12 | 15 | #define KVM_API_VERSION 12 |
16 | 16 | ||
17 | /* for KVM_TRACE_ENABLE */ | 17 | /* for KVM_TRACE_ENABLE, deprecated */ |
18 | struct kvm_user_trace_setup { | 18 | struct kvm_user_trace_setup { |
19 | __u32 buf_size; /* sub_buffer size of each per-cpu */ | 19 | __u32 buf_size; /* sub_buffer size of each per-cpu */ |
20 | __u32 buf_nr; /* the number of sub_buffers of each per-cpu */ | 20 | __u32 buf_nr; /* the number of sub_buffers of each per-cpu */ |
@@ -70,6 +70,14 @@ struct kvm_irqchip { | |||
70 | } chip; | 70 | } chip; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | /* for KVM_CREATE_PIT2 */ | ||
74 | struct kvm_pit_config { | ||
75 | __u32 flags; | ||
76 | __u32 pad[15]; | ||
77 | }; | ||
78 | |||
79 | #define KVM_PIT_SPEAKER_DUMMY 1 | ||
80 | |||
73 | #define KVM_EXIT_UNKNOWN 0 | 81 | #define KVM_EXIT_UNKNOWN 0 |
74 | #define KVM_EXIT_EXCEPTION 1 | 82 | #define KVM_EXIT_EXCEPTION 1 |
75 | #define KVM_EXIT_IO 2 | 83 | #define KVM_EXIT_IO 2 |
@@ -87,6 +95,10 @@ struct kvm_irqchip { | |||
87 | #define KVM_EXIT_S390_RESET 14 | 95 | #define KVM_EXIT_S390_RESET 14 |
88 | #define KVM_EXIT_DCR 15 | 96 | #define KVM_EXIT_DCR 15 |
89 | #define KVM_EXIT_NMI 16 | 97 | #define KVM_EXIT_NMI 16 |
98 | #define KVM_EXIT_INTERNAL_ERROR 17 | ||
99 | |||
100 | /* For KVM_EXIT_INTERNAL_ERROR */ | ||
101 | #define KVM_INTERNAL_ERROR_EMULATION 1 | ||
90 | 102 | ||
91 | /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ | 103 | /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ |
92 | struct kvm_run { | 104 | struct kvm_run { |
@@ -173,6 +185,9 @@ struct kvm_run { | |||
173 | __u32 data; | 185 | __u32 data; |
174 | __u8 is_write; | 186 | __u8 is_write; |
175 | } dcr; | 187 | } dcr; |
188 | struct { | ||
189 | __u32 suberror; | ||
190 | } internal; | ||
176 | /* Fix the size of the union. */ | 191 | /* Fix the size of the union. */ |
177 | char padding[256]; | 192 | char padding[256]; |
178 | }; | 193 | }; |
@@ -292,6 +307,28 @@ struct kvm_guest_debug { | |||
292 | struct kvm_guest_debug_arch arch; | 307 | struct kvm_guest_debug_arch arch; |
293 | }; | 308 | }; |
294 | 309 | ||
310 | enum { | ||
311 | kvm_ioeventfd_flag_nr_datamatch, | ||
312 | kvm_ioeventfd_flag_nr_pio, | ||
313 | kvm_ioeventfd_flag_nr_deassign, | ||
314 | kvm_ioeventfd_flag_nr_max, | ||
315 | }; | ||
316 | |||
317 | #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) | ||
318 | #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) | ||
319 | #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) | ||
320 | |||
321 | #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1) | ||
322 | |||
323 | struct kvm_ioeventfd { | ||
324 | __u64 datamatch; | ||
325 | __u64 addr; /* legal pio/mmio address */ | ||
326 | __u32 len; /* 1, 2, 4, or 8 bytes */ | ||
327 | __s32 fd; | ||
328 | __u32 flags; | ||
329 | __u8 pad[36]; | ||
330 | }; | ||
331 | |||
295 | #define KVM_TRC_SHIFT 16 | 332 | #define KVM_TRC_SHIFT 16 |
296 | /* | 333 | /* |
297 | * kvm trace categories | 334 | * kvm trace categories |
@@ -310,35 +347,6 @@ struct kvm_guest_debug { | |||
310 | #define KVM_TRC_CYCLE_SIZE 8 | 347 | #define KVM_TRC_CYCLE_SIZE 8 |
311 | #define KVM_TRC_EXTRA_MAX 7 | 348 | #define KVM_TRC_EXTRA_MAX 7 |
312 | 349 | ||
313 | /* This structure represents a single trace buffer record. */ | ||
314 | struct kvm_trace_rec { | ||
315 | /* variable rec_val | ||
316 | * is split into: | ||
317 | * bits 0 - 27 -> event id | ||
318 | * bits 28 -30 -> number of extra data args of size u32 | ||
319 | * bits 31 -> binary indicator for if tsc is in record | ||
320 | */ | ||
321 | __u32 rec_val; | ||
322 | __u32 pid; | ||
323 | __u32 vcpu_id; | ||
324 | union { | ||
325 | struct { | ||
326 | __u64 timestamp; | ||
327 | __u32 extra_u32[KVM_TRC_EXTRA_MAX]; | ||
328 | } __attribute__((packed)) timestamp; | ||
329 | struct { | ||
330 | __u32 extra_u32[KVM_TRC_EXTRA_MAX]; | ||
331 | } notimestamp; | ||
332 | } u; | ||
333 | }; | ||
334 | |||
335 | #define TRACE_REC_EVENT_ID(val) \ | ||
336 | (0x0fffffff & (val)) | ||
337 | #define TRACE_REC_NUM_DATA_ARGS(val) \ | ||
338 | (0x70000000 & ((val) << 28)) | ||
339 | #define TRACE_REC_TCS(val) \ | ||
340 | (0x80000000 & ((val) << 31)) | ||
341 | |||
342 | #define KVMIO 0xAE | 350 | #define KVMIO 0xAE |
343 | 351 | ||
344 | /* | 352 | /* |
@@ -415,6 +423,19 @@ struct kvm_trace_rec { | |||
415 | #define KVM_CAP_ASSIGN_DEV_IRQ 29 | 423 | #define KVM_CAP_ASSIGN_DEV_IRQ 29 |
416 | /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ | 424 | /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ |
417 | #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 | 425 | #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 |
426 | #ifdef __KVM_HAVE_MCE | ||
427 | #define KVM_CAP_MCE 31 | ||
428 | #endif | ||
429 | #define KVM_CAP_IRQFD 32 | ||
430 | #ifdef __KVM_HAVE_PIT | ||
431 | #define KVM_CAP_PIT2 33 | ||
432 | #endif | ||
433 | #define KVM_CAP_SET_BOOT_CPU_ID 34 | ||
434 | #ifdef __KVM_HAVE_PIT_STATE2 | ||
435 | #define KVM_CAP_PIT_STATE2 35 | ||
436 | #endif | ||
437 | #define KVM_CAP_IOEVENTFD 36 | ||
438 | #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 | ||
418 | 439 | ||
419 | #ifdef KVM_CAP_IRQ_ROUTING | 440 | #ifdef KVM_CAP_IRQ_ROUTING |
420 | 441 | ||
@@ -454,15 +475,32 @@ struct kvm_irq_routing { | |||
454 | 475 | ||
455 | #endif | 476 | #endif |
456 | 477 | ||
478 | #ifdef KVM_CAP_MCE | ||
479 | /* x86 MCE */ | ||
480 | struct kvm_x86_mce { | ||
481 | __u64 status; | ||
482 | __u64 addr; | ||
483 | __u64 misc; | ||
484 | __u64 mcg_status; | ||
485 | __u8 bank; | ||
486 | __u8 pad1[7]; | ||
487 | __u64 pad2[3]; | ||
488 | }; | ||
489 | #endif | ||
490 | |||
491 | #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) | ||
492 | |||
493 | struct kvm_irqfd { | ||
494 | __u32 fd; | ||
495 | __u32 gsi; | ||
496 | __u32 flags; | ||
497 | __u8 pad[20]; | ||
498 | }; | ||
499 | |||
457 | /* | 500 | /* |
458 | * ioctls for VM fds | 501 | * ioctls for VM fds |
459 | */ | 502 | */ |
460 | #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) | 503 | #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) |
461 | #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) | ||
462 | #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) | ||
463 | #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46,\ | ||
464 | struct kvm_userspace_memory_region) | ||
465 | #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) | ||
466 | /* | 504 | /* |
467 | * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns | 505 | * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns |
468 | * a vcpu fd. | 506 | * a vcpu fd. |
@@ -470,6 +508,12 @@ struct kvm_irq_routing { | |||
470 | #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) | 508 | #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) |
471 | #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) | 509 | #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) |
472 | #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) | 510 | #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) |
511 | #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) | ||
512 | #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) | ||
513 | #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46,\ | ||
514 | struct kvm_userspace_memory_region) | ||
515 | #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) | ||
516 | #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) | ||
473 | /* Device model IOC */ | 517 | /* Device model IOC */ |
474 | #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) | 518 | #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) |
475 | #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) | 519 | #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) |
@@ -498,6 +542,10 @@ struct kvm_irq_routing { | |||
498 | #define KVM_ASSIGN_SET_MSIX_ENTRY \ | 542 | #define KVM_ASSIGN_SET_MSIX_ENTRY \ |
499 | _IOW(KVMIO, 0x74, struct kvm_assigned_msix_entry) | 543 | _IOW(KVMIO, 0x74, struct kvm_assigned_msix_entry) |
500 | #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) | 544 | #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) |
545 | #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd) | ||
546 | #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) | ||
547 | #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) | ||
548 | #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd) | ||
501 | 549 | ||
502 | /* | 550 | /* |
503 | * ioctls for vcpu fds | 551 | * ioctls for vcpu fds |
@@ -541,6 +589,10 @@ struct kvm_irq_routing { | |||
541 | #define KVM_NMI _IO(KVMIO, 0x9a) | 589 | #define KVM_NMI _IO(KVMIO, 0x9a) |
542 | /* Available with KVM_CAP_SET_GUEST_DEBUG */ | 590 | /* Available with KVM_CAP_SET_GUEST_DEBUG */ |
543 | #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) | 591 | #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) |
592 | /* MCE for x86 */ | ||
593 | #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) | ||
594 | #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) | ||
595 | #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) | ||
544 | 596 | ||
545 | /* | 597 | /* |
546 | * Deprecated interfaces | 598 | * Deprecated interfaces |
@@ -563,6 +615,9 @@ struct kvm_debug_guest { | |||
563 | #define KVM_IA64_VCPU_GET_STACK _IOR(KVMIO, 0x9a, void *) | 615 | #define KVM_IA64_VCPU_GET_STACK _IOR(KVMIO, 0x9a, void *) |
564 | #define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *) | 616 | #define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *) |
565 | 617 | ||
618 | #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) | ||
619 | #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) | ||
620 | |||
566 | #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) | 621 | #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) |
567 | #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) | 622 | #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) |
568 | #define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04) | 623 | #define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04) |
@@ -633,7 +688,7 @@ struct kvm_assigned_msix_nr { | |||
633 | __u16 padding; | 688 | __u16 padding; |
634 | }; | 689 | }; |
635 | 690 | ||
636 | #define KVM_MAX_MSIX_PER_DEV 512 | 691 | #define KVM_MAX_MSIX_PER_DEV 256 |
637 | struct kvm_assigned_msix_entry { | 692 | struct kvm_assigned_msix_entry { |
638 | __u32 assigned_dev_id; | 693 | __u32 assigned_dev_id; |
639 | __u32 gsi; | 694 | __u32 gsi; |
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 3060bdc35ffe..4af56036a6bf 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -42,6 +42,7 @@ | |||
42 | 42 | ||
43 | #define KVM_USERSPACE_IRQ_SOURCE_ID 0 | 43 | #define KVM_USERSPACE_IRQ_SOURCE_ID 0 |
44 | 44 | ||
45 | struct kvm; | ||
45 | struct kvm_vcpu; | 46 | struct kvm_vcpu; |
46 | extern struct kmem_cache *kvm_vcpu_cache; | 47 | extern struct kmem_cache *kvm_vcpu_cache; |
47 | 48 | ||
@@ -59,10 +60,18 @@ struct kvm_io_bus { | |||
59 | 60 | ||
60 | void kvm_io_bus_init(struct kvm_io_bus *bus); | 61 | void kvm_io_bus_init(struct kvm_io_bus *bus); |
61 | void kvm_io_bus_destroy(struct kvm_io_bus *bus); | 62 | void kvm_io_bus_destroy(struct kvm_io_bus *bus); |
62 | struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus, | 63 | int kvm_io_bus_write(struct kvm_io_bus *bus, gpa_t addr, int len, |
63 | gpa_t addr, int len, int is_write); | 64 | const void *val); |
64 | void kvm_io_bus_register_dev(struct kvm_io_bus *bus, | 65 | int kvm_io_bus_read(struct kvm_io_bus *bus, gpa_t addr, int len, |
65 | struct kvm_io_device *dev); | 66 | void *val); |
67 | int __kvm_io_bus_register_dev(struct kvm_io_bus *bus, | ||
68 | struct kvm_io_device *dev); | ||
69 | int kvm_io_bus_register_dev(struct kvm *kvm, struct kvm_io_bus *bus, | ||
70 | struct kvm_io_device *dev); | ||
71 | void __kvm_io_bus_unregister_dev(struct kvm_io_bus *bus, | ||
72 | struct kvm_io_device *dev); | ||
73 | void kvm_io_bus_unregister_dev(struct kvm *kvm, struct kvm_io_bus *bus, | ||
74 | struct kvm_io_device *dev); | ||
66 | 75 | ||
67 | struct kvm_vcpu { | 76 | struct kvm_vcpu { |
68 | struct kvm *kvm; | 77 | struct kvm *kvm; |
@@ -103,7 +112,7 @@ struct kvm_memory_slot { | |||
103 | struct { | 112 | struct { |
104 | unsigned long rmap_pde; | 113 | unsigned long rmap_pde; |
105 | int write_count; | 114 | int write_count; |
106 | } *lpage_info; | 115 | } *lpage_info[KVM_NR_PAGE_SIZES - 1]; |
107 | unsigned long userspace_addr; | 116 | unsigned long userspace_addr; |
108 | int user_alloc; | 117 | int user_alloc; |
109 | }; | 118 | }; |
@@ -124,7 +133,6 @@ struct kvm_kernel_irq_routing_entry { | |||
124 | }; | 133 | }; |
125 | 134 | ||
126 | struct kvm { | 135 | struct kvm { |
127 | struct mutex lock; /* protects the vcpus array and APIC accesses */ | ||
128 | spinlock_t mmu_lock; | 136 | spinlock_t mmu_lock; |
129 | spinlock_t requests_lock; | 137 | spinlock_t requests_lock; |
130 | struct rw_semaphore slots_lock; | 138 | struct rw_semaphore slots_lock; |
@@ -132,10 +140,23 @@ struct kvm { | |||
132 | int nmemslots; | 140 | int nmemslots; |
133 | struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS + | 141 | struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS + |
134 | KVM_PRIVATE_MEM_SLOTS]; | 142 | KVM_PRIVATE_MEM_SLOTS]; |
143 | #ifdef CONFIG_KVM_APIC_ARCHITECTURE | ||
144 | u32 bsp_vcpu_id; | ||
145 | struct kvm_vcpu *bsp_vcpu; | ||
146 | #endif | ||
135 | struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; | 147 | struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; |
148 | atomic_t online_vcpus; | ||
136 | struct list_head vm_list; | 149 | struct list_head vm_list; |
150 | struct mutex lock; | ||
137 | struct kvm_io_bus mmio_bus; | 151 | struct kvm_io_bus mmio_bus; |
138 | struct kvm_io_bus pio_bus; | 152 | struct kvm_io_bus pio_bus; |
153 | #ifdef CONFIG_HAVE_KVM_EVENTFD | ||
154 | struct { | ||
155 | spinlock_t lock; | ||
156 | struct list_head items; | ||
157 | } irqfds; | ||
158 | struct list_head ioeventfds; | ||
159 | #endif | ||
139 | struct kvm_vm_stat stat; | 160 | struct kvm_vm_stat stat; |
140 | struct kvm_arch arch; | 161 | struct kvm_arch arch; |
141 | atomic_t users_count; | 162 | atomic_t users_count; |
@@ -144,6 +165,7 @@ struct kvm { | |||
144 | struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; | 165 | struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; |
145 | #endif | 166 | #endif |
146 | 167 | ||
168 | struct mutex irq_lock; | ||
147 | #ifdef CONFIG_HAVE_KVM_IRQCHIP | 169 | #ifdef CONFIG_HAVE_KVM_IRQCHIP |
148 | struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */ | 170 | struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */ |
149 | struct hlist_head mask_notifier_list; | 171 | struct hlist_head mask_notifier_list; |
@@ -167,6 +189,17 @@ struct kvm { | |||
167 | #define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt) | 189 | #define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt) |
168 | #define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt) | 190 | #define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt) |
169 | 191 | ||
192 | static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i) | ||
193 | { | ||
194 | smp_rmb(); | ||
195 | return kvm->vcpus[i]; | ||
196 | } | ||
197 | |||
198 | #define kvm_for_each_vcpu(idx, vcpup, kvm) \ | ||
199 | for (idx = 0, vcpup = kvm_get_vcpu(kvm, idx); \ | ||
200 | idx < atomic_read(&kvm->online_vcpus) && vcpup; \ | ||
201 | vcpup = kvm_get_vcpu(kvm, ++idx)) | ||
202 | |||
170 | int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id); | 203 | int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id); |
171 | void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); | 204 | void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); |
172 | 205 | ||
@@ -201,6 +234,7 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
201 | struct kvm_userspace_memory_region *mem, | 234 | struct kvm_userspace_memory_region *mem, |
202 | struct kvm_memory_slot old, | 235 | struct kvm_memory_slot old, |
203 | int user_alloc); | 236 | int user_alloc); |
237 | void kvm_disable_largepages(void); | ||
204 | void kvm_arch_flush_shadow(struct kvm *kvm); | 238 | void kvm_arch_flush_shadow(struct kvm *kvm); |
205 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); | 239 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); |
206 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); | 240 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); |
@@ -243,8 +277,6 @@ long kvm_arch_dev_ioctl(struct file *filp, | |||
243 | unsigned int ioctl, unsigned long arg); | 277 | unsigned int ioctl, unsigned long arg); |
244 | long kvm_arch_vcpu_ioctl(struct file *filp, | 278 | long kvm_arch_vcpu_ioctl(struct file *filp, |
245 | unsigned int ioctl, unsigned long arg); | 279 | unsigned int ioctl, unsigned long arg); |
246 | void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu); | ||
247 | void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu); | ||
248 | 280 | ||
249 | int kvm_dev_ioctl_check_extension(long ext); | 281 | int kvm_dev_ioctl_check_extension(long ext); |
250 | 282 | ||
@@ -300,7 +332,6 @@ int kvm_arch_hardware_setup(void); | |||
300 | void kvm_arch_hardware_unsetup(void); | 332 | void kvm_arch_hardware_unsetup(void); |
301 | void kvm_arch_check_processor_compat(void *rtn); | 333 | void kvm_arch_check_processor_compat(void *rtn); |
302 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu); | 334 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu); |
303 | int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu); | ||
304 | 335 | ||
305 | void kvm_free_physmem(struct kvm *kvm); | 336 | void kvm_free_physmem(struct kvm *kvm); |
306 | 337 | ||
@@ -309,8 +340,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm); | |||
309 | void kvm_free_all_assigned_devices(struct kvm *kvm); | 340 | void kvm_free_all_assigned_devices(struct kvm *kvm); |
310 | void kvm_arch_sync_events(struct kvm *kvm); | 341 | void kvm_arch_sync_events(struct kvm *kvm); |
311 | 342 | ||
312 | int kvm_cpu_get_interrupt(struct kvm_vcpu *v); | ||
313 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v); | ||
314 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); | 343 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); |
315 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); | 344 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); |
316 | 345 | ||
@@ -366,7 +395,8 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level); | |||
366 | void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin); | 395 | void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin); |
367 | void kvm_register_irq_ack_notifier(struct kvm *kvm, | 396 | void kvm_register_irq_ack_notifier(struct kvm *kvm, |
368 | struct kvm_irq_ack_notifier *kian); | 397 | struct kvm_irq_ack_notifier *kian); |
369 | void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian); | 398 | void kvm_unregister_irq_ack_notifier(struct kvm *kvm, |
399 | struct kvm_irq_ack_notifier *kian); | ||
370 | int kvm_request_irq_source_id(struct kvm *kvm); | 400 | int kvm_request_irq_source_id(struct kvm *kvm); |
371 | void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); | 401 | void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); |
372 | 402 | ||
@@ -459,37 +489,6 @@ struct kvm_stats_debugfs_item { | |||
459 | extern struct kvm_stats_debugfs_item debugfs_entries[]; | 489 | extern struct kvm_stats_debugfs_item debugfs_entries[]; |
460 | extern struct dentry *kvm_debugfs_dir; | 490 | extern struct dentry *kvm_debugfs_dir; |
461 | 491 | ||
462 | #define KVMTRACE_5D(evt, vcpu, d1, d2, d3, d4, d5, name) \ | ||
463 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
464 | vcpu, 5, d1, d2, d3, d4, d5) | ||
465 | #define KVMTRACE_4D(evt, vcpu, d1, d2, d3, d4, name) \ | ||
466 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
467 | vcpu, 4, d1, d2, d3, d4, 0) | ||
468 | #define KVMTRACE_3D(evt, vcpu, d1, d2, d3, name) \ | ||
469 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
470 | vcpu, 3, d1, d2, d3, 0, 0) | ||
471 | #define KVMTRACE_2D(evt, vcpu, d1, d2, name) \ | ||
472 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
473 | vcpu, 2, d1, d2, 0, 0, 0) | ||
474 | #define KVMTRACE_1D(evt, vcpu, d1, name) \ | ||
475 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
476 | vcpu, 1, d1, 0, 0, 0, 0) | ||
477 | #define KVMTRACE_0D(evt, vcpu, name) \ | ||
478 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
479 | vcpu, 0, 0, 0, 0, 0, 0) | ||
480 | |||
481 | #ifdef CONFIG_KVM_TRACE | ||
482 | int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg); | ||
483 | void kvm_trace_cleanup(void); | ||
484 | #else | ||
485 | static inline | ||
486 | int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg) | ||
487 | { | ||
488 | return -EINVAL; | ||
489 | } | ||
490 | #define kvm_trace_cleanup() ((void)0) | ||
491 | #endif | ||
492 | |||
493 | #ifdef KVM_ARCH_WANT_MMU_NOTIFIER | 492 | #ifdef KVM_ARCH_WANT_MMU_NOTIFIER |
494 | static inline int mmu_notifier_retry(struct kvm_vcpu *vcpu, unsigned long mmu_seq) | 493 | static inline int mmu_notifier_retry(struct kvm_vcpu *vcpu, unsigned long mmu_seq) |
495 | { | 494 | { |
@@ -525,4 +524,33 @@ static inline void kvm_free_irq_routing(struct kvm *kvm) {} | |||
525 | 524 | ||
526 | #endif | 525 | #endif |
527 | 526 | ||
527 | #ifdef CONFIG_HAVE_KVM_EVENTFD | ||
528 | |||
529 | void kvm_eventfd_init(struct kvm *kvm); | ||
530 | int kvm_irqfd(struct kvm *kvm, int fd, int gsi, int flags); | ||
531 | void kvm_irqfd_release(struct kvm *kvm); | ||
532 | int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args); | ||
533 | |||
534 | #else | ||
535 | |||
536 | static inline void kvm_eventfd_init(struct kvm *kvm) {} | ||
537 | static inline int kvm_irqfd(struct kvm *kvm, int fd, int gsi, int flags) | ||
538 | { | ||
539 | return -EINVAL; | ||
540 | } | ||
541 | |||
542 | static inline void kvm_irqfd_release(struct kvm *kvm) {} | ||
543 | static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) | ||
544 | { | ||
545 | return -ENOSYS; | ||
546 | } | ||
547 | |||
548 | #endif /* CONFIG_HAVE_KVM_EVENTFD */ | ||
549 | |||
550 | #ifdef CONFIG_KVM_APIC_ARCHITECTURE | ||
551 | static inline bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu) | ||
552 | { | ||
553 | return vcpu->kvm->bsp_vcpu_id == vcpu->vcpu_id; | ||
554 | } | ||
555 | #endif | ||
528 | #endif | 556 | #endif |
diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h index 3ddce03766ca..d73109243fda 100644 --- a/include/linux/kvm_para.h +++ b/include/linux/kvm_para.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #define KVM_ENOSYS 1000 | 13 | #define KVM_ENOSYS 1000 |
14 | #define KVM_EFAULT EFAULT | 14 | #define KVM_EFAULT EFAULT |
15 | #define KVM_E2BIG E2BIG | 15 | #define KVM_E2BIG E2BIG |
16 | #define KVM_EPERM EPERM | ||
16 | 17 | ||
17 | #define KVM_HC_VAPIC_POLL_IRQ 1 | 18 | #define KVM_HC_VAPIC_POLL_IRQ 1 |
18 | #define KVM_HC_MMU_OP 2 | 19 | #define KVM_HC_MMU_OP 2 |
diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h new file mode 100644 index 000000000000..dbe108455275 --- /dev/null +++ b/include/trace/events/kvm.h | |||
@@ -0,0 +1,151 @@ | |||
1 | #if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ) | ||
2 | #define _TRACE_KVM_MAIN_H | ||
3 | |||
4 | #include <linux/tracepoint.h> | ||
5 | |||
6 | #undef TRACE_SYSTEM | ||
7 | #define TRACE_SYSTEM kvm | ||
8 | #define TRACE_INCLUDE_FILE kvm | ||
9 | |||
10 | #if defined(__KVM_HAVE_IOAPIC) | ||
11 | TRACE_EVENT(kvm_set_irq, | ||
12 | TP_PROTO(unsigned int gsi, int level, int irq_source_id), | ||
13 | TP_ARGS(gsi, level, irq_source_id), | ||
14 | |||
15 | TP_STRUCT__entry( | ||
16 | __field( unsigned int, gsi ) | ||
17 | __field( int, level ) | ||
18 | __field( int, irq_source_id ) | ||
19 | ), | ||
20 | |||
21 | TP_fast_assign( | ||
22 | __entry->gsi = gsi; | ||
23 | __entry->level = level; | ||
24 | __entry->irq_source_id = irq_source_id; | ||
25 | ), | ||
26 | |||
27 | TP_printk("gsi %u level %d source %d", | ||
28 | __entry->gsi, __entry->level, __entry->irq_source_id) | ||
29 | ); | ||
30 | |||
31 | #define kvm_deliver_mode \ | ||
32 | {0x0, "Fixed"}, \ | ||
33 | {0x1, "LowPrio"}, \ | ||
34 | {0x2, "SMI"}, \ | ||
35 | {0x3, "Res3"}, \ | ||
36 | {0x4, "NMI"}, \ | ||
37 | {0x5, "INIT"}, \ | ||
38 | {0x6, "SIPI"}, \ | ||
39 | {0x7, "ExtINT"} | ||
40 | |||
41 | TRACE_EVENT(kvm_ioapic_set_irq, | ||
42 | TP_PROTO(__u64 e, int pin, bool coalesced), | ||
43 | TP_ARGS(e, pin, coalesced), | ||
44 | |||
45 | TP_STRUCT__entry( | ||
46 | __field( __u64, e ) | ||
47 | __field( int, pin ) | ||
48 | __field( bool, coalesced ) | ||
49 | ), | ||
50 | |||
51 | TP_fast_assign( | ||
52 | __entry->e = e; | ||
53 | __entry->pin = pin; | ||
54 | __entry->coalesced = coalesced; | ||
55 | ), | ||
56 | |||
57 | TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s", | ||
58 | __entry->pin, (u8)(__entry->e >> 56), (u8)__entry->e, | ||
59 | __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode), | ||
60 | (__entry->e & (1<<11)) ? "logical" : "physical", | ||
61 | (__entry->e & (1<<15)) ? "level" : "edge", | ||
62 | (__entry->e & (1<<16)) ? "|masked" : "", | ||
63 | __entry->coalesced ? " (coalesced)" : "") | ||
64 | ); | ||
65 | |||
66 | TRACE_EVENT(kvm_msi_set_irq, | ||
67 | TP_PROTO(__u64 address, __u64 data), | ||
68 | TP_ARGS(address, data), | ||
69 | |||
70 | TP_STRUCT__entry( | ||
71 | __field( __u64, address ) | ||
72 | __field( __u64, data ) | ||
73 | ), | ||
74 | |||
75 | TP_fast_assign( | ||
76 | __entry->address = address; | ||
77 | __entry->data = data; | ||
78 | ), | ||
79 | |||
80 | TP_printk("dst %u vec %x (%s|%s|%s%s)", | ||
81 | (u8)(__entry->address >> 12), (u8)__entry->data, | ||
82 | __print_symbolic((__entry->data >> 8 & 0x7), kvm_deliver_mode), | ||
83 | (__entry->address & (1<<2)) ? "logical" : "physical", | ||
84 | (__entry->data & (1<<15)) ? "level" : "edge", | ||
85 | (__entry->address & (1<<3)) ? "|rh" : "") | ||
86 | ); | ||
87 | |||
88 | #define kvm_irqchips \ | ||
89 | {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \ | ||
90 | {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \ | ||
91 | {KVM_IRQCHIP_IOAPIC, "IOAPIC"} | ||
92 | |||
93 | TRACE_EVENT(kvm_ack_irq, | ||
94 | TP_PROTO(unsigned int irqchip, unsigned int pin), | ||
95 | TP_ARGS(irqchip, pin), | ||
96 | |||
97 | TP_STRUCT__entry( | ||
98 | __field( unsigned int, irqchip ) | ||
99 | __field( unsigned int, pin ) | ||
100 | ), | ||
101 | |||
102 | TP_fast_assign( | ||
103 | __entry->irqchip = irqchip; | ||
104 | __entry->pin = pin; | ||
105 | ), | ||
106 | |||
107 | TP_printk("irqchip %s pin %u", | ||
108 | __print_symbolic(__entry->irqchip, kvm_irqchips), | ||
109 | __entry->pin) | ||
110 | ); | ||
111 | |||
112 | |||
113 | |||
114 | #endif /* defined(__KVM_HAVE_IOAPIC) */ | ||
115 | |||
116 | #define KVM_TRACE_MMIO_READ_UNSATISFIED 0 | ||
117 | #define KVM_TRACE_MMIO_READ 1 | ||
118 | #define KVM_TRACE_MMIO_WRITE 2 | ||
119 | |||
120 | #define kvm_trace_symbol_mmio \ | ||
121 | { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \ | ||
122 | { KVM_TRACE_MMIO_READ, "read" }, \ | ||
123 | { KVM_TRACE_MMIO_WRITE, "write" } | ||
124 | |||
125 | TRACE_EVENT(kvm_mmio, | ||
126 | TP_PROTO(int type, int len, u64 gpa, u64 val), | ||
127 | TP_ARGS(type, len, gpa, val), | ||
128 | |||
129 | TP_STRUCT__entry( | ||
130 | __field( u32, type ) | ||
131 | __field( u32, len ) | ||
132 | __field( u64, gpa ) | ||
133 | __field( u64, val ) | ||
134 | ), | ||
135 | |||
136 | TP_fast_assign( | ||
137 | __entry->type = type; | ||
138 | __entry->len = len; | ||
139 | __entry->gpa = gpa; | ||
140 | __entry->val = val; | ||
141 | ), | ||
142 | |||
143 | TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx", | ||
144 | __print_symbolic(__entry->type, kvm_trace_symbol_mmio), | ||
145 | __entry->len, __entry->gpa, __entry->val) | ||
146 | ); | ||
147 | |||
148 | #endif /* _TRACE_KVM_MAIN_H */ | ||
149 | |||
150 | /* This part must be outside protection */ | ||
151 | #include <trace/define_trace.h> | ||