diff options
Diffstat (limited to 'arch/s390/kvm/interrupt.c')
-rw-r--r-- | arch/s390/kvm/interrupt.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index 329b2843fee2..fa557372d600 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c | |||
@@ -213,6 +213,16 @@ static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu) | |||
213 | vcpu->arch.local_int.pending_irqs; | 213 | vcpu->arch.local_int.pending_irqs; |
214 | } | 214 | } |
215 | 215 | ||
216 | static inline int isc_to_irq_type(unsigned long isc) | ||
217 | { | ||
218 | return IRQ_PEND_IO_ISC_0 + isc; | ||
219 | } | ||
220 | |||
221 | static inline int irq_type_to_isc(unsigned long irq_type) | ||
222 | { | ||
223 | return irq_type - IRQ_PEND_IO_ISC_0; | ||
224 | } | ||
225 | |||
216 | static unsigned long disable_iscs(struct kvm_vcpu *vcpu, | 226 | static unsigned long disable_iscs(struct kvm_vcpu *vcpu, |
217 | unsigned long active_mask) | 227 | unsigned long active_mask) |
218 | { | 228 | { |
@@ -220,7 +230,7 @@ static unsigned long disable_iscs(struct kvm_vcpu *vcpu, | |||
220 | 230 | ||
221 | for (i = 0; i <= MAX_ISC; i++) | 231 | for (i = 0; i <= MAX_ISC; i++) |
222 | if (!(vcpu->arch.sie_block->gcr[6] & isc_to_isc_bits(i))) | 232 | if (!(vcpu->arch.sie_block->gcr[6] & isc_to_isc_bits(i))) |
223 | active_mask &= ~(1UL << (IRQ_PEND_IO_ISC_0 + i)); | 233 | active_mask &= ~(1UL << (isc_to_irq_type(i))); |
224 | 234 | ||
225 | return active_mask; | 235 | return active_mask; |
226 | } | 236 | } |
@@ -901,7 +911,7 @@ static int __must_check __deliver_io(struct kvm_vcpu *vcpu, | |||
901 | fi = &vcpu->kvm->arch.float_int; | 911 | fi = &vcpu->kvm->arch.float_int; |
902 | 912 | ||
903 | spin_lock(&fi->lock); | 913 | spin_lock(&fi->lock); |
904 | isc_list = &fi->lists[irq_type - IRQ_PEND_IO_ISC_0]; | 914 | isc_list = &fi->lists[irq_type_to_isc(irq_type)]; |
905 | inti = list_first_entry_or_null(isc_list, | 915 | inti = list_first_entry_or_null(isc_list, |
906 | struct kvm_s390_interrupt_info, | 916 | struct kvm_s390_interrupt_info, |
907 | list); | 917 | list); |
@@ -1074,6 +1084,12 @@ void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu) | |||
1074 | * in kvm_vcpu_block without having the waitqueue set (polling) | 1084 | * in kvm_vcpu_block without having the waitqueue set (polling) |
1075 | */ | 1085 | */ |
1076 | vcpu->valid_wakeup = true; | 1086 | vcpu->valid_wakeup = true; |
1087 | /* | ||
1088 | * This is mostly to document, that the read in swait_active could | ||
1089 | * be moved before other stores, leading to subtle races. | ||
1090 | * All current users do not store or use an atomic like update | ||
1091 | */ | ||
1092 | smp_mb__after_atomic(); | ||
1077 | if (swait_active(&vcpu->wq)) { | 1093 | if (swait_active(&vcpu->wq)) { |
1078 | /* | 1094 | /* |
1079 | * The vcpu gave up the cpu voluntarily, mark it as a good | 1095 | * The vcpu gave up the cpu voluntarily, mark it as a good |
@@ -1395,7 +1411,7 @@ static struct kvm_s390_interrupt_info *get_io_int(struct kvm *kvm, | |||
1395 | list_del_init(&iter->list); | 1411 | list_del_init(&iter->list); |
1396 | fi->counters[FIRQ_CNTR_IO] -= 1; | 1412 | fi->counters[FIRQ_CNTR_IO] -= 1; |
1397 | if (list_empty(isc_list)) | 1413 | if (list_empty(isc_list)) |
1398 | clear_bit(IRQ_PEND_IO_ISC_0 + isc, &fi->pending_irqs); | 1414 | clear_bit(isc_to_irq_type(isc), &fi->pending_irqs); |
1399 | spin_unlock(&fi->lock); | 1415 | spin_unlock(&fi->lock); |
1400 | return iter; | 1416 | return iter; |
1401 | } | 1417 | } |
@@ -1522,7 +1538,7 @@ static int __inject_io(struct kvm *kvm, struct kvm_s390_interrupt_info *inti) | |||
1522 | isc = int_word_to_isc(inti->io.io_int_word); | 1538 | isc = int_word_to_isc(inti->io.io_int_word); |
1523 | list = &fi->lists[FIRQ_LIST_IO_ISC_0 + isc]; | 1539 | list = &fi->lists[FIRQ_LIST_IO_ISC_0 + isc]; |
1524 | list_add_tail(&inti->list, list); | 1540 | list_add_tail(&inti->list, list); |
1525 | set_bit(IRQ_PEND_IO_ISC_0 + isc, &fi->pending_irqs); | 1541 | set_bit(isc_to_irq_type(isc), &fi->pending_irqs); |
1526 | spin_unlock(&fi->lock); | 1542 | spin_unlock(&fi->lock); |
1527 | return 0; | 1543 | return 0; |
1528 | } | 1544 | } |
@@ -2175,6 +2191,8 @@ static int clear_io_irq(struct kvm *kvm, struct kvm_device_attr *attr) | |||
2175 | return -EINVAL; | 2191 | return -EINVAL; |
2176 | if (copy_from_user(&schid, (void __user *) attr->addr, sizeof(schid))) | 2192 | if (copy_from_user(&schid, (void __user *) attr->addr, sizeof(schid))) |
2177 | return -EFAULT; | 2193 | return -EFAULT; |
2194 | if (!schid) | ||
2195 | return -EINVAL; | ||
2178 | kfree(kvm_s390_get_io_int(kvm, isc_mask, schid)); | 2196 | kfree(kvm_s390_get_io_int(kvm, isc_mask, schid)); |
2179 | /* | 2197 | /* |
2180 | * If userspace is conforming to the architecture, we can have at most | 2198 | * If userspace is conforming to the architecture, we can have at most |