All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: Janis Schoetterl-Glausch <scgl@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [kvm-unit-tests PATCH] s390x: Add strict mode to specification exception interpretation test
Date: Thu, 25 Nov 2021 15:47:26 +0100	[thread overview]
Message-ID: <20211125144726.1414645-1-scgl@linux.ibm.com> (raw)
In-Reply-To: <82750b44-6246-3f3c-4562-3d64d7378448@redhat.com>

While specification exception interpretation is not required to occur,
it can be useful for automatic regression testing to fail the test if it
does not occur.
Add a `--strict` argument to enable this.
`--strict` takes a list of machine types (as reported by STIDP)
for which to enable strict mode, for example
`--strict 8562,8561,3907,3906,2965,2964`
will enable it for models z15 - z13.
Alternatively, strict mode can be enabled for all but the listed machine
types by prefixing the list with a `!`, for example
`--strict !1090,1091,2064,2066,2084,2086,2094,2096,2097,2098,2817,2818,2827,2828`
will enable it for z/Architecture models except those older than z13.

Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
---

Apparently my message with inline patch did not make it to the mailing
list for some reason, so here's the patch again.

 s390x/spec_ex-sie.c | 59 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 53 insertions(+), 6 deletions(-)

diff --git a/s390x/spec_ex-sie.c b/s390x/spec_ex-sie.c
index 5dea411..9a063f9 100644
--- a/s390x/spec_ex-sie.c
+++ b/s390x/spec_ex-sie.c
@@ -7,6 +7,7 @@
  * specification exception interpretation is off/on.
  */
 #include <libcflat.h>
+#include <stdlib.h>
 #include <sclp.h>
 #include <asm/page.h>
 #include <asm/arch_def.h>
@@ -36,7 +37,7 @@ static void reset_guest(void)
 	vm.sblk->icptcode = 0;
 }
 
-static void test_spec_ex_sie(void)
+static void test_spec_ex_sie(bool strict)
 {
 	setup_guest();
 
@@ -61,14 +62,60 @@ static void test_spec_ex_sie(void)
 	report(vm.sblk->icptcode == ICPT_PROGI
 	       && vm.sblk->iprcc == PGM_INT_CODE_SPECIFICATION,
 	       "Received specification exception intercept");
-	if (vm.sblk->gpsw.addr == 0xdeadbeee)
-		report_info("Interpreted initial exception, intercepted invalid program new PSW exception");
-	else
-		report_info("Did not interpret initial exception");
+	{
+		const char *msg;
+
+		msg = "Interpreted initial exception, intercepted invalid program new PSW exception";
+		if (strict)
+			report(vm.sblk->gpsw.addr == 0xdeadbeee, msg);
+		else if (vm.sblk->gpsw.addr == 0xdeadbeee)
+			report_info(msg);
+		else
+			report_info("Did not interpret initial exception");
+	}
 	report_prefix_pop();
 	report_prefix_pop();
 }
 
+static bool parse_strict(char **argv)
+{
+	uint16_t machine_id;
+	char *list;
+	bool ret;
+
+	if (!*argv)
+		return false;
+	if (strcmp("--strict", *argv))
+		return false;
+
+	machine_id = get_machine_id();
+	list = argv[1];
+	if (!list) {
+		printf("No argument to --strict, ignoring\n");
+		return false;
+	}
+	if (list[0] == '!') {
+		ret = true;
+		list++;
+	} else
+		ret = false;
+	while (true) {
+		long input = 0;
+
+		if (strlen(list) == 0)
+			return ret;
+		input = strtol(list, &list, 16);
+		if (*list == ',')
+			list++;
+		else if (*list != '\0')
+			break;
+		if (input == machine_id)
+			return !ret;
+	}
+	printf("Invalid --strict argument \"%s\", ignoring\n", list);
+	return ret;
+}
+
 int main(int argc, char **argv)
 {
 	if (!sclp_facilities.has_sief2) {
@@ -76,7 +123,7 @@ int main(int argc, char **argv)
 		goto out;
 	}
 
-	test_spec_ex_sie();
+	test_spec_ex_sie(parse_strict(argv + 1));
 out:
 	return report_summary();
 }
-- 
2.31.1


  parent reply	other threads:[~2021-11-25 14:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22 13:10 [kvm-unit-tests PATCH v3 0/1] Test spec exception interception Janis Schoetterl-Glausch
2021-10-22 13:10 ` [kvm-unit-tests PATCH v3 1/1] s390x: Add specification exception interception test Janis Schoetterl-Glausch
2021-10-25 12:25   ` Thomas Huth
2021-11-11  7:47   ` Thomas Huth
2021-11-16 11:57     ` Janis Schoetterl-Glausch
2021-11-25 14:47     ` Janis Schoetterl-Glausch [this message]
2021-12-03 11:15       ` [kvm-unit-tests PATCH] s390x: Add strict mode to specification exception interpretation test Thomas Huth
2021-12-03 11:46         ` Janis Schoetterl-Glausch
2022-02-25 17:23 Janis Schoetterl-Glausch
2022-02-28 13:27 ` Claudio Imbrenda
2022-03-03  9:43   ` Janis Schoetterl-Glausch

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=20211125144726.1414645-1-scgl@linux.ibm.com \
    --to=scgl@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.