diff options
author | Paul Mackerras <paulus@samba.org> | 2014-06-30 06:51:11 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-08-05 08:26:20 -0400 |
commit | 9957c86d659a4d5a2bed25ccbd3bfc9c3f25e658 (patch) | |
tree | 27bd3fc644da983d63e34bb1ed54c8dcdab5fe0d /include/linux/kvm_host.h | |
parent | 8ba918d488caded2c4368b0b922eb905fe3bb101 (diff) |
KVM: Move all accesses to kvm::irq_routing into irqchip.c
Now that struct _irqfd does not keep a reference to storage pointed
to by the irq_routing field of struct kvm, we can move the statement
that updates it out from under the irqfds.lock and put it in
kvm_set_irq_routing() instead. That means we then have to take a
srcu_read_lock on kvm->irq_srcu around the irqfd_update call in
kvm_irqfd_assign(), since holding the kvm->irqfds.lock no longer
ensures that that the routing can't change.
Combined with changing kvm_irq_map_gsi() and kvm_irq_map_chip_pin()
to take a struct kvm * argument instead of the pointer to the routing
table, this allows us to to move all references to kvm->irq_routing
into irqchip.c. That in turn allows us to move the definition of the
kvm_irq_routing_table struct into irqchip.c as well.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Tested-by: Eric Auger <eric.auger@linaro.org>
Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r-- | include/linux/kvm_host.h | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 4956149e962a..ddd33e1aeee1 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -325,24 +325,7 @@ struct kvm_kernel_irq_routing_entry { | |||
325 | struct hlist_node link; | 325 | struct hlist_node link; |
326 | }; | 326 | }; |
327 | 327 | ||
328 | #ifdef CONFIG_HAVE_KVM_IRQ_ROUTING | 328 | struct kvm_irq_routing_table; |
329 | |||
330 | struct kvm_irq_routing_table { | ||
331 | int chip[KVM_NR_IRQCHIPS][KVM_IRQCHIP_NUM_PINS]; | ||
332 | struct kvm_kernel_irq_routing_entry *rt_entries; | ||
333 | u32 nr_rt_entries; | ||
334 | /* | ||
335 | * Array indexed by gsi. Each entry contains list of irq chips | ||
336 | * the gsi is connected to. | ||
337 | */ | ||
338 | struct hlist_head map[0]; | ||
339 | }; | ||
340 | |||
341 | #else | ||
342 | |||
343 | struct kvm_irq_routing_table {}; | ||
344 | |||
345 | #endif | ||
346 | 329 | ||
347 | #ifndef KVM_PRIVATE_MEM_SLOTS | 330 | #ifndef KVM_PRIVATE_MEM_SLOTS |
348 | #define KVM_PRIVATE_MEM_SLOTS 0 | 331 | #define KVM_PRIVATE_MEM_SLOTS 0 |
@@ -401,8 +384,7 @@ struct kvm { | |||
401 | struct mutex irq_lock; | 384 | struct mutex irq_lock; |
402 | #ifdef CONFIG_HAVE_KVM_IRQCHIP | 385 | #ifdef CONFIG_HAVE_KVM_IRQCHIP |
403 | /* | 386 | /* |
404 | * Update side is protected by irq_lock and, | 387 | * Update side is protected by irq_lock. |
405 | * if configured, irqfds.lock. | ||
406 | */ | 388 | */ |
407 | struct kvm_irq_routing_table __rcu *irq_routing; | 389 | struct kvm_irq_routing_table __rcu *irq_routing; |
408 | struct hlist_head mask_notifier_list; | 390 | struct hlist_head mask_notifier_list; |
@@ -752,10 +734,9 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq, | |||
752 | void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin, | 734 | void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin, |
753 | bool mask); | 735 | bool mask); |
754 | 736 | ||
755 | int kvm_irq_map_gsi(struct kvm_kernel_irq_routing_entry *entries, | 737 | int kvm_irq_map_gsi(struct kvm *kvm, |
756 | struct kvm_irq_routing_table *irq_rt, int gsi); | 738 | struct kvm_kernel_irq_routing_entry *entries, int gsi); |
757 | int kvm_irq_map_chip_pin(struct kvm_irq_routing_table *irq_rt, | 739 | int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin); |
758 | unsigned irqchip, unsigned pin); | ||
759 | 740 | ||
760 | int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level, | 741 | int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level, |
761 | bool line_status); | 742 | bool line_status); |
@@ -967,7 +948,7 @@ int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args); | |||
967 | #ifdef CONFIG_HAVE_KVM_IRQCHIP | 948 | #ifdef CONFIG_HAVE_KVM_IRQCHIP |
968 | int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args); | 949 | int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args); |
969 | void kvm_irqfd_release(struct kvm *kvm); | 950 | void kvm_irqfd_release(struct kvm *kvm); |
970 | void kvm_irq_routing_update(struct kvm *, struct kvm_irq_routing_table *); | 951 | void kvm_irq_routing_update(struct kvm *); |
971 | #else | 952 | #else |
972 | static inline int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args) | 953 | static inline int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args) |
973 | { | 954 | { |
@@ -989,10 +970,8 @@ static inline int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args) | |||
989 | static inline void kvm_irqfd_release(struct kvm *kvm) {} | 970 | static inline void kvm_irqfd_release(struct kvm *kvm) {} |
990 | 971 | ||
991 | #ifdef CONFIG_HAVE_KVM_IRQCHIP | 972 | #ifdef CONFIG_HAVE_KVM_IRQCHIP |
992 | static inline void kvm_irq_routing_update(struct kvm *kvm, | 973 | static inline void kvm_irq_routing_update(struct kvm *kvm) |
993 | struct kvm_irq_routing_table *irq_rt) | ||
994 | { | 974 | { |
995 | rcu_assign_pointer(kvm->irq_routing, irq_rt); | ||
996 | } | 975 | } |
997 | #endif | 976 | #endif |
998 | 977 | ||