summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMichael Mueller <mimu@linux.vnet.ibm.com>2017-06-29 12:39:27 -0400
committerChristian Borntraeger <borntraeger@de.ibm.com>2018-01-26 03:49:09 -0500
commitc7901a6ebee4b624971361bbd93f21ab0b359786 (patch)
tree8247eb88130353574f5f2fa35452059ac7c7dd40 /arch
parent8d5fb0dc4ec069ea02395593e9b6b2b39a92457e (diff)
KVM: s390: reverse bit ordering of irqs in pending mask
This patch prepares a simplification of bit operations between the irq pending mask for emulated interrupts and the Interruption Pending Mask (IPM) which is part of the Guest Interruption State Area (GISA), a feature that allows interrupt delivery to guests by means of the SIE instruction. Without that change, a bit-wise *or* operation on parts of these two masks would either require a look-up table of size 256 bytes to map the IPM to the emulated irq pending mask bit orientation (all bits mirrored at half byte) or a sequence of up to 8 condidional branches to perform tests of single bit positions. Both options are to be rejected either by performance or space utilization reasons. Beyond that this change will be transparent. Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com> Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/s390/include/asm/kvm_host.h54
-rw-r--r--arch/s390/kvm/interrupt.c12
2 files changed, 33 insertions, 33 deletions
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 029e8144c6ec..d2351d63afa3 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -422,35 +422,35 @@ struct kvm_vcpu_stat {
422#define PGM_PER 0x80 422#define PGM_PER 0x80
423#define PGM_CRYPTO_OPERATION 0x119 423#define PGM_CRYPTO_OPERATION 0x119
424 424
425/* irq types in order of priority */ 425/* irq types in ascend order of priorities */
426enum irq_types { 426enum irq_types {
427 IRQ_PEND_MCHK_EX = 0, 427 IRQ_PEND_SET_PREFIX = 0,
428 IRQ_PEND_SVC,
429 IRQ_PEND_PROG,
430 IRQ_PEND_MCHK_REP,
431 IRQ_PEND_EXT_IRQ_KEY,
432 IRQ_PEND_EXT_MALFUNC,
433 IRQ_PEND_EXT_EMERGENCY,
434 IRQ_PEND_EXT_EXTERNAL,
435 IRQ_PEND_EXT_CLOCK_COMP,
436 IRQ_PEND_EXT_CPU_TIMER,
437 IRQ_PEND_EXT_TIMING,
438 IRQ_PEND_EXT_SERVICE,
439 IRQ_PEND_EXT_HOST,
440 IRQ_PEND_PFAULT_INIT,
441 IRQ_PEND_PFAULT_DONE,
442 IRQ_PEND_VIRTIO,
443 IRQ_PEND_IO_ISC_0,
444 IRQ_PEND_IO_ISC_1,
445 IRQ_PEND_IO_ISC_2,
446 IRQ_PEND_IO_ISC_3,
447 IRQ_PEND_IO_ISC_4,
448 IRQ_PEND_IO_ISC_5,
449 IRQ_PEND_IO_ISC_6,
450 IRQ_PEND_IO_ISC_7,
451 IRQ_PEND_SIGP_STOP,
452 IRQ_PEND_RESTART, 428 IRQ_PEND_RESTART,
453 IRQ_PEND_SET_PREFIX, 429 IRQ_PEND_SIGP_STOP,
430 IRQ_PEND_IO_ISC_7,
431 IRQ_PEND_IO_ISC_6,
432 IRQ_PEND_IO_ISC_5,
433 IRQ_PEND_IO_ISC_4,
434 IRQ_PEND_IO_ISC_3,
435 IRQ_PEND_IO_ISC_2,
436 IRQ_PEND_IO_ISC_1,
437 IRQ_PEND_IO_ISC_0,
438 IRQ_PEND_VIRTIO,
439 IRQ_PEND_PFAULT_DONE,
440 IRQ_PEND_PFAULT_INIT,
441 IRQ_PEND_EXT_HOST,
442 IRQ_PEND_EXT_SERVICE,
443 IRQ_PEND_EXT_TIMING,
444 IRQ_PEND_EXT_CPU_TIMER,
445 IRQ_PEND_EXT_CLOCK_COMP,
446 IRQ_PEND_EXT_EXTERNAL,
447 IRQ_PEND_EXT_EMERGENCY,
448 IRQ_PEND_EXT_MALFUNC,
449 IRQ_PEND_EXT_IRQ_KEY,
450 IRQ_PEND_MCHK_REP,
451 IRQ_PEND_PROG,
452 IRQ_PEND_SVC,
453 IRQ_PEND_MCHK_EX,
454 IRQ_PEND_COUNT 454 IRQ_PEND_COUNT
455}; 455};
456 456
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 4b483b48436a..b731d4fede83 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -189,8 +189,8 @@ static int cpu_timer_irq_pending(struct kvm_vcpu *vcpu)
189 189
190static inline int is_ioirq(unsigned long irq_type) 190static inline int is_ioirq(unsigned long irq_type)
191{ 191{
192 return ((irq_type >= IRQ_PEND_IO_ISC_0) && 192 return ((irq_type >= IRQ_PEND_IO_ISC_7) &&
193 (irq_type <= IRQ_PEND_IO_ISC_7)); 193 (irq_type <= IRQ_PEND_IO_ISC_0));
194} 194}
195 195
196static uint64_t isc_to_isc_bits(int isc) 196static uint64_t isc_to_isc_bits(int isc)
@@ -211,12 +211,12 @@ static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu)
211 211
212static inline int isc_to_irq_type(unsigned long isc) 212static inline int isc_to_irq_type(unsigned long isc)
213{ 213{
214 return IRQ_PEND_IO_ISC_0 + isc; 214 return IRQ_PEND_IO_ISC_0 - isc;
215} 215}
216 216
217static inline int irq_type_to_isc(unsigned long irq_type) 217static inline int irq_type_to_isc(unsigned long irq_type)
218{ 218{
219 return irq_type - IRQ_PEND_IO_ISC_0; 219 return IRQ_PEND_IO_ISC_0 - irq_type;
220} 220}
221 221
222static unsigned long disable_iscs(struct kvm_vcpu *vcpu, 222static unsigned long disable_iscs(struct kvm_vcpu *vcpu,
@@ -1149,8 +1149,8 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
1149 set_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs); 1149 set_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs);
1150 1150
1151 while ((irqs = deliverable_irqs(vcpu)) && !rc) { 1151 while ((irqs = deliverable_irqs(vcpu)) && !rc) {
1152 /* bits are in the order of interrupt priority */ 1152 /* bits are in the reverse order of interrupt priority */
1153 irq_type = find_first_bit(&irqs, IRQ_PEND_COUNT); 1153 irq_type = find_last_bit(&irqs, IRQ_PEND_COUNT);
1154 if (is_ioirq(irq_type)) { 1154 if (is_ioirq(irq_type)) {
1155 rc = __deliver_io(vcpu, irq_type); 1155 rc = __deliver_io(vcpu, irq_type);
1156 } else { 1156 } else {