From: Christoph Schlameuss <schlameuss@linux.ibm.com>
To: linux-s390@vger.kernel.org
Cc: "Janosch Frank" <frankja@linux.ibm.com>,
"Claudio Imbrenda" <imbrenda@linux.ibm.com>,
"Nico Böhr" <nrb@linux.ibm.com>,
"David Hildenbrand" <david@kernel.org>,
"Thomas Huth" <thuth@redhat.com>,
kvm@vger.kernel.org,
"Christoph Schlameuss" <schlameuss@linux.ibm.com>,
"Nina Schoetterl-Glausch" <nsg@linux.ibm.com>
Subject: [kvm-unit-tests PATCH v3 6/6] s390x: Add test for STFLE interpretive execution (format-2)
Date: Tue, 21 Apr 2026 13:31:12 +0200 [thread overview]
Message-ID: <20260421-vsie-stfle-fac-v3-6-3cee84efefa3@linux.ibm.com> (raw)
In-Reply-To: <20260421-vsie-stfle-fac-v3-0-3cee84efefa3@linux.ibm.com>
The STFLE instruction indicates installed facilities.
SIE has facilities for the interpretive execution of STFLE.
There are multiple possible formats for the control block.
Use a snippet guest executing STFLE to get the result of
interpretive execution and check the result.
With the addition of the format-2 control block invalid format
specifiers are now possible.
Test for the occurrence of optional validity intercepts.
Move prefixes into main method to improve the readability of the
log by having prefixes for reports by tests called from multiple
places.
Co-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
---
lib/s390x/sie.c | 11 +++++++++
lib/s390x/sie.h | 1 +
s390x/stfle-sie.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 79 insertions(+), 5 deletions(-)
diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c
index 0fa915cf028a..17f0ef7eff42 100644
--- a/lib/s390x/sie.c
+++ b/lib/s390x/sie.c
@@ -42,6 +42,17 @@ void sie_check_validity(struct vm *vm, uint16_t vir_exp)
report(vir_exp == vir, "VALIDITY: %x", vir);
}
+void sie_check_optional_validity(struct vm *vm, uint16_t vir_exp)
+{
+ uint16_t vir = sie_get_validity(vm);
+
+ if (vir == 0xffff)
+ report_pass("optional VALIDITY: no");
+ else
+ report(vir_exp == vir, "optional VALIDITY: %x", vir);
+ vm->validity_expected = false;
+}
+
void sie_handle_validity(struct vm *vm)
{
if (vm->sblk->icptcode != ICPT_VALIDITY)
diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h
index 3ec49ed0da64..8bea0b10b0a6 100644
--- a/lib/s390x/sie.h
+++ b/lib/s390x/sie.h
@@ -51,6 +51,7 @@ void sie(struct vm *vm);
void sie_expect_validity(struct vm *vm);
uint16_t sie_get_validity(struct vm *vm);
void sie_check_validity(struct vm *vm, uint16_t vir_exp);
+void sie_check_optional_validity(struct vm *vm, uint16_t vir_exp);
void sie_handle_validity(struct vm *vm);
static inline bool sie_is_pv(struct vm *vm)
diff --git a/s390x/stfle-sie.c b/s390x/stfle-sie.c
index 21cf8ff8b6f6..e3ed22ee536e 100644
--- a/s390x/stfle-sie.c
+++ b/s390x/stfle-sie.c
@@ -42,6 +42,7 @@ static struct guest_stfle_res run_guest(void)
uint64_t guest_stfle_addr;
uint64_t reg;
+ reset_guest(&vm);
sie(&vm);
assert(snippet_is_force_exit_value(&vm));
guest_stfle_addr = snippet_get_force_exit_value(&vm);
@@ -56,7 +57,6 @@ static void test_stfle_format_0(void)
{
struct guest_stfle_res res;
- report_prefix_push("format-0");
for (int j = 0; j < stfle_size(); j++)
WRITE_ONCE((*fac)[j], prng64(&prng_s));
vm.sblk->fac = (uint32_t)(uint64_t)fac;
@@ -64,6 +64,47 @@ static void test_stfle_format_0(void)
report(res.len == stfle_size(), "stfle len correct");
report(!memcmp(*fac, res.mem, res.len * sizeof(uint64_t)),
"Guest facility list as specified");
+}
+
+static void test_stfle_format_2(void)
+{
+ const int max_stfle_len = 8;
+ int guest_max_stfle_len = 0;
+ struct guest_stfle_res res;
+ bool saturated = false;
+
+ for (int i = 1; i <= max_stfle_len; i++) {
+ report_prefix_pushf("max STFLE len %d", i);
+
+ WRITE_ONCE((*fac)[0], i - 1);
+ for (int j = 0; j < i; j++)
+ WRITE_ONCE((*fac)[j + 1], prng64(&prng_s));
+ vm.sblk->fac = (uint32_t)(uint64_t)fac | 2;
+ res = run_guest();
+ /* len increases up to maximum (machine specific) */
+ if (res.len < i)
+ saturated = true;
+ if (saturated) {
+ report(res.len == guest_max_stfle_len, "stfle len correct");
+ } else {
+ report(res.len == i, "stfle len correct");
+ guest_max_stfle_len = i;
+ }
+ report(!memcmp(&(*fac)[1], res.mem, guest_max_stfle_len * sizeof(uint64_t)),
+ "Guest facility list as specified");
+
+ report_prefix_pop();
+ }
+}
+
+static void test_no_stfle_format(int format)
+{
+ report_prefix_pushf("no-stfle");
+ reset_guest(&vm);
+ vm.sblk->fac = (uint32_t)(uint64_t)fac | format;
+ sie_expect_validity(&vm);
+ sie(&vm);
+ sie_check_optional_validity(&vm, 0x1330);
report_prefix_pop();
}
@@ -119,20 +160,41 @@ static struct args parse_args(int argc, char **argv)
int main(int argc, char **argv)
{
struct args args = parse_args(argc, argv);
- bool run_format_0 = test_facility(7);
if (!sclp_facilities.has_sief2) {
report_skip("SIEF2 facility unavailable");
goto out;
}
- if (!run_format_0)
+ if (!test_facility(7)) {
report_skip("STFLE facility not available");
+ goto out;
+ }
report_info("PRNG seed: 0x%lx", args.seed);
prng_s = prng_init(args.seed);
setup_guest();
- if (run_format_0)
- test_stfle_format_0();
+ report_prefix_pushf("format-0");
+ test_stfle_format_0();
+ report_prefix_pop();
+
+ report_prefix_pushf("format-1");
+ if (!sclp_facilities.has_astfleie1)
+ test_no_stfle_format(1);
+ report_prefix_pop();
+
+ report_prefix_pushf("format-2");
+ if (!sclp_facilities.has_astfleie2) {
+ test_no_stfle_format(2);
+ report_skip("alternate STFLE interpretive-execution facility 2 not available");
+ } else {
+ test_stfle_format_2();
+ }
+ report_prefix_pop();
+
+ report_prefix_pushf("format-3");
+ test_no_stfle_format(3);
+ report_prefix_pop();
+
out:
return report_summary();
}
--
2.53.0
prev parent reply other threads:[~2026-04-21 11:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 11:31 [kvm-unit-tests PATCH v3 0/6] s390x: Add test for STFLE interpretive execution (format-2) Christoph Schlameuss
2026-04-21 11:31 ` [kvm-unit-tests PATCH v3 1/6] s390x: snippets: Add reset_guest() to lib Christoph Schlameuss
2026-04-21 11:31 ` [kvm-unit-tests PATCH v3 2/6] s390x: sclp: Remove unnecessary padding from struct sclp_facilities Christoph Schlameuss
2026-04-21 11:31 ` [kvm-unit-tests PATCH v3 3/6] s390x: sclp: Rework sclp_facilities_setup() for simpler control flow Christoph Schlameuss
2026-04-21 11:31 ` [kvm-unit-tests PATCH v3 4/6] s390x: sclp: Use sclp_feat_check directly to read DIAG318 feature bit Christoph Schlameuss
2026-04-21 11:31 ` [kvm-unit-tests PATCH v3 5/6] s390x: sclp: Add detection of alternate STFLE facilities Christoph Schlameuss
2026-04-21 11:31 ` Christoph Schlameuss [this message]
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=20260421-vsie-stfle-fac-v3-6-3cee84efefa3@linux.ibm.com \
--to=schlameuss@linux.ibm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nrb@linux.ibm.com \
--cc=nsg@linux.ibm.com \
--cc=thuth@redhat.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