mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yvan Janssens <yvanj@cyber.gent>
To: Christian Borntraeger <borntraeger@linux.ibm.com>,
	Janosch Frank <frankja@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: [PATCH 0/2] KVM: s390: vsie: fix instruction retry for nested guests in ESA mode
Date: Wed, 25 Nov 2026 16:16:05 +0100	[thread overview]
Message-ID: <20261125151607.3039477-1-yvanj@cyber.gent> (raw)

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



             reply	other threads:[~2026-11-25 15:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 15:16 Yvan Janssens [this message]
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

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=20261125151607.3039477-1-yvanj@cyber.gent \
    --to=yvanj@cyber.gent \
    --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=frankja@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 \
    /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®