Skip to content

Commit 74a439e

Browse files
iii-ifrankjaa
authored andcommitted
KVM: s390: interrupt: Fix single-stepping into program interrupt handlers
Currently, after single-stepping an instruction that generates a specification exception, GDB ends up on the instruction immediately following it. The reason is that vcpu_post_run() injects the interrupt and sets KVM_GUESTDBG_EXIT_PENDING, causing a KVM_SINGLESTEP exit. The interrupt is not delivered, however, therefore userspace sees the address of the next instruction. Fix by letting the __vcpu_run() loop go into the next iteration, where vcpu_pre_run() delivers the interrupt and sets KVM_GUESTDBG_EXIT_PENDING. Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Ilya Leoshkevich <[email protected]> Reviewed-by: Claudio Imbrenda <[email protected]> Message-ID: <[email protected]> Signed-off-by: Claudio Imbrenda <[email protected]> Signed-off-by: Janosch Frank <[email protected]>
1 parent 16631c4 commit 74a439e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

arch/s390/kvm/intercept.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,21 @@ static int handle_itdb(struct kvm_vcpu *vcpu)
228228

229229
#define per_event(vcpu) (vcpu->arch.sie_block->iprcc & PGM_PER)
230230

231+
static bool should_handle_per_event(const struct kvm_vcpu *vcpu)
232+
{
233+
if (!guestdbg_enabled(vcpu) || !per_event(vcpu))
234+
return false;
235+
if (guestdbg_sstep_enabled(vcpu) &&
236+
vcpu->arch.sie_block->iprcc != PGM_PER) {
237+
/*
238+
* __vcpu_run() will exit after delivering the concurrently
239+
* indicated condition.
240+
*/
241+
return false;
242+
}
243+
return true;
244+
}
245+
231246
static int handle_prog(struct kvm_vcpu *vcpu)
232247
{
233248
psw_t psw;
@@ -242,7 +257,7 @@ static int handle_prog(struct kvm_vcpu *vcpu)
242257
if (kvm_s390_pv_cpu_is_protected(vcpu))
243258
return -EOPNOTSUPP;
244259

245-
if (guestdbg_enabled(vcpu) && per_event(vcpu)) {
260+
if (should_handle_per_event(vcpu)) {
246261
rc = kvm_s390_handle_per_event(vcpu);
247262
if (rc)
248263
return rc;

0 commit comments

Comments
 (0)