Skip to content

Commit 16631c4

Browse files
iii-ifrankjaa
authored andcommitted
KVM: s390: interrupt: Fix single-stepping into interrupt handlers
After single-stepping an instruction that generates an interrupt, GDB ends up on the second instruction of the respective interrupt handler. The reason is that vcpu_pre_run() manually delivers the interrupt, and then __vcpu_run() runs the first handler instruction using the CPUSTAT_P flag. This causes a KVM_SINGLESTEP exit on the second handler instruction. Fix by delaying the KVM_SINGLESTEP exit until after the manual interrupt delivery. Acked-by: David Hildenbrand <[email protected]> Reviewed-by: Claudio Imbrenda <[email protected]> Signed-off-by: Ilya Leoshkevich <[email protected]> Message-ID: <[email protected]> Signed-off-by: Claudio Imbrenda <[email protected]> Signed-off-by: Janosch Frank <[email protected]>
1 parent ede6d0b commit 16631c4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

arch/s390/kvm/interrupt.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,7 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
13921392
{
13931393
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
13941394
int rc = 0;
1395+
bool delivered = false;
13951396
unsigned long irq_type;
13961397
unsigned long irqs;
13971398

@@ -1465,6 +1466,19 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
14651466
WARN_ONCE(1, "Unknown pending irq type %ld", irq_type);
14661467
clear_bit(irq_type, &li->pending_irqs);
14671468
}
1469+
delivered |= !rc;
1470+
}
1471+
1472+
/*
1473+
* We delivered at least one interrupt and modified the PC. Force a
1474+
* singlestep event now.
1475+
*/
1476+
if (delivered && guestdbg_sstep_enabled(vcpu)) {
1477+
struct kvm_debug_exit_arch *debug_exit = &vcpu->run->debug.arch;
1478+
1479+
debug_exit->addr = vcpu->arch.sie_block->gpsw.addr;
1480+
debug_exit->type = KVM_SINGLESTEP;
1481+
vcpu->guest_debug |= KVM_GUESTDBG_EXIT_PENDING;
14681482
}
14691483

14701484
set_intercept_indicators(vcpu);

arch/s390/kvm/kvm-s390.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4611,7 +4611,7 @@ static int vcpu_pre_run(struct kvm_vcpu *vcpu)
46114611

46124612
if (!kvm_is_ucontrol(vcpu->kvm)) {
46134613
rc = kvm_s390_deliver_pending_interrupts(vcpu);
4614-
if (rc)
4614+
if (rc || guestdbg_exit_pending(vcpu))
46154615
return rc;
46164616
}
46174617

@@ -4738,7 +4738,7 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
47384738

47394739
do {
47404740
rc = vcpu_pre_run(vcpu);
4741-
if (rc)
4741+
if (rc || guestdbg_exit_pending(vcpu))
47424742
break;
47434743

47444744
kvm_vcpu_srcu_read_unlock(vcpu);

0 commit comments

Comments
 (0)