Skip to content

Commit 33a729a

Browse files
efarmanfrankjaa
authored andcommitted
KVM: s390: vsie: retry SIE instruction on host intercepts
It's possible that SIE exits for work that the host needs to perform rather than something that is intended for the guest. A Linux guest will ignore this intercept code since there is nothing for it to do, but a more robust solution would rewind the PSW back to the SIE instruction. This will transparently resume the guest once the host completes its work, without the guest needing to process what is effectively a NOP and re-issue SIE itself. Signed-off-by: Eric Farman <[email protected]> Acked-by: Christian Borntraeger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Janosch Frank <[email protected]> Message-ID: <[email protected]>
1 parent 98f7703 commit 33a729a

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

arch/s390/kvm/vsie.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,10 +1304,24 @@ static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
13041304

13051305
if (rc == -EAGAIN)
13061306
rc = 0;
1307-
if (rc || scb_s->icptcode || signal_pending(current) ||
1307+
1308+
/*
1309+
* Exit the loop if the guest needs to process the intercept
1310+
*/
1311+
if (rc || scb_s->icptcode)
1312+
break;
1313+
1314+
/*
1315+
* Exit the loop if the host needs to process an intercept,
1316+
* but rewind the PSW to re-enter SIE once that's completed
1317+
* instead of passing a "no action" intercept to the guest.
1318+
*/
1319+
if (signal_pending(current) ||
13081320
kvm_s390_vcpu_has_irq(vcpu, 0) ||
1309-
kvm_s390_vcpu_sie_inhibited(vcpu))
1321+
kvm_s390_vcpu_sie_inhibited(vcpu)) {
1322+
kvm_s390_rewind_psw(vcpu, 4);
13101323
break;
1324+
}
13111325
cond_resched();
13121326
}
13131327

@@ -1426,8 +1440,10 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu)
14261440
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
14271441

14281442
if (signal_pending(current) || kvm_s390_vcpu_has_irq(vcpu, 0) ||
1429-
kvm_s390_vcpu_sie_inhibited(vcpu))
1443+
kvm_s390_vcpu_sie_inhibited(vcpu)) {
1444+
kvm_s390_rewind_psw(vcpu, 4);
14301445
return 0;
1446+
}
14311447

14321448
vsie_page = get_vsie_page(vcpu->kvm, scb_addr);
14331449
if (IS_ERR(vsie_page))

0 commit comments

Comments
 (0)