diff options
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r-- | include/linux/kvm_host.h | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index ab428552af8e..31ebb59cbd2f 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -27,6 +27,10 @@ | |||
27 | 27 | ||
28 | #include <asm/kvm_host.h> | 28 | #include <asm/kvm_host.h> |
29 | 29 | ||
30 | #ifndef KVM_MMIO_SIZE | ||
31 | #define KVM_MMIO_SIZE 8 | ||
32 | #endif | ||
33 | |||
30 | /* | 34 | /* |
31 | * vcpu->requests bit members | 35 | * vcpu->requests bit members |
32 | */ | 36 | */ |
@@ -43,7 +47,6 @@ | |||
43 | #define KVM_REQ_DEACTIVATE_FPU 10 | 47 | #define KVM_REQ_DEACTIVATE_FPU 10 |
44 | #define KVM_REQ_EVENT 11 | 48 | #define KVM_REQ_EVENT 11 |
45 | #define KVM_REQ_APF_HALT 12 | 49 | #define KVM_REQ_APF_HALT 12 |
46 | #define KVM_REQ_NMI 13 | ||
47 | 50 | ||
48 | #define KVM_USERSPACE_IRQ_SOURCE_ID 0 | 51 | #define KVM_USERSPACE_IRQ_SOURCE_ID 0 |
49 | 52 | ||
@@ -133,7 +136,8 @@ struct kvm_vcpu { | |||
133 | int mmio_read_completed; | 136 | int mmio_read_completed; |
134 | int mmio_is_write; | 137 | int mmio_is_write; |
135 | int mmio_size; | 138 | int mmio_size; |
136 | unsigned char mmio_data[8]; | 139 | int mmio_index; |
140 | unsigned char mmio_data[KVM_MMIO_SIZE]; | ||
137 | gpa_t mmio_phys_addr; | 141 | gpa_t mmio_phys_addr; |
138 | #endif | 142 | #endif |
139 | 143 | ||
@@ -292,9 +296,10 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i) | |||
292 | } | 296 | } |
293 | 297 | ||
294 | #define kvm_for_each_vcpu(idx, vcpup, kvm) \ | 298 | #define kvm_for_each_vcpu(idx, vcpup, kvm) \ |
295 | for (idx = 0, vcpup = kvm_get_vcpu(kvm, idx); \ | 299 | for (idx = 0; \ |
296 | idx < atomic_read(&kvm->online_vcpus) && vcpup; \ | 300 | idx < atomic_read(&kvm->online_vcpus) && \ |
297 | vcpup = kvm_get_vcpu(kvm, ++idx)) | 301 | (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \ |
302 | idx++) | ||
298 | 303 | ||
299 | int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id); | 304 | int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id); |
300 | void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); | 305 | void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); |
@@ -365,7 +370,6 @@ pfn_t gfn_to_pfn_prot(struct kvm *kvm, gfn_t gfn, bool write_fault, | |||
365 | bool *writable); | 370 | bool *writable); |
366 | pfn_t gfn_to_pfn_memslot(struct kvm *kvm, | 371 | pfn_t gfn_to_pfn_memslot(struct kvm *kvm, |
367 | struct kvm_memory_slot *slot, gfn_t gfn); | 372 | struct kvm_memory_slot *slot, gfn_t gfn); |
368 | int memslot_id(struct kvm *kvm, gfn_t gfn); | ||
369 | void kvm_release_pfn_dirty(pfn_t); | 373 | void kvm_release_pfn_dirty(pfn_t); |
370 | void kvm_release_pfn_clean(pfn_t pfn); | 374 | void kvm_release_pfn_clean(pfn_t pfn); |
371 | void kvm_set_pfn_dirty(pfn_t pfn); | 375 | void kvm_set_pfn_dirty(pfn_t pfn); |
@@ -513,6 +517,7 @@ struct kvm_assigned_dev_kernel { | |||
513 | struct kvm *kvm; | 517 | struct kvm *kvm; |
514 | spinlock_t intx_lock; | 518 | spinlock_t intx_lock; |
515 | char irq_name[32]; | 519 | char irq_name[32]; |
520 | struct pci_saved_state *pci_saved_state; | ||
516 | }; | 521 | }; |
517 | 522 | ||
518 | struct kvm_irq_mask_notifier { | 523 | struct kvm_irq_mask_notifier { |
@@ -587,8 +592,17 @@ static inline int kvm_deassign_device(struct kvm *kvm, | |||
587 | 592 | ||
588 | static inline void kvm_guest_enter(void) | 593 | static inline void kvm_guest_enter(void) |
589 | { | 594 | { |
595 | BUG_ON(preemptible()); | ||
590 | account_system_vtime(current); | 596 | account_system_vtime(current); |
591 | current->flags |= PF_VCPU; | 597 | current->flags |= PF_VCPU; |
598 | /* KVM does not hold any references to rcu protected data when it | ||
599 | * switches CPU into a guest mode. In fact switching to a guest mode | ||
600 | * is very similar to exiting to userspase from rcu point of view. In | ||
601 | * addition CPU may stay in a guest mode for quite a long time (up to | ||
602 | * one time slice). Lets treat guest mode as quiescent state, just like | ||
603 | * we do with user-mode execution. | ||
604 | */ | ||
605 | rcu_virt_note_context_switch(smp_processor_id()); | ||
592 | } | 606 | } |
593 | 607 | ||
594 | static inline void kvm_guest_exit(void) | 608 | static inline void kvm_guest_exit(void) |
@@ -597,6 +611,11 @@ static inline void kvm_guest_exit(void) | |||
597 | current->flags &= ~PF_VCPU; | 611 | current->flags &= ~PF_VCPU; |
598 | } | 612 | } |
599 | 613 | ||
614 | static inline int memslot_id(struct kvm *kvm, gfn_t gfn) | ||
615 | { | ||
616 | return gfn_to_memslot(kvm, gfn)->id; | ||
617 | } | ||
618 | |||
600 | static inline unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, | 619 | static inline unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, |
601 | gfn_t gfn) | 620 | gfn_t gfn) |
602 | { | 621 | { |