From: Janosch Frank <frankja@linux.ibm.com>
To: pbonzini@redhat.com
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com,
borntraeger@linux.ibm.com, linux-s390@vger.kernel.org,
imbrenda@linux.ibm.com, thuth@redhat.com,
Christoph Schlameuss <schlameuss@linux.ibm.com>,
Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Subject: [kvm-unit-tests GIT PULL 10/13] s390x: Add test for STFLE interpretive execution (format-2)
Date: Mon, 24 Aug 2026 14:35:42 +0000 [thread overview]
Message-ID: <20260824143740.291583-11-frankja@linux.ibm.com> (raw)
In-Reply-To: <20260824143740.291583-1-frankja@linux.ibm.com>
From: Christoph Schlameuss <schlameuss@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>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@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 ad1f2ade..99089dc3 100644
--- a/lib/s390x/sie.c
+++ b/lib/s390x/sie.c
@@ -43,6 +43,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 85d691d5..e5970f36 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 8df1185c..3697e1ae 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();
snippet_destroy_guest(&vm);
out:
--
2.53.0
next prev parent reply other threads:[~2026-08-24 14:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 14:35 [kvm-unit-tests GIT PULL 00/13] s390x: stflei test, fixes and sie lib rework Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 01/13] lib: s390x: Add function to get page root Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 02/13] lib: s390x: sie: Allocate physical guest memory via memalign Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 03/13] lib: s390x: sie: Memory rework Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 04/13] lib: s390x: snippet: Add function to create a guest of specific length Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 05/13] s390x: snippets: Add reset_guest() to lib Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 06/13] s390x: sclp: Remove unnecessary padding from struct sclp_facilities Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 07/13] s390x: sclp: Check sclp byte before reading feature bits Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 08/13] s390x: sclp: Use sclp_feat_check directly to read DIAG318 feature bit Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 09/13] s390x: sclp: Add detection of alternate STFLE facilities Janosch Frank
2026-08-24 14:35 ` Janosch Frank [this message]
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 11/13] s390x: stsi: regression test for the STSI 3.2.2 count clamp Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 12/13] s390x: unittests: Reenable tcg for migration tests Janosch Frank
2026-08-24 14:35 ` [kvm-unit-tests GIT PULL 13/13] s390x: skey: Fence TCG protection checks Janosch Frank
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=20260824143740.291583-11-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nsg@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=schlameuss@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