* [PATCH 0/2] KVM: s390: vsie: fix instruction retry for nested guests in ESA mode
@ 2026-11-25 15:16 Yvan Janssens
2026-11-25 15:16 ` [PATCH 1/2] KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format Yvan Janssens
2026-11-25 15:16 ` [PATCH 2/2] KVM: s390: selftests: Add a test for nested guests in ESA mode Yvan Janssens
0 siblings, 2 replies; 4+ messages in thread
From: Yvan Janssens @ 2026-11-25 15:16 UTC (permalink / raw)
To: Christian Borntraeger, Janosch Frank, Claudio Imbrenda
Cc: David Hildenbrand, Eric Farman, Hendrik Brueckner,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
Paolo Bonzini, Sean Christopherson, Shuah Khan, kvm, linux-s390,
linux-kselftest, linux-kernel
Since v7.1 a nested hypervisor can run its guests in ESA mode (the
ESA/390-compatibility mode of the machine) when user space enables
KVM_CAP_S390_VSIE_ESAMODE. One piece of vsie still treats the PSW of such a
guest as a z/Architecture PSW: the rewind that vsie uses to have an
instruction repeated. For a state description in ESA/390 format the
instruction is skipped instead, and a stray value is left in the half of
the PSW field that such a state description does not use.
What a nested guest sees: the first STORE FACILITY LIST EXTENDED after
every entry into SIE does nothing (operand and condition code untouched),
because vsie intercepts it to shadow the facility list. A program that
tests facility bits gets zeros.
Patch 1 is the fix, patch 2 a selftest that reproduces the problem with a
small guest 2 that issues SIE itself (modelled on the vsie selftest that is
queued in kvm-s390 next). The series is based on v7.4-rc4-260-g4dce97c6c265.
Why it matters beyond one instruction: backward compatibility is a
defining property of this platform, and the ESA/390-compatibility mode is
the architecture's mechanism for running older programs on machines that
only start in z/Architecture mode. Any hypervisor that runs as a KVM guest
and gives its own guests that mode depends on vsie handling such state
descriptions exactly like the machine.
Testing (z14)
- On an LPAR running v7.3.6 with patch 1 (the host owns SIE) the selftest
of patch 2 passes all three checks: the unused doubleword stays 0, the
PSW ends behind the last instruction, and the first STFLE stores the
designated list.
- Without patch 1 (v7.3.6, test kernel running as a KVM guest above a level
that passed ESA mode state descriptions on): the unused PSW doubleword
comes back as 0x7ffffff8 and neither STFLE stores anything. In such a
nested setup above a host without the fix, checks 1 and 3 still fail
with patch 1 in the test kernel, because the defect acts once per level.
- On a host whose lower level refuses ESA mode state descriptions the test
skips (validity 0x0001 seen by guest 2).
- KVM selftests (12 s390 tests and 5 generic ones) and the s390x
kvm-unit-tests (37 pass, 4 fail, 21 skip) give the same result for every
test with and without the series (v7.3.6, nested setup); the 4 failures
(sclp-1g, sclp-3g, css, edat) are the same with the unmodified module.
- Built with W=1 and sparse without warnings; checkpatch --strict is clean
apart from the MAINTAINERS note for the new file.
- Not tested: MOVE PAGE partial execution and the addressing-exception
path for a guest in ESA mode. MOVE PAGE is not available in the mode
without the ESA/XC facilities, so the first should not occur.
Assistance: the series was prepared with an AI coding assistant (see the
Assisted-by tags); the defect was found while tracing why a facility test
failed in a nested guest, the analysis, fix and test were written with the
assistant and reviewed by the submitter.
Yvan Janssens (2):
KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format
KVM: s390: selftests: Add a test for nested guests in ESA mode
arch/s390/kvm/s390/vsie.c | 23 ++-
tools/testing/selftests/kvm/Makefile.kvm | 1 +
.../selftests/kvm/s390/vsie_esa_test.c | 180 ++++++++++++++++++
3 files changed, 202 insertions(+), 2 deletions(-)
create mode 100644 tools/testing/selftests/kvm/s390/vsie_esa_test.c
base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format
2026-11-25 15:16 [PATCH 0/2] KVM: s390: vsie: fix instruction retry for nested guests in ESA mode Yvan Janssens
@ 2026-11-25 15:16 ` Yvan Janssens
2026-11-25 16:19 ` Janosch Frank
2026-11-25 15:16 ` [PATCH 2/2] KVM: s390: selftests: Add a test for nested guests in ESA mode Yvan Janssens
1 sibling, 1 reply; 4+ messages in thread
From: Yvan Janssens @ 2026-11-25 15:16 UTC (permalink / raw)
To: Christian Borntraeger, Janosch Frank, Claudio Imbrenda
Cc: David Hildenbrand, Eric Farman, Hendrik Brueckner,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
Paolo Bonzini, Sean Christopherson, Shuah Khan, kvm, linux-s390,
linux-kselftest, linux-kernel
A state description without the z/Architecture flag holds the eight-byte
ESA/390 PSW in the first doubleword of its PSW field: the addressing mode
is bit 32 and the instruction address is in bits 33-63 of that doubleword
(Principles of Operation, "Program-Status Word" as it applies in the
ESA/390-compatibility mode). The second doubleword is not part of the
PSW.
Since nested guests can be run in ESA mode, vsie still rewinds the PSW of
their shadow state description as if it were a z/Architecture PSW. It
subtracts the instruction length from the second doubleword, which leaves
the instruction address alone and stores a wrapped address there
(0x7ffffffc for one four-byte instruction). The value is copied back into
the state description of guest 2 when the shadow is released.
The rewind is how vsie repeats an instruction: STORE FACILITY LIST
EXTENDED after the facility list that guest 2 designates has been
shadowed (handle_stfle()), MOVE PAGE after a fault was resolved
(vsie_handle_mvpg()), and the instruction that is reported with an
addressing exception when guest 3 touches memory guest 2 does not have.
For a guest in ESA mode the instruction is skipped instead. The first
STORE FACILITY LIST EXTENDED after every entry into SIE returns with its
operand and the condition code untouched, so a program in the nested
guest that looks at the facility list sees zeros.
Rewind the instruction address where the format of the state description
has it.
The selftest in the next patch reproduces the problem: on 7.3.6 the
second doubleword of the PSW field comes back as 0x7ffffff8 after two
skipped instructions and the nested guest never stores a facility list.
Fixes: b0ad874d9852 ("KVM: s390: vsie: Allow non-zarch guests")
Cc: stable@vger.kernel.org # 7.1+
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Yvan Janssens <yvanj@cyber.gent>
---
arch/s390/kvm/s390/vsie.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/arch/s390/kvm/s390/vsie.c b/arch/s390/kvm/s390/vsie.c
index 3ce133f20fa2..58afe913bff4 100644
--- a/arch/s390/kvm/s390/vsie.c
+++ b/arch/s390/kvm/s390/vsie.c
@@ -948,6 +948,25 @@ static inline void clear_vsie_icpt(struct vsie_page *vsie_page)
vsie_page->scb_s.icptcode = 0;
}
+/*
+ * Rewind the PSW of a shadow scb. An ESA mode guest has the eight-byte
+ * ESA/390 PSW in the first doubleword of the PSW field: the addressing mode
+ * in bit 32 and the instruction address in bits 33-63. The second doubleword
+ * is not part of its PSW.
+ */
+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;
+ }
+ 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 +979,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 +1432,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;
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] KVM: s390: selftests: Add a test for nested guests in ESA mode
2026-11-25 15:16 [PATCH 0/2] KVM: s390: vsie: fix instruction retry for nested guests in ESA mode Yvan Janssens
2026-11-25 15:16 ` [PATCH 1/2] KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format Yvan Janssens
@ 2026-11-25 15:16 ` Yvan Janssens
1 sibling, 0 replies; 4+ messages in thread
From: Yvan Janssens @ 2026-11-25 15:16 UTC (permalink / raw)
To: Christian Borntraeger, Janosch Frank, Claudio Imbrenda
Cc: David Hildenbrand, Eric Farman, Hendrik Brueckner,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
Paolo Bonzini, Sean Christopherson, Shuah Khan, kvm, linux-s390,
linux-kselftest, linux-kernel
Run a nested guest from a state description without the z/Architecture
flag, with KVM_CAP_S390_VSIE_ESAMODE enabled, and let it execute STORE
FACILITY LIST EXTENDED twice. vsie intercepts the first one of every SIE
entry to shadow the facility list guest 2 designates and then has the
instruction repeated.
The test checks that the second doubleword of the PSW field, which is not
part of an ESA/390 PSW, comes back unchanged, that the PSW points behind
the last instruction, and that the first instruction stored the
designated list. What the second instruction stored is printed for
diagnosis.
The test is skipped without the capability, without interpretive
execution for the guest (SIEF2) and without facility 7 in the guest's
model.
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: Yvan Janssens <yvanj@cyber.gent>
---
tools/testing/selftests/kvm/Makefile.kvm | 1 +
.../selftests/kvm/s390/vsie_esa_test.c | 180 ++++++++++++++++++
2 files changed, 181 insertions(+)
create mode 100644 tools/testing/selftests/kvm/s390/vsie_esa_test.c
diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
index 283c59d7649c..aef64ec2719c 100644
--- a/tools/testing/selftests/kvm/Makefile.kvm
+++ b/tools/testing/selftests/kvm/Makefile.kvm
@@ -227,6 +227,7 @@ TEST_GEN_PROGS_s390 += s390/shared_zeropage_test
TEST_GEN_PROGS_s390 += s390/ucontrol_test
TEST_GEN_PROGS_s390 += s390/user_operexec
TEST_GEN_PROGS_s390 += s390/keyop
+TEST_GEN_PROGS_s390 += s390/vsie_esa_test
TEST_GEN_PROGS_s390 += rseq_test
TEST_GEN_PROGS_s390 += s390/irq_routing
TEST_GEN_PROGS_s390 += mmu_stress_test
diff --git a/tools/testing/selftests/kvm/s390/vsie_esa_test.c b/tools/testing/selftests/kvm/s390/vsie_esa_test.c
new file mode 100644
index 000000000000..a52603e30f63
--- /dev/null
+++ b/tools/testing/selftests/kvm/s390/vsie_esa_test.c
@@ -0,0 +1,180 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Test nested guests that run in ESA mode (KVM_CAP_S390_VSIE_ESAMODE).
+ *
+ * Guest 2 runs a guest 3 from a state description without the
+ * z/Architecture flag. Such a state description has the eight-byte ESA/390
+ * PSW in the first doubleword of the PSW field. vsie rewinds the PSW of
+ * guest 3 when it has to repeat an instruction; the test uses STORE FACILITY
+ * LIST EXTENDED, which vsie repeats after it has shadowed the facility list
+ * guest 2 designates.
+ */
+#include <stdio.h>
+#include <string.h>
+
+#include "kvm_util.h"
+#include "test_util.h"
+#include "kselftest.h"
+#include "sie.h"
+#include "facility.h"
+#include "ucall_common.h"
+
+#define G3_MEM_LEN 0x100000UL
+/* mso/msl have 1MB granularity */
+#define G3_MSO 0x10000000UL
+#define G3_START (2 * 0x1000UL)
+/* where guest 3 stores its facility lists, in its first page */
+#define G3_STFLE_1 0xf00
+#define G3_STFLE_2 0xf80
+
+#define FAC_STFLE 7
+
+/* bit 12 of an ESA/390 PSW is one, bit 32 selects 31-bit addressing */
+#define ESA_PSW_MASK 0x0008000080000000ULL
+#define ESA_PSW_ADDR 0x000000007fffffffULL
+
+/* facility list for guest 3: only the first doubleword is looked at */
+#define G3_FAC_0 0x4000100000000001ULL
+
+static const u8 g3_code[] = {
+ 0xa7, 0x08, 0x00, 0x00, /* lhi %r0,0 */
+ 0xb2, 0xb0, 0x0f, 0x00, /* stfle G3_STFLE_1 */
+ 0xa7, 0x08, 0x00, 0x00, /* lhi %r0,0 */
+ 0xb2, 0xb0, 0x0f, 0x80, /* stfle G3_STFLE_2 */
+ 0x83, 0x00, 0x00, 0x44, /* diag %r0,%r0,0x44 */
+};
+
+static u64 scb_real;
+
+static void guest_code(void)
+{
+ while (1) {
+ asm volatile(" sie 0(%[scb])\n"
+ :
+ : [scb] "a" (scb_real)
+ : "memory", "cc");
+ GUEST_SYNC(0);
+ }
+}
+
+static void get_machine_feat(struct kvm_s390_vm_cpu_feat *feat)
+{
+ struct kvm_vm *vm = vm_create_barebones();
+
+ kvm_device_attr_get(vm->fd, KVM_S390_VM_CPU_MODEL,
+ KVM_S390_VM_CPU_MACHINE_FEAT, feat);
+ kvm_vm_free(vm);
+}
+
+static bool machine_has_sief2(void)
+{
+ struct kvm_s390_vm_cpu_feat feat = {};
+
+ get_machine_feat(&feat);
+ return feat.feat[0] & (1ULL << (63 - KVM_S390_VM_CPU_FEAT_SIEF2));
+}
+
+static bool machine_has_facility(int nr)
+{
+ struct kvm_s390_vm_cpu_processor proc = {};
+ struct kvm_vm *vm = vm_create_barebones();
+ bool ret;
+
+ kvm_device_attr_get(vm->fd, KVM_S390_VM_CPU_MODEL,
+ KVM_S390_VM_CPU_PROCESSOR, &proc);
+ ret = test_bit_inv(nr, (unsigned long *)proc.fac_list);
+ kvm_vm_free(vm);
+ return ret;
+}
+
+int main(int argc, char *argv[])
+{
+ struct kvm_s390_vm_cpu_feat feat = {};
+ struct kvm_s390_sie_block *scb;
+ u64 *g3_page0, *fac_list;
+ struct kvm_vcpu *vcpu;
+ struct kvm_vm *vm;
+ gva_t gva, fac_gva;
+ u64 psw_end;
+ struct ucall uc;
+ void *code;
+ int i;
+
+ TEST_REQUIRE(kvm_has_cap(KVM_CAP_S390_VSIE_ESAMODE));
+ TEST_REQUIRE(machine_has_sief2());
+ TEST_REQUIRE(machine_has_facility(FAC_STFLE));
+
+ ksft_print_header();
+ ksft_set_plan(3);
+
+ /* SIEF2 must be enabled before the first vcpu is created */
+ get_machine_feat(&feat);
+ vm = vm_create(1);
+ kvm_device_attr_set(vm->fd, KVM_S390_VM_CPU_MODEL,
+ KVM_S390_VM_CPU_PROCESSOR_FEAT, &feat);
+ vm_enable_cap(vm, KVM_CAP_S390_VSIE_ESAMODE, 0);
+ vcpu = vm_vcpu_add(vm, 0, guest_code);
+
+ gva = vm_alloc_page(vm);
+ scb = addr_gva2hva(vm, gva);
+ memset(scb, 0, getpagesize());
+ scb_real = addr_gva2gpa(vm, gva);
+ sync_global_to_guest(vm, scb_real);
+
+ fac_gva = vm_alloc_page(vm);
+ fac_list = addr_gva2hva(vm, fac_gva);
+ memset(fac_list, 0, getpagesize());
+ fac_list[0] = G3_FAC_0;
+
+ /* guest 3: two prefix pages and one page of code */
+ for (i = 0; i < 3; i++) {
+ gpa_t gpa = vm_phy_page_alloc(vm, MEM_REGION_TEST_DATA);
+
+ virt_pg_map(vm, G3_MSO + i * getpagesize(), gpa);
+ memset(addr_gpa2hva(vm, gpa), 0, getpagesize());
+ if (i == 0)
+ g3_page0 = addr_gpa2hva(vm, gpa);
+ if (i == 2)
+ code = addr_gpa2hva(vm, gpa);
+ }
+ memcpy(code, g3_code, sizeof(g3_code));
+
+ scb->cpuflags = CPUSTAT_RUNNING;
+ scb->ihcpu = 0xffff;
+ scb->mso = G3_MSO;
+ scb->msl = G3_MSO + ((G3_MEM_LEN - 1) & ~0xfffffUL);
+ scb->psw_mask = ESA_PSW_MASK | G3_START;
+ scb->psw_addr = 0;
+ scb->fac = addr_gva2gpa(vm, fac_gva);
+ TEST_ASSERT(!(scb->fac & 7) && addr_gva2gpa(vm, fac_gva) < (1UL << 31),
+ "facility list not usable for a designation");
+
+ vcpu_run(vcpu);
+ TEST_ASSERT_EQ(get_ucall(vcpu, &uc), UCALL_SYNC);
+ /*
+ * The capability does not tell whether the machine (or the hypervisor
+ * this host is a guest of) runs a state description without the
+ * z/Architecture flag. If not, it answers with validity 0x0001.
+ */
+ if (scb->icptcode == ICPT_VALIDITY && (scb->ipb >> 16) == 0x0001)
+ ksft_exit_skip("the host cannot run nested guests in ESA mode (validity 0x0001)\n");
+ TEST_ASSERT(scb->icptcode == ICPT_INST && scb->ipa == 0x8300,
+ "guest 3: icptcode 0x%02x ipa 0x%04x ipb 0x%08x psw 0x%016llx 0x%016llx",
+ scb->icptcode, scb->ipa, scb->ipb, scb->psw_mask, scb->psw_addr);
+
+ psw_end = ESA_PSW_MASK | (G3_START + sizeof(g3_code));
+ ksft_test_result(scb->psw_addr == 0,
+ "second PSW doubleword of the ESA mode guest untouched (0x%llx)\n",
+ scb->psw_addr);
+ ksft_test_result((scb->psw_mask & ~0x0000300000000000ULL) == psw_end,
+ "ESA/390 PSW after the last instruction (0x%llx)\n",
+ scb->psw_mask);
+ ksft_print_msg("second STFLE stored 0x%lx\n",
+ g3_page0[G3_STFLE_2 / sizeof(u64)]);
+ ksft_test_result(g3_page0[G3_STFLE_1 / sizeof(u64)] == G3_FAC_0,
+ "first STFLE of the ESA mode guest executed (0x%lx)\n",
+ g3_page0[G3_STFLE_1 / sizeof(u64)]);
+
+ kvm_vm_free(vm);
+ ksft_finished();
+}
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format
2026-11-25 15:16 ` [PATCH 1/2] KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format Yvan Janssens
@ 2026-11-25 16:19 ` Janosch Frank
0 siblings, 0 replies; 4+ messages in thread
From: Janosch Frank @ 2026-11-25 16:19 UTC (permalink / raw)
To: Yvan Janssens, Christian Borntraeger, Claudio Imbrenda
Cc: David Hildenbrand, Eric Farman, Hendrik Brueckner,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
Paolo Bonzini, Sean Christopherson, Shuah Khan, kvm, linux-s390,
linux-kselftest, linux-kernel
On 11/25/26 4:16 PM, Yvan Janssens wrote:
> A state description without the z/Architecture flag holds the eight-byte
> ESA/390 PSW in the first doubleword of its PSW field: the addressing mode
> is bit 32 and the instruction address is in bits 33-63 of that doubleword
> (Principles of Operation, "Program-Status Word" as it applies in the
> ESA/390-compatibility mode). The second doubleword is not part of the
> PSW.
>
> Since nested guests can be run in ESA mode, vsie still rewinds the PSW of
> their shadow state description as if it were a z/Architecture PSW. It
> subtracts the instruction length from the second doubleword, which leaves
> the instruction address alone and stores a wrapped address there
> (0x7ffffffc for one four-byte instruction). The value is copied back into
> the state description of guest 2 when the shadow is released.
>
> The rewind is how vsie repeats an instruction: STORE FACILITY LIST
> EXTENDED after the facility list that guest 2 designates has been
> shadowed (handle_stfle()), MOVE PAGE after a fault was resolved
> (vsie_handle_mvpg()), and the instruction that is reported with an
> addressing exception when guest 3 touches memory guest 2 does not have.
> For a guest in ESA mode the instruction is skipped instead. The first
> STORE FACILITY LIST EXTENDED after every entry into SIE returns with its
> operand and the condition code untouched, so a program in the nested
> guest that looks at the facility list sees zeros.
>
> Rewind the instruction address where the format of the state description
> has it.
>
> The selftest in the next patch reproduces the problem: on 7.3.6 the
> second doubleword of the PSW field comes back as 0x7ffffff8 after two
I'm wondering if we should only copy the a DWORD back to the guest for
the PSW in ESA mode and not the long PSW. On the other hand I'd like to
have as little ESA accommodations in this code as possible. Sigh.
> skipped instructions and the nested guest never stores a facility list.
While I do appreciate documentation of what a patch changes and why it
changes it, I don't like lengthy explanations of basic concepts.
Please take the time to write this yourself if it's not 100% trivial.
This helps me to decide if you actually understood the changes that
you're proposing. Especially when you change obscure stuff like this :)
I'd suggest something like:
Basic ESA mode support for vsie was introduced with b0ad874d9852.
Such guests use the 8 byte short PSW instead of the 16 byte zArch PSW.
This means that the mask and the address have to share the same DWORD.
Unfortunately the vsie code does not consider this when rewinding the
PSW address in the shadow scb and manipulates the (unused) second DWORD
instead of the first. This patch adds a vsie specific rewind function to
address that.
Since vsie only provides basic ESA support I'm not adding a short PSW
and we make do with writing mask and address into the same PSW mask field.
Code seems fine.
>
> Fixes: b0ad874d9852 ("KVM: s390: vsie: Allow non-zarch guests")
> Cc: stable@vger.kernel.org # 7.1+
> Assisted-by: Claude:claude-fable-5-2
> Signed-off-by: Yvan Janssens <yvanj@cyber.gent>
> ---
> arch/s390/kvm/s390/vsie.c | 23 +++++++++++++++++++++--
> 1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/arch/s390/kvm/s390/vsie.c b/arch/s390/kvm/s390/vsie.c
> index 3ce133f20fa2..58afe913bff4 100644
> --- a/arch/s390/kvm/s390/vsie.c
> +++ b/arch/s390/kvm/s390/vsie.c
> @@ -948,6 +948,25 @@ static inline void clear_vsie_icpt(struct vsie_page *vsie_page)
> vsie_page->scb_s.icptcode = 0;
> }
>
> +/*
> + * Rewind the PSW of a shadow scb. An ESA mode guest has the eight-byte
> + * ESA/390 PSW in the first doubleword of the PSW field: the addressing mode
> + * in bit 32 and the instruction address in bits 33-63. The second doubleword
> + * is not part of its PSW.
> + */
Please remove this comment it suffers from the same problem that the
commit message has.
> +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;
> + }
Please add a short comment that this is for the esa short psw and that's
why everything is written to the 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 +979,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 +1432,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;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-25 16:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 15:16 [PATCH 0/2] KVM: s390: vsie: fix instruction retry for nested guests in ESA mode Yvan Janssens
2026-11-25 15:16 ` [PATCH 1/2] KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format Yvan Janssens
2026-11-25 16:19 ` Janosch Frank
2026-11-25 15:16 ` [PATCH 2/2] KVM: s390: selftests: Add a test for nested guests in ESA mode Yvan Janssens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®