diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-05 16:12:34 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-05 16:12:34 -0500 |
commit | c812a51d11bbe983f4c24e32b59b265705ddd3c2 (patch) | |
tree | d454f518db51a4de700cf3dcd4c3c71ee7288b47 /include | |
parent | 9467c4fdd66f6810cecef0f1173330f3c6e67d45 (diff) | |
parent | d2be1651b736002e0c76d7095d6c0ba77b4a897c (diff) |
Merge branch 'kvm-updates/2.6.34' of git://git.kernel.org/pub/scm/virt/kvm/kvm
* 'kvm-updates/2.6.34' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (145 commits)
KVM: x86: Add KVM_CAP_X86_ROBUST_SINGLESTEP
KVM: VMX: Update instruction length on intercepted BP
KVM: Fix emulate_sys[call, enter, exit]()'s fault handling
KVM: Fix segment descriptor loading
KVM: Fix load_guest_segment_descriptor() to inject page fault
KVM: x86 emulator: Forbid modifying CS segment register by mov instruction
KVM: Convert kvm->requests_lock to raw_spinlock_t
KVM: Convert i8254/i8259 locks to raw_spinlocks
KVM: x86 emulator: disallow opcode 82 in 64-bit mode
KVM: x86 emulator: code style cleanup
KVM: Plan obsolescence of kernel allocated slots, paravirt mmu
KVM: x86 emulator: Add LOCK prefix validity checking
KVM: x86 emulator: Check CPL level during privilege instruction emulation
KVM: x86 emulator: Fix popf emulation
KVM: x86 emulator: Check IOPL level during io instruction emulation
KVM: x86 emulator: fix memory access during x86 emulation
KVM: x86 emulator: Add Virtual-8086 mode of emulation
KVM: x86 emulator: Add group9 instruction decoding
KVM: x86 emulator: Add group8 instruction decoding
KVM: do not store wqh in irqfd
...
Trivial conflicts in Documentation/feature-removal-schedule.txt
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/kvm.h | 10 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 71 | ||||
-rw-r--r-- | include/trace/events/kvm.h | 41 |
3 files changed, 93 insertions, 29 deletions
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index a24de0b1858e..60df9c84ecae 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
@@ -103,7 +103,7 @@ struct kvm_userspace_memory_region { | |||
103 | 103 | ||
104 | /* for kvm_memory_region::flags */ | 104 | /* for kvm_memory_region::flags */ |
105 | #define KVM_MEM_LOG_DIRTY_PAGES 1UL | 105 | #define KVM_MEM_LOG_DIRTY_PAGES 1UL |
106 | 106 | #define KVM_MEMSLOT_INVALID (1UL << 1) | |
107 | 107 | ||
108 | /* for KVM_IRQ_LINE */ | 108 | /* for KVM_IRQ_LINE */ |
109 | struct kvm_irq_level { | 109 | struct kvm_irq_level { |
@@ -497,6 +497,11 @@ struct kvm_ioeventfd { | |||
497 | #endif | 497 | #endif |
498 | #define KVM_CAP_S390_PSW 42 | 498 | #define KVM_CAP_S390_PSW 42 |
499 | #define KVM_CAP_PPC_SEGSTATE 43 | 499 | #define KVM_CAP_PPC_SEGSTATE 43 |
500 | #define KVM_CAP_HYPERV 44 | ||
501 | #define KVM_CAP_HYPERV_VAPIC 45 | ||
502 | #define KVM_CAP_HYPERV_SPIN 46 | ||
503 | #define KVM_CAP_PCI_SEGMENT 47 | ||
504 | #define KVM_CAP_X86_ROBUST_SINGLESTEP 51 | ||
500 | 505 | ||
501 | #ifdef KVM_CAP_IRQ_ROUTING | 506 | #ifdef KVM_CAP_IRQ_ROUTING |
502 | 507 | ||
@@ -691,8 +696,9 @@ struct kvm_assigned_pci_dev { | |||
691 | __u32 busnr; | 696 | __u32 busnr; |
692 | __u32 devfn; | 697 | __u32 devfn; |
693 | __u32 flags; | 698 | __u32 flags; |
699 | __u32 segnr; | ||
694 | union { | 700 | union { |
695 | __u32 reserved[12]; | 701 | __u32 reserved[11]; |
696 | }; | 702 | }; |
697 | }; | 703 | }; |
698 | 704 | ||
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index bd5a616d9373..a3fd0f91d943 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -38,6 +38,7 @@ | |||
38 | #define KVM_REQ_MMU_SYNC 7 | 38 | #define KVM_REQ_MMU_SYNC 7 |
39 | #define KVM_REQ_KVMCLOCK_UPDATE 8 | 39 | #define KVM_REQ_KVMCLOCK_UPDATE 8 |
40 | #define KVM_REQ_KICK 9 | 40 | #define KVM_REQ_KICK 9 |
41 | #define KVM_REQ_DEACTIVATE_FPU 10 | ||
41 | 42 | ||
42 | #define KVM_USERSPACE_IRQ_SOURCE_ID 0 | 43 | #define KVM_USERSPACE_IRQ_SOURCE_ID 0 |
43 | 44 | ||
@@ -57,20 +58,20 @@ struct kvm_io_bus { | |||
57 | struct kvm_io_device *devs[NR_IOBUS_DEVS]; | 58 | struct kvm_io_device *devs[NR_IOBUS_DEVS]; |
58 | }; | 59 | }; |
59 | 60 | ||
60 | void kvm_io_bus_init(struct kvm_io_bus *bus); | 61 | enum kvm_bus { |
61 | void kvm_io_bus_destroy(struct kvm_io_bus *bus); | 62 | KVM_MMIO_BUS, |
62 | int kvm_io_bus_write(struct kvm_io_bus *bus, gpa_t addr, int len, | 63 | KVM_PIO_BUS, |
63 | const void *val); | 64 | KVM_NR_BUSES |
64 | int kvm_io_bus_read(struct kvm_io_bus *bus, gpa_t addr, int len, | 65 | }; |
66 | |||
67 | int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr, | ||
68 | int len, const void *val); | ||
69 | int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr, int len, | ||
65 | void *val); | 70 | void *val); |
66 | int __kvm_io_bus_register_dev(struct kvm_io_bus *bus, | 71 | int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, |
67 | struct kvm_io_device *dev); | ||
68 | int kvm_io_bus_register_dev(struct kvm *kvm, struct kvm_io_bus *bus, | ||
69 | struct kvm_io_device *dev); | 72 | struct kvm_io_device *dev); |
70 | void __kvm_io_bus_unregister_dev(struct kvm_io_bus *bus, | 73 | int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx, |
71 | struct kvm_io_device *dev); | 74 | struct kvm_io_device *dev); |
72 | void kvm_io_bus_unregister_dev(struct kvm *kvm, struct kvm_io_bus *bus, | ||
73 | struct kvm_io_device *dev); | ||
74 | 75 | ||
75 | struct kvm_vcpu { | 76 | struct kvm_vcpu { |
76 | struct kvm *kvm; | 77 | struct kvm *kvm; |
@@ -83,6 +84,8 @@ struct kvm_vcpu { | |||
83 | struct kvm_run *run; | 84 | struct kvm_run *run; |
84 | unsigned long requests; | 85 | unsigned long requests; |
85 | unsigned long guest_debug; | 86 | unsigned long guest_debug; |
87 | int srcu_idx; | ||
88 | |||
86 | int fpu_active; | 89 | int fpu_active; |
87 | int guest_fpu_loaded; | 90 | int guest_fpu_loaded; |
88 | wait_queue_head_t wq; | 91 | wait_queue_head_t wq; |
@@ -150,14 +153,19 @@ struct kvm_irq_routing_table {}; | |||
150 | 153 | ||
151 | #endif | 154 | #endif |
152 | 155 | ||
153 | struct kvm { | 156 | struct kvm_memslots { |
154 | spinlock_t mmu_lock; | ||
155 | spinlock_t requests_lock; | ||
156 | struct rw_semaphore slots_lock; | ||
157 | struct mm_struct *mm; /* userspace tied to this vm */ | ||
158 | int nmemslots; | 157 | int nmemslots; |
159 | struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS + | 158 | struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS + |
160 | KVM_PRIVATE_MEM_SLOTS]; | 159 | KVM_PRIVATE_MEM_SLOTS]; |
160 | }; | ||
161 | |||
162 | struct kvm { | ||
163 | spinlock_t mmu_lock; | ||
164 | raw_spinlock_t requests_lock; | ||
165 | struct mutex slots_lock; | ||
166 | struct mm_struct *mm; /* userspace tied to this vm */ | ||
167 | struct kvm_memslots *memslots; | ||
168 | struct srcu_struct srcu; | ||
161 | #ifdef CONFIG_KVM_APIC_ARCHITECTURE | 169 | #ifdef CONFIG_KVM_APIC_ARCHITECTURE |
162 | u32 bsp_vcpu_id; | 170 | u32 bsp_vcpu_id; |
163 | struct kvm_vcpu *bsp_vcpu; | 171 | struct kvm_vcpu *bsp_vcpu; |
@@ -166,8 +174,7 @@ struct kvm { | |||
166 | atomic_t online_vcpus; | 174 | atomic_t online_vcpus; |
167 | struct list_head vm_list; | 175 | struct list_head vm_list; |
168 | struct mutex lock; | 176 | struct mutex lock; |
169 | struct kvm_io_bus mmio_bus; | 177 | struct kvm_io_bus *buses[KVM_NR_BUSES]; |
170 | struct kvm_io_bus pio_bus; | ||
171 | #ifdef CONFIG_HAVE_KVM_EVENTFD | 178 | #ifdef CONFIG_HAVE_KVM_EVENTFD |
172 | struct { | 179 | struct { |
173 | spinlock_t lock; | 180 | spinlock_t lock; |
@@ -249,13 +256,20 @@ int kvm_set_memory_region(struct kvm *kvm, | |||
249 | int __kvm_set_memory_region(struct kvm *kvm, | 256 | int __kvm_set_memory_region(struct kvm *kvm, |
250 | struct kvm_userspace_memory_region *mem, | 257 | struct kvm_userspace_memory_region *mem, |
251 | int user_alloc); | 258 | int user_alloc); |
252 | int kvm_arch_set_memory_region(struct kvm *kvm, | 259 | int kvm_arch_prepare_memory_region(struct kvm *kvm, |
260 | struct kvm_memory_slot *memslot, | ||
261 | struct kvm_memory_slot old, | ||
262 | struct kvm_userspace_memory_region *mem, | ||
263 | int user_alloc); | ||
264 | void kvm_arch_commit_memory_region(struct kvm *kvm, | ||
253 | struct kvm_userspace_memory_region *mem, | 265 | struct kvm_userspace_memory_region *mem, |
254 | struct kvm_memory_slot old, | 266 | struct kvm_memory_slot old, |
255 | int user_alloc); | 267 | int user_alloc); |
256 | void kvm_disable_largepages(void); | 268 | void kvm_disable_largepages(void); |
257 | void kvm_arch_flush_shadow(struct kvm *kvm); | 269 | void kvm_arch_flush_shadow(struct kvm *kvm); |
258 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); | 270 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); |
271 | gfn_t unalias_gfn_instantiation(struct kvm *kvm, gfn_t gfn); | ||
272 | |||
259 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); | 273 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); |
260 | unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn); | 274 | unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn); |
261 | void kvm_release_page_clean(struct page *page); | 275 | void kvm_release_page_clean(struct page *page); |
@@ -264,6 +278,9 @@ void kvm_set_page_dirty(struct page *page); | |||
264 | void kvm_set_page_accessed(struct page *page); | 278 | void kvm_set_page_accessed(struct page *page); |
265 | 279 | ||
266 | pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn); | 280 | pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn); |
281 | pfn_t gfn_to_pfn_memslot(struct kvm *kvm, | ||
282 | struct kvm_memory_slot *slot, gfn_t gfn); | ||
283 | int memslot_id(struct kvm *kvm, gfn_t gfn); | ||
267 | void kvm_release_pfn_dirty(pfn_t); | 284 | void kvm_release_pfn_dirty(pfn_t); |
268 | void kvm_release_pfn_clean(pfn_t pfn); | 285 | void kvm_release_pfn_clean(pfn_t pfn); |
269 | void kvm_set_pfn_dirty(pfn_t pfn); | 286 | void kvm_set_pfn_dirty(pfn_t pfn); |
@@ -283,6 +300,7 @@ int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len); | |||
283 | int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len); | 300 | int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len); |
284 | struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn); | 301 | struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn); |
285 | int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn); | 302 | int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn); |
303 | unsigned long kvm_host_page_size(struct kvm *kvm, gfn_t gfn); | ||
286 | void mark_page_dirty(struct kvm *kvm, gfn_t gfn); | 304 | void mark_page_dirty(struct kvm *kvm, gfn_t gfn); |
287 | 305 | ||
288 | void kvm_vcpu_block(struct kvm_vcpu *vcpu); | 306 | void kvm_vcpu_block(struct kvm_vcpu *vcpu); |
@@ -383,6 +401,7 @@ struct kvm_assigned_dev_kernel { | |||
383 | struct work_struct interrupt_work; | 401 | struct work_struct interrupt_work; |
384 | struct list_head list; | 402 | struct list_head list; |
385 | int assigned_dev_id; | 403 | int assigned_dev_id; |
404 | int host_segnr; | ||
386 | int host_busnr; | 405 | int host_busnr; |
387 | int host_devfn; | 406 | int host_devfn; |
388 | unsigned int entries_nr; | 407 | unsigned int entries_nr; |
@@ -429,8 +448,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); | |||
429 | #define KVM_IOMMU_CACHE_COHERENCY 0x1 | 448 | #define KVM_IOMMU_CACHE_COHERENCY 0x1 |
430 | 449 | ||
431 | #ifdef CONFIG_IOMMU_API | 450 | #ifdef CONFIG_IOMMU_API |
432 | int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn, | 451 | int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot); |
433 | unsigned long npages); | ||
434 | int kvm_iommu_map_guest(struct kvm *kvm); | 452 | int kvm_iommu_map_guest(struct kvm *kvm); |
435 | int kvm_iommu_unmap_guest(struct kvm *kvm); | 453 | int kvm_iommu_unmap_guest(struct kvm *kvm); |
436 | int kvm_assign_device(struct kvm *kvm, | 454 | int kvm_assign_device(struct kvm *kvm, |
@@ -480,11 +498,6 @@ static inline void kvm_guest_exit(void) | |||
480 | current->flags &= ~PF_VCPU; | 498 | current->flags &= ~PF_VCPU; |
481 | } | 499 | } |
482 | 500 | ||
483 | static inline int memslot_id(struct kvm *kvm, struct kvm_memory_slot *slot) | ||
484 | { | ||
485 | return slot - kvm->memslots; | ||
486 | } | ||
487 | |||
488 | static inline gpa_t gfn_to_gpa(gfn_t gfn) | 501 | static inline gpa_t gfn_to_gpa(gfn_t gfn) |
489 | { | 502 | { |
490 | return (gpa_t)gfn << PAGE_SHIFT; | 503 | return (gpa_t)gfn << PAGE_SHIFT; |
@@ -532,6 +545,10 @@ static inline int mmu_notifier_retry(struct kvm_vcpu *vcpu, unsigned long mmu_se | |||
532 | } | 545 | } |
533 | #endif | 546 | #endif |
534 | 547 | ||
548 | #ifndef KVM_ARCH_HAS_UNALIAS_INSTANTIATION | ||
549 | #define unalias_gfn_instantiation unalias_gfn | ||
550 | #endif | ||
551 | |||
535 | #ifdef CONFIG_HAVE_KVM_IRQCHIP | 552 | #ifdef CONFIG_HAVE_KVM_IRQCHIP |
536 | 553 | ||
537 | #define KVM_MAX_IRQ_ROUTES 1024 | 554 | #define KVM_MAX_IRQ_ROUTES 1024 |
diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h index dbe108455275..b17d49dfc3ef 100644 --- a/include/trace/events/kvm.h +++ b/include/trace/events/kvm.h | |||
@@ -145,6 +145,47 @@ TRACE_EVENT(kvm_mmio, | |||
145 | __entry->len, __entry->gpa, __entry->val) | 145 | __entry->len, __entry->gpa, __entry->val) |
146 | ); | 146 | ); |
147 | 147 | ||
148 | #define kvm_fpu_load_symbol \ | ||
149 | {0, "unload"}, \ | ||
150 | {1, "load"} | ||
151 | |||
152 | TRACE_EVENT(kvm_fpu, | ||
153 | TP_PROTO(int load), | ||
154 | TP_ARGS(load), | ||
155 | |||
156 | TP_STRUCT__entry( | ||
157 | __field( u32, load ) | ||
158 | ), | ||
159 | |||
160 | TP_fast_assign( | ||
161 | __entry->load = load; | ||
162 | ), | ||
163 | |||
164 | TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol)) | ||
165 | ); | ||
166 | |||
167 | TRACE_EVENT(kvm_age_page, | ||
168 | TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref), | ||
169 | TP_ARGS(hva, slot, ref), | ||
170 | |||
171 | TP_STRUCT__entry( | ||
172 | __field( u64, hva ) | ||
173 | __field( u64, gfn ) | ||
174 | __field( u8, referenced ) | ||
175 | ), | ||
176 | |||
177 | TP_fast_assign( | ||
178 | __entry->hva = hva; | ||
179 | __entry->gfn = | ||
180 | slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT); | ||
181 | __entry->referenced = ref; | ||
182 | ), | ||
183 | |||
184 | TP_printk("hva %llx gfn %llx %s", | ||
185 | __entry->hva, __entry->gfn, | ||
186 | __entry->referenced ? "YOUNG" : "OLD") | ||
187 | ); | ||
188 | |||
148 | #endif /* _TRACE_KVM_MAIN_H */ | 189 | #endif /* _TRACE_KVM_MAIN_H */ |
149 | 190 | ||
150 | /* This part must be outside protection */ | 191 | /* This part must be outside protection */ |