Skip to content

Commit baabee6

Browse files
davidhildenbrandborntraeger
authored andcommitted
KVM: s390: use switch vs jump table in interrupt.c
Just like for the interception handlers, let's also use a switch-case in our interrupt delivery code. Signed-off-by: David Hildenbrand <[email protected]> Message-Id: <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Reviewed-by: Janosch Frank <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]>
1 parent cb7485d commit baabee6

File tree

1 file changed

+50
-34
lines changed

1 file changed

+50
-34
lines changed

arch/s390/kvm/interrupt.c

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,6 @@ static int cpu_timer_irq_pending(struct kvm_vcpu *vcpu)
187187
return kvm_s390_get_cpu_timer(vcpu) >> 63;
188188
}
189189

190-
static inline int is_ioirq(unsigned long irq_type)
191-
{
192-
return ((irq_type >= IRQ_PEND_IO_ISC_7) &&
193-
(irq_type <= IRQ_PEND_IO_ISC_0));
194-
}
195-
196190
static uint64_t isc_to_isc_bits(int isc)
197191
{
198192
return (0x80 >> isc) << 24;
@@ -1016,24 +1010,6 @@ static int __must_check __deliver_io(struct kvm_vcpu *vcpu,
10161010
return rc;
10171011
}
10181012

1019-
typedef int (*deliver_irq_t)(struct kvm_vcpu *vcpu);
1020-
1021-
static const deliver_irq_t deliver_irq_funcs[] = {
1022-
[IRQ_PEND_MCHK_EX] = __deliver_machine_check,
1023-
[IRQ_PEND_MCHK_REP] = __deliver_machine_check,
1024-
[IRQ_PEND_PROG] = __deliver_prog,
1025-
[IRQ_PEND_EXT_EMERGENCY] = __deliver_emergency_signal,
1026-
[IRQ_PEND_EXT_EXTERNAL] = __deliver_external_call,
1027-
[IRQ_PEND_EXT_CLOCK_COMP] = __deliver_ckc,
1028-
[IRQ_PEND_EXT_CPU_TIMER] = __deliver_cpu_timer,
1029-
[IRQ_PEND_RESTART] = __deliver_restart,
1030-
[IRQ_PEND_SET_PREFIX] = __deliver_set_prefix,
1031-
[IRQ_PEND_PFAULT_INIT] = __deliver_pfault_init,
1032-
[IRQ_PEND_EXT_SERVICE] = __deliver_service,
1033-
[IRQ_PEND_PFAULT_DONE] = __deliver_pfault_done,
1034-
[IRQ_PEND_VIRTIO] = __deliver_virtio,
1035-
};
1036-
10371013
/* Check whether an external call is pending (deliverable or not) */
10381014
int kvm_s390_ext_call_pending(struct kvm_vcpu *vcpu)
10391015
{
@@ -1197,7 +1173,6 @@ void kvm_s390_clear_local_irqs(struct kvm_vcpu *vcpu)
11971173
int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
11981174
{
11991175
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
1200-
deliver_irq_t func;
12011176
int rc = 0;
12021177
unsigned long irq_type;
12031178
unsigned long irqs;
@@ -1217,16 +1192,57 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
12171192
while ((irqs = deliverable_irqs(vcpu)) && !rc) {
12181193
/* bits are in the reverse order of interrupt priority */
12191194
irq_type = find_last_bit(&irqs, IRQ_PEND_COUNT);
1220-
if (is_ioirq(irq_type)) {
1195+
switch (irq_type) {
1196+
case IRQ_PEND_IO_ISC_0:
1197+
case IRQ_PEND_IO_ISC_1:
1198+
case IRQ_PEND_IO_ISC_2:
1199+
case IRQ_PEND_IO_ISC_3:
1200+
case IRQ_PEND_IO_ISC_4:
1201+
case IRQ_PEND_IO_ISC_5:
1202+
case IRQ_PEND_IO_ISC_6:
1203+
case IRQ_PEND_IO_ISC_7:
12211204
rc = __deliver_io(vcpu, irq_type);
1222-
} else {
1223-
func = deliver_irq_funcs[irq_type];
1224-
if (!func) {
1225-
WARN_ON_ONCE(func == NULL);
1226-
clear_bit(irq_type, &li->pending_irqs);
1227-
continue;
1228-
}
1229-
rc = func(vcpu);
1205+
break;
1206+
case IRQ_PEND_MCHK_EX:
1207+
case IRQ_PEND_MCHK_REP:
1208+
rc = __deliver_machine_check(vcpu);
1209+
break;
1210+
case IRQ_PEND_PROG:
1211+
rc = __deliver_prog(vcpu);
1212+
break;
1213+
case IRQ_PEND_EXT_EMERGENCY:
1214+
rc = __deliver_emergency_signal(vcpu);
1215+
break;
1216+
case IRQ_PEND_EXT_EXTERNAL:
1217+
rc = __deliver_external_call(vcpu);
1218+
break;
1219+
case IRQ_PEND_EXT_CLOCK_COMP:
1220+
rc = __deliver_ckc(vcpu);
1221+
break;
1222+
case IRQ_PEND_EXT_CPU_TIMER:
1223+
rc = __deliver_cpu_timer(vcpu);
1224+
break;
1225+
case IRQ_PEND_RESTART:
1226+
rc = __deliver_restart(vcpu);
1227+
break;
1228+
case IRQ_PEND_SET_PREFIX:
1229+
rc = __deliver_set_prefix(vcpu);
1230+
break;
1231+
case IRQ_PEND_PFAULT_INIT:
1232+
rc = __deliver_pfault_init(vcpu);
1233+
break;
1234+
case IRQ_PEND_EXT_SERVICE:
1235+
rc = __deliver_service(vcpu);
1236+
break;
1237+
case IRQ_PEND_PFAULT_DONE:
1238+
rc = __deliver_pfault_done(vcpu);
1239+
break;
1240+
case IRQ_PEND_VIRTIO:
1241+
rc = __deliver_virtio(vcpu);
1242+
break;
1243+
default:
1244+
WARN_ONCE(1, "Unknown pending irq type %ld", irq_type);
1245+
clear_bit(irq_type, &li->pending_irqs);
12301246
}
12311247
}
12321248

0 commit comments

Comments
 (0)