From: Janosch Frank <frankja@linux.ibm.com>
To: Yvan Janssens <yvanj@cyber.gent>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: David Hildenbrand <david@kernel.org>,
Eric Farman <farman@linux.ibm.com>,
Hendrik Brueckner <brueckner@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Shuah Khan <shuah@kernel.org>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format
Date: Wed, 25 Nov 2026 17:19:35 +0100 [thread overview]
Message-ID: <f64f9cd9-e2c9-4821-9d37-6c6ecdcb5239@linux.ibm.com> (raw)
In-Reply-To: <20261125151607.3039477-2-yvanj@cyber.gent>
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;
next prev parent reply other threads:[~2026-11-25 16:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-11-25 15:16 ` [PATCH 2/2] KVM: s390: selftests: Add a test for nested guests in ESA mode Yvan Janssens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f64f9cd9-e2c9-4821-9d37-6c6ecdcb5239@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=brueckner@linux.ibm.com \
--cc=david@kernel.org \
--cc=farman@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=svens@linux.ibm.com \
--cc=yvanj@cyber.gent \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®