Re: [PATCH v2 1/2] KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format
From: Christian Borntraeger
Date: Thu Nov 26 2026 - 03:33:23 EST
Am 25.11.26 um 17:56 schrieb Yvan Janssens:
ESA-mode guests in vsie have existed since commit b0ad874d9852 ("KVM:
s390: vsie: Allow non-zarch guests"); they use the 8-byte short PSW -
the mask and instruction address share one doubleword.
vsie's PSW rewind originally still changed the second doubleword, which
is unused in ESA mode, so the instruction is skipped instead of
repeated. The visible effect is that the first STFLE after entering SIE
does nothing in a nested guest.
There might be other cases as well that we skip. So when applying maybe
replace "The visible" with "One visible"
This patch adds a vsie-specific rewind function that handles both
formats; no short-PSW type is introduced - for ESA guests mask and
address are written into the mask field.
Fixes: b0ad874d9852 ("KVM: s390: vsie: Allow non-zarch guests")
Cc: stable@xxxxxxxxxxxxxxx # 7.1+
Signed-off-by: Yvan Janssens <yvanj@xxxxxxxxxx>
Reviewed-by: Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>
---
arch/s390/kvm/s390/vsie.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/s390/kvm/s390/vsie.c b/arch/s390/kvm/s390/vsie.c
index 3ce133f20fa2..ed40d40d89e4 100644
--- a/arch/s390/kvm/s390/vsie.c
+++ b/arch/s390/kvm/s390/vsie.c
@@ -948,6 +948,20 @@ static inline void clear_vsie_icpt(struct vsie_page *vsie_page)
vsie_page->scb_s.icptcode = 0;
}
+static void vsie_rewind_psw(struct kvm_s390_sie_block *scb, int ilen)
+{
+ u64 addr_mask;
+
+ if (atomic_read(&scb->cpuflags) & CPUSTAT_ZARCH) {
+ scb->gpsw.addr = __rewind_psw(scb->gpsw, ilen);
+ return;
+ }
+ /* ESA short PSW: mask and address both live in gpsw.mask */
+ addr_mask = scb->gpsw.mask & PSW32_ADDR_AMODE ? PSW32_ADDR_INSN : 0x00ffffffUL;
+ scb->gpsw.mask = (scb->gpsw.mask & ~PSW32_ADDR_INSN) |
+ ((scb->gpsw.mask - ilen) & addr_mask);
+}
+
/* rewind the psw and clear the vsie icpt, so we can retry execution */
static void retry_vsie_icpt(struct vsie_page *vsie_page)
{
@@ -960,7 +974,7 @@ static void retry_vsie_icpt(struct vsie_page *vsie_page)
if (!ilen)
ilen = 4;
}
- scb_s->gpsw.addr = __rewind_psw(scb_s->gpsw, ilen);
+ vsie_rewind_psw(scb_s, ilen);
clear_vsie_icpt(vsie_page);
}
@@ -1413,7 +1427,7 @@ static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
scb_s->icptcode = ICPT_PROGI;
scb_s->iprcc = PGM_ADDRESSING;
scb_s->pgmilc = 4;
- scb_s->gpsw.addr = __rewind_psw(scb_s->gpsw, 4);
+ vsie_rewind_psw(scb_s, 4);
rc = 1;
}
return rc;