Re: [kvm-unit-tests PATCH] s390x: Add strict mode to specification exception interpretation test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25/11/2021 15.47, Janis Schoetterl-Glausch wrote:
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.

Thank you very much for adding this!

Some comments below...

`--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@xxxxxxxxxxxxx>
---

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;

Could you please move the variable declaration to the beginning of the function? Then you could get rid of the curly brackets and one level of indentation.

+		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;

I think this works ok with out current implementation of argv, but that's an "inofficial" implementation detail, so in case this ever gets changed, it might be better to check argc first before dereferencing argv here ... so could you please add a check for argc, too?

+	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;

You could also support --strict without arguments - that could turn on the strict mode unconditionally, I think.

+	}
+	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();
  }


 Thomas




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux