From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Yvan Janssens <yvanj@cyber.gent>,
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: Re: [PATCH v2 2/2] KVM: s390: selftests: Add a test for nested guests in ESA mode
Date: Thu, 26 Nov 2026 10:13:43 +0100 [thread overview]
Message-ID: <d19de976-aa6c-4168-856d-b65e96eabe88@linux.ibm.com> (raw)
In-Reply-To: <20261125165604.3074595-3-yvanj@cyber.gent>
Am 25.11.26 um 17:56 schrieb Yvan Janssens:
> 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.
>
> 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
unused but probably ok to keep in.
> +
> +/* 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");
The guest touches r0, so we probably should add that to the clobber list when applying.
Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
next prev parent reply other threads:[~2026-11-26 9:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 16:56 [PATCH v2 0/2] KVM: s390: vsie: fix instruction retry for nested guests in ESA mode Yvan Janssens
2026-11-25 16:56 ` [PATCH v2 1/2] KVM: s390: vsie: Rewind the PSW of ESA mode guests in the right format Yvan Janssens
2026-11-26 8:32 ` Christian Borntraeger
2026-11-26 12:35 ` Janosch Frank
2026-11-25 16:56 ` [PATCH v2 2/2] KVM: s390: selftests: Add a test for nested guests in ESA mode Yvan Janssens
2026-11-26 9:13 ` Christian Borntraeger [this message]
2026-11-26 14:37 ` Claudio Imbrenda
2026-11-25 17:05 ` [PATCH v2 0/2] KVM: s390: vsie: fix instruction retry " sashiko-bot
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=d19de976-aa6c-4168-856d-b65e96eabe88@linux.ibm.com \
--to=borntraeger@linux.ibm.com \
--cc=agordeev@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 \
--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