All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors
@ 2021-04-06  7:40 Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 01/16] s390x: lib: css: disabling a subchannel Pierre Morel
                   ` (16 more replies)
  0 siblings, 17 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

The goal of this series is to test some of the I/O instructions,
SSCH, CSCH and HSCH for errors like invalid parameters, addressing,
timing etc.
We can not test the sending of an instruction before the last instruction
has been proceeded by QEMU due to the QEMU serialization but we can 
check the behavior of an instruction if it is started before the status
of the last instruction is read.

To do this we first separate the waiting for the interruption and the
checking of the IRB and enable the subchannel without an I/O ISC to
avoid interruptions at this subchannel and second, we add an argument
to the routine in charge to check the IRB representing the expected
SCSW control field of the IRB.

We also need several other enhancements to the testing environment:

- definitions for the SCSW control bits
- a new function to disable a subchannel
- a macro to simplify skiping tests when no device is present
  (I know the warning about return in macro, can we accept it?)

In the new tests we assume that all the test preparation is working and
use asserts for all function for which we do not expect a failure.

regards,
Pierre

PS: Sorry, I needed to modify patches 4 and 5 for which I already had RB or AB.
    I removed them even I hope you will agree with my modifications.


Pierre Morel (16):
  s390x: lib: css: disabling a subchannel
  s390x: lib: css: SCSW bit definitions
  s390x: css: simplify skipping tests on no device
  s390x: lib: css: separate wait for IRQ and check I/O completion
  s390x: lib: css: add SCSW ctrl expectations to check I/O completion
  s390x: lib: css: checking I/O errors
  s390x: css: testing ssch errors
  s390x: css: ssch check for cpa zero
  s390x: css: ssch with mis aligned ORB
  s390x: css: ssch checking addressing errors
  s390x: css: No support for MIDAW
  s390x: css: Check ORB reserved bits
  s390x: css: checking for CSS extensions
  s390x: css: issuing SSCH when the channel is status pending
  s390x: css: testing halt subchannel
  s390x: css: testing clear subchannel

 lib/s390x/css.h     |  42 ++++-
 lib/s390x/css_lib.c | 138 ++++++++++++--
 s390x/css.c         | 425 +++++++++++++++++++++++++++++++++++++++++---
 s390x/unittests.cfg |   8 +-
 4 files changed, 565 insertions(+), 48 deletions(-)

-- 
2.17.1

log:

from v2:

- modified the patch 3 simplifying the check for no device
  to move the check once for all in the main
  (Thomas)

- modified the patch 4 separate wait for IRQ..
  to move the check for IRQ parameters inside the IRQ routine
  (Pierre)

- modified the patch 5 checking for expectations on I/O
  to return with success if the expectation is matched without
  further checks.
  (Pierre)

- rewords patch 5 commet and commit message
  (Connie)

- reworked patches on SSCH addressing memory
  (Claudio)


from v1:

- rework the buggy interrupt handling
  (Connie)

- identation and comments changes in "disabling subchannel"
  (Janosch)

- Bit definition naming
  (Connie)

- use get_ram_size() to get the maximal address
  (Janosch)

- better comments for SSCH (hopefully)
  (Pierre)

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 01/16] s390x: lib: css: disabling a subchannel
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 02/16] s390x: lib: css: SCSW bit definitions Pierre Morel
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

Some tests require to disable a subchannel.
Let's implement the css_disable() function.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
---
 lib/s390x/css.h     |  1 +
 lib/s390x/css_lib.c | 63 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index 7e3d261..b0de3a3 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -284,6 +284,7 @@ int css_enumerate(void);
 #define IO_SCH_ISC      3
 int css_enable(int schid, int isc);
 bool css_enabled(int schid);
+int css_disable(int schid);
 
 /* Library functions */
 int start_ccw1_chain(unsigned int sid, struct ccw1 *ccw);
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index efc7057..9711b0b 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -186,6 +186,69 @@ bool css_enabled(int schid)
 	}
 	return true;
 }
+
+/*
+ * css_disable: disable the subchannel
+ * @schid: Subchannel Identifier
+ * Return value:
+ *   On success: 0
+ *   On error the CC of the faulty instruction
+ *      or -1 if the retry count is exceeded.
+ */
+int css_disable(int schid)
+{
+	struct pmcw *pmcw = &schib.pmcw;
+	int retries = 0;
+	int cc;
+
+	/* Read the SCHIB for this subchannel */
+	cc = stsch(schid, &schib);
+	if (cc) {
+		report_info("stsch: sch %08x failed with cc=%d", schid, cc);
+		return cc;
+	}
+
+	if (!(pmcw->flags & PMCW_ENABLE)) {
+		report_info("stsch: sch %08x already disabled", schid);
+		return 0;
+	}
+
+	for (retries = 0; retries < MAX_ENABLE_RETRIES; retries++) {
+		/* Update the SCHIB to disable the subchannel */
+		pmcw->flags &= ~PMCW_ENABLE;
+
+		/* Tell the CSS we want to modify the subchannel */
+		cc = msch(schid, &schib);
+		/*
+		 * If the subchannel is status pending or if a function is in progress,
+		 * we consider both cases as errors.
+		 */
+		if (cc) {
+			report_info("msch: sch %08x failed with cc=%d", schid, cc);
+			return cc;
+		}
+
+		/* Read the SCHIB again to verify the disablement */
+		cc = stsch(schid, &schib);
+		if (cc) {
+			report_info("stsch: updating sch %08x failed with cc=%d", schid, cc);
+			return cc;
+		}
+
+		if (!(pmcw->flags & PMCW_ENABLE)) {
+			if (retries)
+				report_info("stsch: sch %08x successfully disabled after %d retries", schid, retries);
+			return 0;
+		}
+
+		/* the hardware was not ready, give it some time */
+		mdelay(10);
+	}
+
+	report_info("msch: modifying sch %08x failed after %d retries. pmcw flags: %04x",
+		    schid, retries, pmcw->flags);
+	return -1;
+}
 /*
  * css_enable: enable the subchannel with the specified ISC
  * @schid: Subchannel Identifier
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 02/16] s390x: lib: css: SCSW bit definitions
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 01/16] s390x: lib: css: disabling a subchannel Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 03/16] s390x: css: simplify skipping tests on no device Pierre Morel
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

We need the SCSW definitions to test clear and halt subchannel.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
 lib/s390x/css.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index b0de3a3..0058355 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -67,6 +67,29 @@ struct scsw {
 #define SCSW_SC_PRIMARY		0x00000004
 #define SCSW_SC_INTERMEDIATE	0x00000008
 #define SCSW_SC_ALERT		0x00000010
+#define SCSW_AC_SUSPENDED	0x00000020
+#define SCSW_AC_DEVICE_ACTIVE	0x00000040
+#define SCSW_AC_SUBCH_ACTIVE	0x00000080
+#define SCSW_AC_CLEAR_PEND	0x00000100
+#define SCSW_AC_HALT_PEND	0x00000200
+#define SCSW_AC_START_PEND	0x00000400
+#define SCSW_AC_RESUME_PEND	0x00000800
+#define SCSW_FC_CLEAR		0x00001000
+#define SCSW_FC_HALT		0x00002000
+#define SCSW_FC_START		0x00004000
+#define SCSW_QDIO_RESERVED	0x00008000
+#define SCSW_PATH_NON_OP	0x00010000
+#define SCSW_EXTENDED_CTRL	0x00020000
+#define SCSW_ZERO_COND		0x00040000
+#define SCSW_SUPPRESS_SUSP_INT	0x00080000
+#define SCSW_IRB_FMT_CTRL	0x00100000
+#define SCSW_INITIAL_IRQ_STATUS	0x00200000
+#define SCSW_PREFETCH		0x00400000
+#define SCSW_CCW_FORMAT		0x00800000
+#define SCSW_DEFERED_CC		0x03000000
+#define SCSW_ESW_FORMAT		0x04000000
+#define SCSW_SUSPEND_CTRL	0x08000000
+#define SCSW_KEY		0xf0000000
 	uint32_t ctrl;
 	uint32_t ccw_addr;
 #define SCSW_DEVS_DEV_END	0x04
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 03/16] s390x: css: simplify skipping tests on no device
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 01/16] s390x: lib: css: disabling a subchannel Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 02/16] s390x: lib: css: SCSW bit definitions Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06 12:44   ` Cornelia Huck
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 04/16] s390x: lib: css: separate wait for IRQ and check I/O completion Pierre Morel
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

We will have to test if a device is present for every tests
in the future.
Let's provide separate the first tests from the test loop and
skip the remaining tests if no device is present.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 s390x/css.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/s390x/css.c b/s390x/css.c
index c340c53..17a6e1d 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -41,11 +41,6 @@ static void test_enable(void)
 {
 	int cc;
 
-	if (!test_device_sid) {
-		report_skip("No device");
-		return;
-	}
-
 	cc = css_enable(test_device_sid, IO_SCH_ISC);
 
 	report(cc == 0, "Enable subchannel %08x", test_device_sid);
@@ -62,11 +57,6 @@ static void test_sense(void)
 	int ret;
 	int len;
 
-	if (!test_device_sid) {
-		report_skip("No device");
-		return;
-	}
-
 	ret = css_enable(test_device_sid, IO_SCH_ISC);
 	if (ret) {
 		report(0, "Could not enable the subchannel: %08x",
@@ -218,11 +208,6 @@ static void test_schm_fmt0(void)
 	struct measurement_block_format0 *mb0;
 	int shared_mb_size = 2 * sizeof(struct measurement_block_format0);
 
-	if (!test_device_sid) {
-		report_skip("No device");
-		return;
-	}
-
 	/* Allocate zeroed Measurement block */
 	mb0 = alloc_io_mem(shared_mb_size, 0);
 	if (!mb0) {
@@ -289,11 +274,6 @@ static void test_schm_fmt1(void)
 {
 	struct measurement_block_format1 *mb1;
 
-	if (!test_device_sid) {
-		report_skip("No device");
-		return;
-	}
-
 	if (!css_test_general_feature(CSSC_EXTENDED_MEASUREMENT_BLOCK)) {
 		report_skip("Extended measurement block not available");
 		return;
@@ -336,8 +316,6 @@ static struct {
 	void (*func)(void);
 } tests[] = {
 	/* The css_init test is needed to initialize the CSS Characteristics */
-	{ "initialize CSS (chsc)", css_init },
-	{ "enumerate (stsch)", test_enumerate },
 	{ "enable (msch)", test_enable },
 	{ "sense (ssch/tsch)", test_sense },
 	{ "measurement block (schm)", test_schm },
@@ -352,11 +330,25 @@ int main(int argc, char *argv[])
 
 	report_prefix_push("Channel Subsystem");
 	enable_io_isc(0x80 >> IO_SCH_ISC);
+
+	report_prefix_push("initialize CSS (chsc)");
+	css_init();
+	report_prefix_pop();
+
+	report_prefix_push("enumerate (stsch)");
+	test_enumerate();
+	report_prefix_pop();
+
+	if (!test_device_sid)
+		goto end;
+
 	for (i = 0; tests[i].name; i++) {
 		report_prefix_push(tests[i].name);
 		tests[i].func();
 		report_prefix_pop();
 	}
+
+end:
 	report_prefix_pop();
 
 	return report_summary();
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 04/16] s390x: lib: css: separate wait for IRQ and check I/O completion
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (2 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 03/16] s390x: css: simplify skipping tests on no device Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 05/16] s390x: lib: css: add SCSW ctrl expectations to " Pierre Morel
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

We will may want to check the result of an I/O without waiting
for an interrupt.
For example because we do not handle interrupt.
Let's separate waiting for interrupt and the I/O completion check.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/css.h     |  1 +
 lib/s390x/css_lib.c | 34 +++++++++++++++++++---------------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index 0058355..5d1e1f0 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -317,6 +317,7 @@ int css_residual_count(unsigned int schid);
 
 void enable_io_isc(uint8_t isc);
 int wait_and_check_io_completion(int schid);
+int check_io_completion(int schid);
 
 /*
  * CHSC definitions
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index 9711b0b..e81076a 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -483,55 +483,59 @@ struct ccw1 *ccw_alloc(int code, void *data, int count, unsigned char flags)
 }
 
 /* wait_and_check_io_completion:
+ * @schid: the subchannel ID
+ */
+int wait_and_check_io_completion(int schid)
+{
+	wait_for_interrupt(PSW_MASK_IO);
+
+	if (lowcore_ptr->io_int_param != schid) {
+		report(0, "interrupt parameter: expected %08x got %08x", schid, lowcore_ptr->io_int_param);
+		return -1;
+	}
+
+	return check_io_completion(schid);
+}
+
+/* check_io_completion:
  * @schid: the subchannel ID
  *
  * Makes the most common check to validate a successful I/O
  * completion.
  * Only report failures.
  */
-int wait_and_check_io_completion(int schid)
+int check_io_completion(int schid)
 {
-	int ret = 0;
-
-	wait_for_interrupt(PSW_MASK_IO);
+	int ret = -1;
 
 	report_prefix_push("check I/O completion");
 
-	if (lowcore_ptr->io_int_param != schid) {
-		report(0, "interrupt parameter: expected %08x got %08x",
-		       schid, lowcore_ptr->io_int_param);
-		ret = -1;
-		goto end;
-	}
-
 	/* Verify that device status is valid */
 	if (!(irb.scsw.ctrl & SCSW_SC_PENDING)) {
 		report(0, "No status pending after interrupt. Subch Ctrl: %08x",
 		       irb.scsw.ctrl);
-		ret = -1;
 		goto end;
 	}
 
 	if (!(irb.scsw.ctrl & (SCSW_SC_SECONDARY | SCSW_SC_PRIMARY))) {
 		report(0, "Primary or secondary status missing. Subch Ctrl: %08x",
 		       irb.scsw.ctrl);
-		ret = -1;
 		goto end;
 	}
 
 	if (!(irb.scsw.dev_stat & (SCSW_DEVS_DEV_END | SCSW_DEVS_SCH_END))) {
 		report(0, "No device end or sch end. Dev. status: %02x",
 		       irb.scsw.dev_stat);
-		ret = -1;
 		goto end;
 	}
 
 	if (irb.scsw.sch_stat & ~SCSW_SCHS_IL) {
 		report_info("Unexpected Subch. status %02x", irb.scsw.sch_stat);
-		ret = -1;
 		goto end;
 	}
 
+	ret = 0;
+
 end:
 	report_prefix_pop();
 	return ret;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 05/16] s390x: lib: css: add SCSW ctrl expectations to check I/O completion
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (3 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 04/16] s390x: lib: css: separate wait for IRQ and check I/O completion Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 06/16] s390x: lib: css: checking I/O errors Pierre Morel
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

When we check for the completion of an I/O, we may need to check
the cause of the interrupt depending on the test case.

Let's make it possible for the tests to check whether the last valid
IRB received indicates the expected functions after executing
an instruction or sequence of instructions and if all ctrl flags
of the SCSW are set as expected.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/css.h     |  4 ++--
 lib/s390x/css_lib.c | 21 ++++++++++++++++-----
 s390x/css.c         |  4 ++--
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index 5d1e1f0..1603781 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -316,8 +316,8 @@ void css_irq_io(void);
 int css_residual_count(unsigned int schid);
 
 void enable_io_isc(uint8_t isc);
-int wait_and_check_io_completion(int schid);
-int check_io_completion(int schid);
+int wait_and_check_io_completion(int schid, uint32_t ctrl);
+int check_io_completion(int schid, uint32_t ctrl);
 
 /*
  * CHSC definitions
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index e81076a..97bf032 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -484,8 +484,9 @@ struct ccw1 *ccw_alloc(int code, void *data, int count, unsigned char flags)
 
 /* wait_and_check_io_completion:
  * @schid: the subchannel ID
+ * @ctrl : expected SCSW control flags
  */
-int wait_and_check_io_completion(int schid)
+int wait_and_check_io_completion(int schid, uint32_t ctrl)
 {
 	wait_for_interrupt(PSW_MASK_IO);
 
@@ -494,22 +495,32 @@ int wait_and_check_io_completion(int schid)
 		return -1;
 	}
 
-	return check_io_completion(schid);
+	return check_io_completion(schid, ctrl);
 }
 
 /* check_io_completion:
  * @schid: the subchannel ID
+ * @ctrl : expected SCSW control flags
  *
- * Makes the most common check to validate a successful I/O
- * completion.
+ * Perform some standard checks to validate a successful I/O completion.
+ * If the ctrl parameter is not zero, additionally verify that the
+ * specified bits are indicated in the IRB SCSW ctrl flags.
  * Only report failures.
  */
-int check_io_completion(int schid)
+int check_io_completion(int schid, uint32_t ctrl)
 {
 	int ret = -1;
 
 	report_prefix_push("check I/O completion");
 
+	if (ctrl) {
+		if (ctrl == irb.scsw.ctrl)
+			ret = 0;
+		else
+			report_info("extected %s != %s", dump_scsw_flags(irb.scsw.ctrl), dump_scsw_flags(ctrl));
+		goto end;
+	}
+
 	/* Verify that device status is valid */
 	if (!(irb.scsw.ctrl & SCSW_SC_PENDING)) {
 		report(0, "No status pending after interrupt. Subch Ctrl: %08x",
diff --git a/s390x/css.c b/s390x/css.c
index 17a6e1d..f4b7af1 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -84,7 +84,7 @@ static void test_sense(void)
 		goto error;
 	}
 
-	if (wait_and_check_io_completion(test_device_sid) < 0)
+	if (wait_and_check_io_completion(test_device_sid, 0) < 0)
 		goto error;
 
 	/* Test transfer completion */
@@ -127,7 +127,7 @@ static void sense_id(void)
 {
 	assert(!start_ccw1_chain(test_device_sid, ccw));
 
-	assert(wait_and_check_io_completion(test_device_sid) >= 0);
+	assert(wait_and_check_io_completion(test_device_sid, 0) >= 0);
 }
 
 static void css_init(void)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 06/16] s390x: lib: css: checking I/O errors
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (4 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 05/16] s390x: lib: css: add SCSW ctrl expectations to " Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 07/16] s390x: css: testing ssch errors Pierre Morel
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

When testing I/O transaction with bad addresses we need to check
the result of the error when the I/O completed with an alert status.
The resulting status is reported in the subchannel and device
status of the IRB SCSW.

Let's provide the tests the possibility to check if the device
and the subchannel status of the IRB SCSW are set as expected.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/css.h     |  6 ++++--
 lib/s390x/css_lib.c | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index 1603781..a5a8427 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -95,8 +95,9 @@ struct scsw {
 #define SCSW_DEVS_DEV_END	0x04
 #define SCSW_DEVS_SCH_END	0x08
 	uint8_t  dev_stat;
-#define SCSW_SCHS_PCI	0x80
-#define SCSW_SCHS_IL	0x40
+#define SCSW_SCHS_PCI		0x80
+#define SCSW_SCHS_IL		0x40
+#define SCSW_SCHS_PRG_CHK	0x20
 	uint8_t  sch_stat;
 	uint16_t count;
 };
@@ -318,6 +319,7 @@ int css_residual_count(unsigned int schid);
 void enable_io_isc(uint8_t isc);
 int wait_and_check_io_completion(int schid, uint32_t ctrl);
 int check_io_completion(int schid, uint32_t ctrl);
+bool check_io_errors(int schid, uint8_t dev_stat, uint8_t sch_stat);
 
 /*
  * CHSC definitions
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index 97bf032..65159aa 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -552,6 +552,30 @@ end:
 	return ret;
 }
 
+/* check_io_errors:
+ * @schid: the subchannel ID
+ * @dev_stat : expected device stat flags
+ * @sch_stat : expected subchannel stat flags
+ *
+ * This routine must be called when an error occurs on CSS I/O
+ * Only report failures information and returns if we found
+ * the expected status flags.
+ */
+bool check_io_errors(int schid, uint8_t dev_stat, uint8_t sch_stat)
+{
+	if (!(irb.scsw.ctrl & SCSW_SC_ALERT)) {
+		report_info("No alert in SCSW Ctrl: %s", dump_scsw_flags(irb.scsw.ctrl));
+		report_info("schid %08x : dev_stat: %02x sch_stat: %02x", schid, irb.scsw.dev_stat, irb.scsw.sch_stat);
+		return false;
+	}
+
+	if ((dev_stat != irb.scsw.dev_stat) || (sch_stat != irb.scsw.sch_stat)) {
+		report_info("schid %08x : dev_stat: %02x sch_stat: %02x", schid, irb.scsw.dev_stat, irb.scsw.sch_stat);
+		return false;
+	}
+	return true;
+}
+
 /*
  * css_residual_count
  * Return the residual count, if it is valid.
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 07/16] s390x: css: testing ssch errors
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (5 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 06/16] s390x: lib: css: checking I/O errors Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 08/16] s390x: css: ssch check for cpa zero Pierre Morel
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

Setup testing environment and check privilege.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 s390x/css.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 68 insertions(+), 4 deletions(-)

diff --git a/s390x/css.c b/s390x/css.c
index f4b7af1..da21ccc 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -15,17 +15,24 @@
 #include <interrupt.h>
 #include <asm/arch_def.h>
 #include <alloc_page.h>
+#include <alloc.h>
 
 #include <malloc_io.h>
 #include <css.h>
 #include <asm/barrier.h>
 
+struct tests {
+	const char *name;
+	void (*func)(void);
+};
+
 #define DEFAULT_CU_TYPE		0x3832 /* virtio-ccw */
 static unsigned long cu_type = DEFAULT_CU_TYPE;
 
 static int test_device_sid;
 static struct senseid *senseid;
 struct ccw1 *ccw;
+struct orb *orb;
 
 static void test_enumerate(void)
 {
@@ -46,6 +53,65 @@ static void test_enable(void)
 	report(cc == 0, "Enable subchannel %08x", test_device_sid);
 }
 
+/* orb_alloc
+ *
+ * We allocate and initialize for all tests:
+ * - the ORB on a global pointer without memory restrictions.
+ * - A CCW and the senseid structures in I/O memory.
+ * Every subtest is responsible to have them modified for their purpose.
+ */
+static void orb_alloc(void)
+{
+	senseid = alloc_io_mem(sizeof(*senseid), 0);
+	assert(senseid);
+
+	ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI);
+	assert(ccw);
+
+	orb = malloc(sizeof(*orb));
+	assert(orb);
+
+	orb->intparm = test_device_sid;
+	orb->ctrl = ORB_CTRL_ISIC | ORB_CTRL_FMT | ORB_LPM_DFLT;
+	orb->cpa = (long)ccw;
+}
+
+static void orb_free(void)
+{
+	free_io_mem(senseid, sizeof(*senseid));
+	free_io_mem(ccw, sizeof(struct ccw1));
+	free(orb);
+}
+
+static void ssch_privilege(void)
+{
+	enter_pstate();
+	expect_pgm_int();
+	ssch(test_device_sid, orb);
+	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
+}
+
+static struct tests ssh_tests[] = {
+	{ "privilege", ssch_privilege },
+	{ NULL, NULL }
+};
+
+static void test_ssch(void)
+{
+	int i;
+
+	orb_alloc();
+	assert(css_enable(test_device_sid, 0) == 0);
+
+	for (i = 0; ssh_tests[i].name; i++) {
+		report_prefix_push(ssh_tests[i].name);
+		ssh_tests[i].func();
+		report_prefix_pop();
+	}
+
+	orb_free();
+}
+
 /*
  * test_sense
  * Pre-requisites:
@@ -311,12 +377,10 @@ static void test_schm_fmt1(void)
 	free_io_mem(mb1, sizeof(struct measurement_block_format1));
 }
 
-static struct {
-	const char *name;
-	void (*func)(void);
-} tests[] = {
+static struct tests tests[] = {
 	/* The css_init test is needed to initialize the CSS Characteristics */
 	{ "enable (msch)", test_enable },
+	{ "start subchannel", test_ssch },
 	{ "sense (ssch/tsch)", test_sense },
 	{ "measurement block (schm)", test_schm },
 	{ "measurement block format0", test_schm_fmt0 },
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 08/16] s390x: css: ssch check for cpa zero
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (6 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 07/16] s390x: css: testing ssch errors Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 09/16] s390x: css: ssch with mis aligned ORB Pierre Morel
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

We expect a CSS program check if the CPA of the ORB is null
and access to the IRB to check it.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/css.h     |  1 +
 lib/s390x/css_lib.c |  4 ++--
 s390x/css.c         | 13 +++++++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index a5a8427..d824e34 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -139,6 +139,7 @@ struct irb {
 	uint32_t ecw[8];
 	uint32_t emw[8];
 } __attribute__ ((aligned(4)));
+extern struct irb irb;
 
 #define CCW_CMD_SENSE_ID	0xe4
 #define CSS_SENSEID_COMMON_LEN	8
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index 65159aa..12ef874 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -21,6 +21,8 @@
 
 struct schib schib;
 struct chsc_scsc *chsc_scsc;
+struct irb irb;
+
 
 static const char * const chsc_rsp_description[] = {
 	"CHSC unknown error",
@@ -411,8 +413,6 @@ bool css_disable_mb(int schid)
 	return retry_count > 0;
 }
 
-static struct irb irb;
-
 void css_irq_io(void)
 {
 	int ret = 0;
diff --git a/s390x/css.c b/s390x/css.c
index da21ccc..d248cac 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -91,8 +91,21 @@ static void ssch_privilege(void)
 	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
 }
 
+static void ssch_orb_cpa_zero(void)
+{
+	uint32_t cpa = orb->cpa;
+
+	orb->cpa = 0;
+	ssch(test_device_sid, orb);
+	tsch(test_device_sid, &irb);
+	report(check_io_errors(test_device_sid, 0, SCSW_SCHS_PRG_CHK), "expecting Program check");
+
+	orb->cpa = cpa;
+}
+
 static struct tests ssh_tests[] = {
 	{ "privilege", ssch_privilege },
+	{ "orb cpa zero", ssch_orb_cpa_zero },
 	{ NULL, NULL }
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 09/16] s390x: css: ssch with mis aligned ORB
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (7 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 08/16] s390x: css: ssch check for cpa zero Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 10/16] s390x: css: ssch checking addressing errors Pierre Morel
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

We expect a specification exception for a misaligned ORB.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 s390x/css.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/s390x/css.c b/s390x/css.c
index d248cac..47452ba 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -103,9 +103,30 @@ static void ssch_orb_cpa_zero(void)
 	orb->cpa = cpa;
 }
 
+static void ssch_orb_alignment(void)
+{
+	void *p;
+
+	/* Prepare a Valid orb on a misaligned address*/
+	p = alloc_pages_flags(0, AREA_DMA31);
+	assert(p);
+	p += 2;
+
+	((struct orb *)p)->intparm = test_device_sid;
+	((struct orb *)p)->ctrl = ORB_CTRL_ISIC | ORB_CTRL_FMT | ORB_LPM_DFLT;
+	((struct orb *)p)->cpa = (long)ccw;
+
+	expect_pgm_int();
+	ssch(test_device_sid, p);
+	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
+
+	free_pages(p - 2);
+}
+
 static struct tests ssh_tests[] = {
 	{ "privilege", ssch_privilege },
 	{ "orb cpa zero", ssch_orb_cpa_zero },
+	{ "orb alignment", ssch_orb_alignment },
 	{ NULL, NULL }
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 10/16] s390x: css: ssch checking addressing errors
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (8 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 09/16] s390x: css: ssch with mis aligned ORB Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW Pierre Morel
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

We check ORB CPA and CCW address for being inside limits
and existing.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 s390x/css.c         | 79 +++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  8 +++--
 2 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/s390x/css.c b/s390x/css.c
index 47452ba..f8f91cf 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -16,6 +16,7 @@
 #include <asm/arch_def.h>
 #include <alloc_page.h>
 #include <alloc.h>
+#include <sclp.h>
 
 #include <malloc_io.h>
 #include <css.h>
@@ -34,6 +35,12 @@ static struct senseid *senseid;
 struct ccw1 *ccw;
 struct orb *orb;
 
+phys_addr_t ram_size;
+#define ADDR_1G		0x40000000
+#define ADDR_1_5G	0x60000000
+#define ADDR_3G		0xc0000000
+
+
 static void test_enumerate(void)
 {
 	test_device_sid = css_enumerate();
@@ -123,10 +130,80 @@ static void ssch_orb_alignment(void)
 	free_pages(p - 2);
 }
 
+static void ssch_data_access(void)
+{
+	uint32_t tmp;
+
+	if (ram_size > ADDR_1G) {
+		report_skip("Test with more than 1G available memory");
+		return;
+	}
+
+	tmp = ccw->data_address;
+	ccw->data_address = ADDR_1_5G;
+
+	ssch(test_device_sid, orb);
+	tsch(test_device_sid, &irb);
+	report(check_io_errors(test_device_sid, 0, SCSW_SCHS_PRG_CHK), "expecting Program check");
+
+	ccw->data_address = tmp;
+}
+
+static void ssch_ccw_access(void)
+{
+	uint32_t tmp;
+
+	if (ram_size > ADDR_1G) {
+		report_skip("Test with more than 1G available memory");
+		return;
+	}
+
+	tmp = orb->cpa;
+	orb->cpa = ADDR_1_5G;
+
+	ssch(test_device_sid, orb);
+	tsch(test_device_sid, &irb);
+	report(check_io_errors(test_device_sid, 0, SCSW_SCHS_PRG_CHK), "expecting Program check");
+
+	orb->cpa = tmp;
+}
+
+static void ssch_ccw_dma31(void)
+{
+	uint32_t tmp;
+	struct ccw1 *ccw_high;
+
+	if (ram_size < ADDR_3G) {
+		report_skip("Test with less than 3G available memory");
+		return;
+	}
+
+	ccw_high = alloc_pages_flags(0, AREA_NORMAL);
+	assert(ccw_high);
+	ccw_high->code = CCW_CMD_SENSE_ID;
+	ccw_high->flags = CCW_F_SLI;
+	ccw_high->count = sizeof(*senseid);
+	ccw_high->data_address = (long)senseid;
+
+	tmp = orb->cpa;
+	report_info("ccw_high: %p", ccw_high);
+	orb->cpa = (long)ccw_high;
+
+	expect_pgm_int();
+	ssch(test_device_sid, orb);
+	check_pgm_int_code(PGM_INT_CODE_OPERAND);
+
+	orb->cpa = tmp;
+	free_pages(ccw_high);
+}
+
 static struct tests ssh_tests[] = {
 	{ "privilege", ssch_privilege },
 	{ "orb cpa zero", ssch_orb_cpa_zero },
 	{ "orb alignment", ssch_orb_alignment },
+	{ "data access", ssch_data_access },
+	{ "CCW access", ssch_ccw_access },
+	{ "CCW in DMA31", ssch_ccw_dma31 },
 	{ NULL, NULL }
 };
 
@@ -136,6 +213,7 @@ static void test_ssch(void)
 
 	orb_alloc();
 	assert(css_enable(test_device_sid, 0) == 0);
+	ram_size = get_ram_size();
 
 	for (i = 0; ssh_tests[i].name; i++) {
 		report_prefix_push(ssh_tests[i].name);
@@ -144,6 +222,7 @@ static void test_ssch(void)
 	}
 
 	orb_free();
+	css_enable(test_device_sid, 0);
 }
 
 /*
diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
index 9f81a60..45569dc 100644
--- a/s390x/unittests.cfg
+++ b/s390x/unittests.cfg
@@ -86,9 +86,13 @@ extra_params = -m 1G
 file = sclp.elf
 extra_params = -m 3G
 
-[css]
+[css-1g]
 file = css.elf
-extra_params = -device virtio-net-ccw
+extra_params = -m 1G -device virtio-net-ccw
+
+[css-3g]
+file = css.elf
+extra_params = -m 3G -device virtio-net-ccw
 
 [skrf]
 file = skrf.elf
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (9 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 10/16] s390x: css: ssch checking addressing errors Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06 15:58   ` Cornelia Huck
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits Pierre Morel
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

Verify that using MIDAW triggers a operand exception.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 s390x/css.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/s390x/css.c b/s390x/css.c
index f8f91cf..56adc16 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -197,6 +197,18 @@ static void ssch_ccw_dma31(void)
 	free_pages(ccw_high);
 }
 
+static void ssch_orb_midaw(void)
+{
+	uint32_t tmp = orb->ctrl;
+
+	orb->ctrl |= ORB_CTRL_MIDAW;
+	expect_pgm_int();
+	ssch(test_device_sid, orb);
+	check_pgm_int_code(PGM_INT_CODE_OPERAND);
+
+	orb->ctrl = tmp;
+}
+
 static struct tests ssh_tests[] = {
 	{ "privilege", ssch_privilege },
 	{ "orb cpa zero", ssch_orb_cpa_zero },
@@ -204,6 +216,7 @@ static struct tests ssh_tests[] = {
 	{ "data access", ssch_data_access },
 	{ "CCW access", ssch_ccw_access },
 	{ "CCW in DMA31", ssch_ccw_dma31 },
+	{ "ORB MIDAW unsupported", ssch_orb_midaw },
 	{ NULL, NULL }
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (10 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06 15:51   ` Cornelia Huck
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 13/16] s390x: css: checking for CSS extensions Pierre Morel
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

Several bits of the ORB are reserved and must be zero.
Their use will trigger a operand exception.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 s390x/css.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/s390x/css.c b/s390x/css.c
index 56adc16..26f5da6 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -209,6 +209,26 @@ static void ssch_orb_midaw(void)
 	orb->ctrl = tmp;
 }
 
+static void ssch_orb_ctrl(void)
+{
+	uint32_t tmp = orb->ctrl;
+	char buffer[80];
+	int i;
+
+	/* Check the reserved bits of the ORB CTRL field */
+	for (i = 26; i <= 30; i++) {
+		orb->ctrl |= (0x01 << (31 - i));
+		snprintf(buffer, 80, " %d", i);
+		report_prefix_push(buffer);
+		expect_pgm_int();
+		ssch(test_device_sid, orb);
+		check_pgm_int_code(PGM_INT_CODE_OPERAND);
+		report_prefix_pop();
+
+		orb->ctrl = tmp;
+	}
+}
+
 static struct tests ssh_tests[] = {
 	{ "privilege", ssch_privilege },
 	{ "orb cpa zero", ssch_orb_cpa_zero },
@@ -217,6 +237,7 @@ static struct tests ssh_tests[] = {
 	{ "CCW access", ssch_ccw_access },
 	{ "CCW in DMA31", ssch_ccw_dma31 },
 	{ "ORB MIDAW unsupported", ssch_orb_midaw },
+	{ "ORB reserved CTRL bits", ssch_orb_ctrl },
 	{ NULL, NULL }
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 13/16] s390x: css: checking for CSS extensions
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (11 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06 15:50   ` Cornelia Huck
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 14/16] s390x: css: issuing SSCH when the channel is status pending Pierre Morel
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

We verify that these extensions are not install before running simple
tests.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/css.h |  2 ++
 s390x/css.c     | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index d824e34..08b2974 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -338,7 +338,9 @@ struct chsc_scsc {
 	uint8_t reserved[9];
 	struct chsc_header res;
 	uint32_t res_fmt;
+#define CSSC_ORB_EXTENSIONS		0
 #define CSSC_EXTENDED_MEASUREMENT_BLOCK 48
+#define CSSC_FC_EXTENSIONS		88
 	uint64_t general_char[255];
 	uint64_t chsc_char[254];
 };
diff --git a/s390x/css.c b/s390x/css.c
index 26f5da6..f8c6688 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -229,6 +229,35 @@ static void ssch_orb_ctrl(void)
 	}
 }
 
+static void ssch_orb_extension(void)
+{
+	if (!css_test_general_feature(CSSC_ORB_EXTENSIONS)) {
+		report_skip("ORB extensions not installed");
+		return;
+	}
+	/* Place holder for checking ORB extensions */
+	report_info("ORB extensions installed but not tested");
+}
+
+static void ssch_orb_fcx(void)
+{
+	uint32_t tmp = orb->ctrl;
+
+	if (!css_test_general_feature(CSSC_FC_EXTENSIONS)) {
+		report_skip("Fibre-channel extensions not installed");
+		return;
+	}
+
+	report_prefix_push("Channel-Program Type Control");
+	orb->ctrl |= ORB_CTRL_CPTC;
+	expect_pgm_int();
+	ssch(test_device_sid, orb);
+	check_pgm_int_code(PGM_INT_CODE_OPERAND);
+	report_prefix_pop();
+
+	orb->ctrl = tmp;
+}
+
 static struct tests ssh_tests[] = {
 	{ "privilege", ssch_privilege },
 	{ "orb cpa zero", ssch_orb_cpa_zero },
@@ -238,6 +267,8 @@ static struct tests ssh_tests[] = {
 	{ "CCW in DMA31", ssch_ccw_dma31 },
 	{ "ORB MIDAW unsupported", ssch_orb_midaw },
 	{ "ORB reserved CTRL bits", ssch_orb_ctrl },
+	{ "ORB extensions", ssch_orb_extension},
+	{ "FC extensions", ssch_orb_fcx},
 	{ NULL, NULL }
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 14/16] s390x: css: issuing SSCH when the channel is status pending
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (12 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 13/16] s390x: css: checking for CSS extensions Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06 15:34   ` Cornelia Huck
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 15/16] s390x: css: testing halt subchannel Pierre Morel
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

We await CC=1 when we issue a SSCH on a channel with status pending.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/css.h |  2 ++
 s390x/css.c     | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index 08b2974..3eb6957 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -90,6 +90,8 @@ struct scsw {
 #define SCSW_ESW_FORMAT		0x04000000
 #define SCSW_SUSPEND_CTRL	0x08000000
 #define SCSW_KEY		0xf0000000
+#define SCSW_SSCH_COMPLETED	(SCSW_CCW_FORMAT | SCSW_FC_START | SCSW_SC_PENDING | SCSW_SC_SECONDARY | \
+				 SCSW_SC_PRIMARY)
 	uint32_t ctrl;
 	uint32_t ccw_addr;
 #define SCSW_DEVS_DEV_END	0x04
diff --git a/s390x/css.c b/s390x/css.c
index f8c6688..52264f2 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -258,6 +258,15 @@ static void ssch_orb_fcx(void)
 	orb->ctrl = tmp;
 }
 
+static void ssch_status_pending(void)
+{
+	assert(ssch(test_device_sid, orb) == 0);
+	report(ssch(test_device_sid, orb) == 1, "CC = 1");
+	/* now we clear the status */
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_SSCH_COMPLETED);
+}
+
 static struct tests ssh_tests[] = {
 	{ "privilege", ssch_privilege },
 	{ "orb cpa zero", ssch_orb_cpa_zero },
@@ -269,6 +278,7 @@ static struct tests ssh_tests[] = {
 	{ "ORB reserved CTRL bits", ssch_orb_ctrl },
 	{ "ORB extensions", ssch_orb_extension},
 	{ "FC extensions", ssch_orb_fcx},
+	{ "status pending before ssch", ssch_status_pending},
 	{ NULL, NULL }
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 15/16] s390x: css: testing halt subchannel
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (13 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 14/16] s390x: css: issuing SSCH when the channel is status pending Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 16/16] s390x: css: testing clear subchannel Pierre Morel
  2021-04-06 12:21 ` [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

checking return values for HSCH for various configurations.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 lib/s390x/css.h     |  4 +++
 lib/s390x/css_lib.c |  4 +++
 s390x/css.c         | 63 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/lib/s390x/css.h b/lib/s390x/css.h
index 3eb6957..90c8e4b 100644
--- a/lib/s390x/css.h
+++ b/lib/s390x/css.h
@@ -92,6 +92,10 @@ struct scsw {
 #define SCSW_KEY		0xf0000000
 #define SCSW_SSCH_COMPLETED	(SCSW_CCW_FORMAT | SCSW_FC_START | SCSW_SC_PENDING | SCSW_SC_SECONDARY | \
 				 SCSW_SC_PRIMARY)
+#define SCSW_HSCH_COMPLETED	(SCSW_CCW_FORMAT | SCSW_FC_HALT | \
+				 SCSW_SC_PENDING)
+#define SCSW_CSCH_COMPLETED	(SCSW_CCW_FORMAT | SCSW_FC_CLEAR | \
+				 SCSW_SC_PENDING)
 	uint32_t ctrl;
 	uint32_t ccw_addr;
 #define SCSW_DEVS_DEV_END	0x04
diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
index 12ef874..4c4506a 100644
--- a/lib/s390x/css_lib.c
+++ b/lib/s390x/css_lib.c
@@ -528,6 +528,10 @@ int check_io_completion(int schid, uint32_t ctrl)
 		goto end;
 	}
 
+	/* We do not need more check for HSCH or CSCH */
+	if (irb.scsw.ctrl & (SCSW_FC_HALT | SCSW_FC_CLEAR))
+		goto end;
+
 	if (!(irb.scsw.ctrl & (SCSW_SC_SECONDARY | SCSW_SC_PRIMARY))) {
 		report(0, "Primary or secondary status missing. Subch Ctrl: %08x",
 		       irb.scsw.ctrl);
diff --git a/s390x/css.c b/s390x/css.c
index 52264f2..0f80a44 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -300,6 +300,68 @@ static void test_ssch(void)
 	css_enable(test_device_sid, 0);
 }
 
+static void test_hsch(void)
+{
+	struct orb orb = {
+		.intparm = test_device_sid,
+		.ctrl = ORB_CTRL_ISIC | ORB_CTRL_FMT | ORB_LPM_DFLT,
+	};
+	struct ccw1 *ccw;
+
+	senseid = alloc_io_mem(sizeof(*senseid), 0);
+	assert(senseid);
+	ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI);
+	assert(ccw);
+	orb.cpa = (uint64_t)ccw;
+
+	/* HSCH is a privilege operation */
+	report_prefix_push("Privilege");
+	enter_pstate();
+	expect_pgm_int();
+	hsch(test_device_sid);
+	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
+	report_prefix_pop();
+
+	/* Basic HSCH */
+	report_prefix_push("HSCH on a quiet subchannel");
+	assert(css_enable(test_device_sid, 0) == 0);
+	report(hsch(test_device_sid) == 0, "subchannel halted");
+	report_prefix_pop();
+
+	/* now we check the flags */
+	report_prefix_push("Ctrl flags");
+	assert(tsch(test_device_sid, &irb) == 0);
+	report(check_io_completion(test_device_sid, SCSW_HSCH_COMPLETED) == 0, "expected");
+	report_prefix_pop();
+
+	/* Check HSCH after SSCH */
+	report_prefix_push("HSCH on status pending subchannel");
+	assert(ssch(test_device_sid, &orb) == 0);
+	report(hsch(test_device_sid) == 1, "Halt subchannel should fail with CC 1");
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_SSCH_COMPLETED);
+	report_prefix_pop();
+
+	/* Check HSCH after CSCH */
+	report_prefix_push("HSCH on busy on CSCH subchannel");
+	assert(csch(test_device_sid) == 0);
+	report(hsch(test_device_sid) == 1, "Halt subchannel should fail with CC 1");
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED);
+	report_prefix_pop();
+
+	/* Check HSCH after HSCH */
+	report_prefix_push("HSCH on busy on HSCH subchannel");
+	assert(hsch(test_device_sid) == 0);
+	report(hsch(test_device_sid) == 1, "Halt subchannel should fail with CC 1");
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_HSCH_COMPLETED);
+	report_prefix_pop();
+
+	free_io_mem(senseid, sizeof(*senseid));
+	free_io_mem(ccw, sizeof(*ccw));
+}
+
 /*
  * test_sense
  * Pre-requisites:
@@ -569,6 +631,7 @@ static struct tests tests[] = {
 	/* The css_init test is needed to initialize the CSS Characteristics */
 	{ "enable (msch)", test_enable },
 	{ "start subchannel", test_ssch },
+	{ "halt subchannel", test_hsch },
 	{ "sense (ssch/tsch)", test_sense },
 	{ "measurement block (schm)", test_schm },
 	{ "measurement block format0", test_schm_fmt0 },
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [kvm-unit-tests PATCH v3 16/16] s390x: css: testing clear subchannel
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (14 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 15/16] s390x: css: testing halt subchannel Pierre Morel
@ 2021-04-06  7:40 ` Pierre Morel
  2021-04-06 12:21 ` [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06  7:40 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda

Checking return values for CSCH for various configurations.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 s390x/css.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/s390x/css.c b/s390x/css.c
index 0f80a44..00c77c7 100644
--- a/s390x/css.c
+++ b/s390x/css.c
@@ -362,6 +362,69 @@ static void test_hsch(void)
 	free_io_mem(ccw, sizeof(*ccw));
 }
 
+static void test_csch(void)
+{
+	struct orb orb = {
+		.intparm = test_device_sid,
+		.ctrl = ORB_CTRL_ISIC | ORB_CTRL_FMT | ORB_LPM_DFLT,
+	};
+	struct ccw1 *ccw;
+
+	senseid = alloc_io_mem(sizeof(*senseid), 0);
+	assert(senseid);
+	ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI);
+	assert(ccw);
+	orb.cpa = (uint64_t)ccw;
+
+	/* CSCH is a privilege operation */
+	report_prefix_push("Privilege");
+	enter_pstate();
+	expect_pgm_int();
+	csch(test_device_sid);
+	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
+	report_prefix_pop();
+
+	/* Basic check for CSCH */
+	report_prefix_push("CSCH on a quiet subchannel");
+	assert(css_enable(test_device_sid, 0) == 0);
+	report(csch(test_device_sid) == 0, "subchannel clear");
+	report_prefix_pop();
+
+	/* now we check the flags */
+	report_prefix_push("IRQ flags");
+	assert(tsch(test_device_sid, &irb) == 0);
+	report(check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED) == 0, "expected");
+	report_prefix_pop();
+
+	/* We want to check if the IRQ flags of SSCH are erased by clear */
+	report_prefix_push("CSCH on SSCH status pending subchannel");
+	assert(ssch(test_device_sid, &orb) == 0);
+	report(csch(test_device_sid) == 0, "subchannel cleared");
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED |
+			    SCSW_SC_SECONDARY | SCSW_SC_PRIMARY);
+	report_prefix_pop();
+
+	/* Checking CSCH after HSCH */
+	report_prefix_push("CSCH on a halted subchannel");
+	assert(hsch(test_device_sid) == 0);
+	report(csch(test_device_sid) == 0, "subchannel cleared");
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED);
+	report_prefix_pop();
+
+	/* Checking CSCH after CSCH */
+	report_prefix_push("CSCH on a cleared subchannel");
+	assert(csch(test_device_sid) == 0);
+	report(csch(test_device_sid) == 0, "subchannel cleared");
+	assert(tsch(test_device_sid, &irb) == 0);
+	check_io_completion(test_device_sid, SCSW_CSCH_COMPLETED);
+	report_prefix_pop();
+
+	free_io_mem(senseid, sizeof(*senseid));
+	free_io_mem(ccw, sizeof(*ccw));
+}
+
 /*
  * test_sense
  * Pre-requisites:
@@ -632,6 +695,7 @@ static struct tests tests[] = {
 	{ "enable (msch)", test_enable },
 	{ "start subchannel", test_ssch },
 	{ "halt subchannel", test_hsch },
+	{ "clear subchannel", test_csch },
 	{ "sense (ssch/tsch)", test_sense },
 	{ "measurement block (schm)", test_schm },
 	{ "measurement block format0", test_schm_fmt0 },
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors
  2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
                   ` (15 preceding siblings ...)
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 16/16] s390x: css: testing clear subchannel Pierre Morel
@ 2021-04-06 12:21 ` Pierre Morel
  16 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-06 12:21 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, thuth, cohuck, imbrenda


Hi all,

I forgot to write that some tests about addressing will fail if the 
following QEMU patch is not installed:

Subject: [PATCH v1 0/1] s390x: css: report errors from 
ccw_dstream_read/write
Date: Tue,  6 Apr 2021 09:44:12 +0200
Message-Id: <1617695053-7328-1-git-send-email-pmorel@linux.ibm.com>


Regards,
Pierre


On 4/6/21 9:40 AM, Pierre Morel wrote:
> The goal of this series is to test some of the I/O instructions,
> SSCH, CSCH and HSCH for errors like invalid parameters, addressing,
> timing etc.
> We can not test the sending of an instruction before the last instruction
> has been proceeded by QEMU due to the QEMU serialization but we can
> check the behavior of an instruction if it is started before the status
> of the last instruction is read.
> 
> To do this we first separate the waiting for the interruption and the
> checking of the IRB and enable the subchannel without an I/O ISC to
> avoid interruptions at this subchannel and second, we add an argument
> to the routine in charge to check the IRB representing the expected
> SCSW control field of the IRB.
> 
> We also need several other enhancements to the testing environment:
> 
> - definitions for the SCSW control bits
> - a new function to disable a subchannel
> - a macro to simplify skiping tests when no device is present
>    (I know the warning about return in macro, can we accept it?)
> 
> In the new tests we assume that all the test preparation is working and
> use asserts for all function for which we do not expect a failure.
> 
> regards,
> Pierre
> 
> PS: Sorry, I needed to modify patches 4 and 5 for which I already had RB or AB.
>      I removed them even I hope you will agree with my modifications.
> 
> 
> Pierre Morel (16):
>    s390x: lib: css: disabling a subchannel
>    s390x: lib: css: SCSW bit definitions
>    s390x: css: simplify skipping tests on no device
>    s390x: lib: css: separate wait for IRQ and check I/O completion
>    s390x: lib: css: add SCSW ctrl expectations to check I/O completion
>    s390x: lib: css: checking I/O errors
>    s390x: css: testing ssch errors
>    s390x: css: ssch check for cpa zero
>    s390x: css: ssch with mis aligned ORB
>    s390x: css: ssch checking addressing errors
>    s390x: css: No support for MIDAW
>    s390x: css: Check ORB reserved bits
>    s390x: css: checking for CSS extensions
>    s390x: css: issuing SSCH when the channel is status pending
>    s390x: css: testing halt subchannel
>    s390x: css: testing clear subchannel
> 
>   lib/s390x/css.h     |  42 ++++-
>   lib/s390x/css_lib.c | 138 ++++++++++++--
>   s390x/css.c         | 425 +++++++++++++++++++++++++++++++++++++++++---
>   s390x/unittests.cfg |   8 +-
>   4 files changed, 565 insertions(+), 48 deletions(-)
> 

-- 
Pierre Morel
IBM Lab Boeblingen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 03/16] s390x: css: simplify skipping tests on no device
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 03/16] s390x: css: simplify skipping tests on no device Pierre Morel
@ 2021-04-06 12:44   ` Cornelia Huck
  2021-04-07 10:53     ` Pierre Morel
  0 siblings, 1 reply; 30+ messages in thread
From: Cornelia Huck @ 2021-04-06 12:44 UTC (permalink / raw)
  To: Pierre Morel; +Cc: kvm, frankja, david, thuth, imbrenda

On Tue,  6 Apr 2021 09:40:40 +0200
Pierre Morel <pmorel@linux.ibm.com> wrote:

> We will have to test if a device is present for every tests
> in the future.
> Let's provide separate the first tests from the test loop and
> skip the remaining tests if no device is present.

What about the following patch description:

"We keep adding tests that act upon a concrete device, and we have to
test that a device is present for all of those.

Instead, just skip all of the tests requiring a device if we were not
able to set it up in the first place. The enumeration test will already
have failed in that case."

> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
>  s390x/css.c | 36 ++++++++++++++----------------------
>  1 file changed, 14 insertions(+), 22 deletions(-)
> 

(...)

> @@ -336,8 +316,6 @@ static struct {
>  	void (*func)(void);
>  } tests[] = {
>  	/* The css_init test is needed to initialize the CSS Characteristics */

If you remove the css_init test from this list, the above comment does
not make sense anymore :)

> -	{ "initialize CSS (chsc)", css_init },
> -	{ "enumerate (stsch)", test_enumerate },
>  	{ "enable (msch)", test_enable },
>  	{ "sense (ssch/tsch)", test_sense },
>  	{ "measurement block (schm)", test_schm },
> @@ -352,11 +330,25 @@ int main(int argc, char *argv[])
>  
>  	report_prefix_push("Channel Subsystem");
>  	enable_io_isc(0x80 >> IO_SCH_ISC);
> +
> +	report_prefix_push("initialize CSS (chsc)");
> +	css_init();
> +	report_prefix_pop();
> +
> +	report_prefix_push("enumerate (stsch)");
> +	test_enumerate();
> +	report_prefix_pop();

Could we maybe have two lists of tests: one that don't require a
device, and one that does?

> +
> +	if (!test_device_sid)
> +		goto end;

In any case, I think we should log an explicit message that we skip the
remaining tests because of no device being available.

> +
>  	for (i = 0; tests[i].name; i++) {
>  		report_prefix_push(tests[i].name);
>  		tests[i].func();
>  		report_prefix_pop();
>  	}
> +
> +end:
>  	report_prefix_pop();
>  
>  	return report_summary();


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 14/16] s390x: css: issuing SSCH when the channel is status pending
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 14/16] s390x: css: issuing SSCH when the channel is status pending Pierre Morel
@ 2021-04-06 15:34   ` Cornelia Huck
  2021-04-07 10:46     ` Pierre Morel
  0 siblings, 1 reply; 30+ messages in thread
From: Cornelia Huck @ 2021-04-06 15:34 UTC (permalink / raw)
  To: Pierre Morel; +Cc: kvm, frankja, david, thuth, imbrenda

On Tue,  6 Apr 2021 09:40:51 +0200
Pierre Morel <pmorel@linux.ibm.com> wrote:

> We await CC=1 when we issue a SSCH on a channel with status pending.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
>  lib/s390x/css.h |  2 ++
>  s390x/css.c     | 10 ++++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/lib/s390x/css.h b/lib/s390x/css.h
> index 08b2974..3eb6957 100644
> --- a/lib/s390x/css.h
> +++ b/lib/s390x/css.h
> @@ -90,6 +90,8 @@ struct scsw {
>  #define SCSW_ESW_FORMAT		0x04000000
>  #define SCSW_SUSPEND_CTRL	0x08000000
>  #define SCSW_KEY		0xf0000000
> +#define SCSW_SSCH_COMPLETED	(SCSW_CCW_FORMAT | SCSW_FC_START | SCSW_SC_PENDING | SCSW_SC_SECONDARY | \
> +				 SCSW_SC_PRIMARY)
>  	uint32_t ctrl;
>  	uint32_t ccw_addr;
>  #define SCSW_DEVS_DEV_END	0x04
> diff --git a/s390x/css.c b/s390x/css.c
> index f8c6688..52264f2 100644
> --- a/s390x/css.c
> +++ b/s390x/css.c
> @@ -258,6 +258,15 @@ static void ssch_orb_fcx(void)
>  	orb->ctrl = tmp;
>  }
>  
> +static void ssch_status_pending(void)
> +{
> +	assert(ssch(test_device_sid, orb) == 0);
> +	report(ssch(test_device_sid, orb) == 1, "CC = 1");

I don't think that's correct in the general case (although it will work
for QEMU).

The PoP has a note about some models discarding the status pending, if
we have secondary status only (although I don't think that would happen
with this sequence.) You might also end up with cc 2 here, I think. In
theory, you could also get a cc 3 on real hardware, but that would be a
real edge case, and subsequent tests would fail anyway.

> +	/* now we clear the status */
> +	assert(tsch(test_device_sid, &irb) == 0);
> +	check_io_completion(test_device_sid, SCSW_SSCH_COMPLETED);
> +}
> +
>  static struct tests ssh_tests[] = {
>  	{ "privilege", ssch_privilege },
>  	{ "orb cpa zero", ssch_orb_cpa_zero },
> @@ -269,6 +278,7 @@ static struct tests ssh_tests[] = {
>  	{ "ORB reserved CTRL bits", ssch_orb_ctrl },
>  	{ "ORB extensions", ssch_orb_extension},
>  	{ "FC extensions", ssch_orb_fcx},
> +	{ "status pending before ssch", ssch_status_pending},
>  	{ NULL, NULL }
>  };
>  


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 13/16] s390x: css: checking for CSS extensions
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 13/16] s390x: css: checking for CSS extensions Pierre Morel
@ 2021-04-06 15:50   ` Cornelia Huck
  2021-04-07 10:42     ` Pierre Morel
  0 siblings, 1 reply; 30+ messages in thread
From: Cornelia Huck @ 2021-04-06 15:50 UTC (permalink / raw)
  To: Pierre Morel; +Cc: kvm, frankja, david, thuth, imbrenda

On Tue,  6 Apr 2021 09:40:50 +0200
Pierre Morel <pmorel@linux.ibm.com> wrote:

> We verify that these extensions are not install before running simple

s/not install/installed/ ?

Testing extensions that are not installed does not make that much sense
:)

> tests.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
>  lib/s390x/css.h |  2 ++
>  s390x/css.c     | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/lib/s390x/css.h b/lib/s390x/css.h
> index d824e34..08b2974 100644
> --- a/lib/s390x/css.h
> +++ b/lib/s390x/css.h
> @@ -338,7 +338,9 @@ struct chsc_scsc {
>  	uint8_t reserved[9];
>  	struct chsc_header res;
>  	uint32_t res_fmt;
> +#define CSSC_ORB_EXTENSIONS		0
>  #define CSSC_EXTENDED_MEASUREMENT_BLOCK 48
> +#define CSSC_FC_EXTENSIONS		88
>  	uint64_t general_char[255];
>  	uint64_t chsc_char[254];
>  };
> diff --git a/s390x/css.c b/s390x/css.c
> index 26f5da6..f8c6688 100644
> --- a/s390x/css.c
> +++ b/s390x/css.c
> @@ -229,6 +229,35 @@ static void ssch_orb_ctrl(void)
>  	}
>  }
>  
> +static void ssch_orb_extension(void)
> +{
> +	if (!css_test_general_feature(CSSC_ORB_EXTENSIONS)) {
> +		report_skip("ORB extensions not installed");
> +		return;
> +	}
> +	/* Place holder for checking ORB extensions */
> +	report_info("ORB extensions installed but not tested");
> +}
> +
> +static void ssch_orb_fcx(void)
> +{
> +	uint32_t tmp = orb->ctrl;
> +
> +	if (!css_test_general_feature(CSSC_FC_EXTENSIONS)) {
> +		report_skip("Fibre-channel extensions not installed");
> +		return;
> +	}
> +
> +	report_prefix_push("Channel-Program Type Control");
> +	orb->ctrl |= ORB_CTRL_CPTC;
> +	expect_pgm_int();
> +	ssch(test_device_sid, orb);
> +	check_pgm_int_code(PGM_INT_CODE_OPERAND);
> +	report_prefix_pop();

I don't quite understand what you're testing here; shouldn't the device
accept a transport-mode orb if fcx is installed? The problem would be
if the program consists of ccws instead, so it's more a malformed block
handling test?

> +
> +	orb->ctrl = tmp;
> +}
> +
>  static struct tests ssh_tests[] = {
>  	{ "privilege", ssch_privilege },
>  	{ "orb cpa zero", ssch_orb_cpa_zero },
> @@ -238,6 +267,8 @@ static struct tests ssh_tests[] = {
>  	{ "CCW in DMA31", ssch_ccw_dma31 },
>  	{ "ORB MIDAW unsupported", ssch_orb_midaw },
>  	{ "ORB reserved CTRL bits", ssch_orb_ctrl },
> +	{ "ORB extensions", ssch_orb_extension},
> +	{ "FC extensions", ssch_orb_fcx},
>  	{ NULL, NULL }
>  };
>  


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits Pierre Morel
@ 2021-04-06 15:51   ` Cornelia Huck
  2021-04-07 10:07     ` Pierre Morel
  0 siblings, 1 reply; 30+ messages in thread
From: Cornelia Huck @ 2021-04-06 15:51 UTC (permalink / raw)
  To: Pierre Morel; +Cc: kvm, frankja, david, thuth, imbrenda

On Tue,  6 Apr 2021 09:40:49 +0200
Pierre Morel <pmorel@linux.ibm.com> wrote:

> Several bits of the ORB are reserved and must be zero.
> Their use will trigger a operand exception.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
>  s390x/css.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/s390x/css.c b/s390x/css.c
> index 56adc16..26f5da6 100644
> --- a/s390x/css.c
> +++ b/s390x/css.c
> @@ -209,6 +209,26 @@ static void ssch_orb_midaw(void)
>  	orb->ctrl = tmp;
>  }
>  
> +static void ssch_orb_ctrl(void)
> +{
> +	uint32_t tmp = orb->ctrl;
> +	char buffer[80];
> +	int i;
> +
> +	/* Check the reserved bits of the ORB CTRL field */
> +	for (i = 26; i <= 30; i++) {

This looks very magic; can we get some defines?

> +		orb->ctrl |= (0x01 << (31 - i));
> +		snprintf(buffer, 80, " %d", i);
> +		report_prefix_push(buffer);
> +		expect_pgm_int();
> +		ssch(test_device_sid, orb);
> +		check_pgm_int_code(PGM_INT_CODE_OPERAND);
> +		report_prefix_pop();
> +
> +		orb->ctrl = tmp;
> +	}
> +}
> +
>  static struct tests ssh_tests[] = {
>  	{ "privilege", ssch_privilege },
>  	{ "orb cpa zero", ssch_orb_cpa_zero },
> @@ -217,6 +237,7 @@ static struct tests ssh_tests[] = {
>  	{ "CCW access", ssch_ccw_access },
>  	{ "CCW in DMA31", ssch_ccw_dma31 },
>  	{ "ORB MIDAW unsupported", ssch_orb_midaw },
> +	{ "ORB reserved CTRL bits", ssch_orb_ctrl },
>  	{ NULL, NULL }
>  };
>  


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW
  2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW Pierre Morel
@ 2021-04-06 15:58   ` Cornelia Huck
  2021-04-07 10:06     ` Pierre Morel
  0 siblings, 1 reply; 30+ messages in thread
From: Cornelia Huck @ 2021-04-06 15:58 UTC (permalink / raw)
  To: Pierre Morel; +Cc: kvm, frankja, david, thuth, imbrenda

On Tue,  6 Apr 2021 09:40:48 +0200
Pierre Morel <pmorel@linux.ibm.com> wrote:

> Verify that using MIDAW triggers a operand exception.

This is only for current QEMU; a future QEMU or another hypervisor may
support it. I think in those cases the failure mode may be different
(as the ccw does not use midaws?)

> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
>  s390x/css.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/s390x/css.c b/s390x/css.c
> index f8f91cf..56adc16 100644
> --- a/s390x/css.c
> +++ b/s390x/css.c
> @@ -197,6 +197,18 @@ static void ssch_ccw_dma31(void)
>  	free_pages(ccw_high);
>  }
>  
> +static void ssch_orb_midaw(void)
> +{
> +	uint32_t tmp = orb->ctrl;
> +
> +	orb->ctrl |= ORB_CTRL_MIDAW;
> +	expect_pgm_int();
> +	ssch(test_device_sid, orb);
> +	check_pgm_int_code(PGM_INT_CODE_OPERAND);
> +
> +	orb->ctrl = tmp;
> +}
> +
>  static struct tests ssh_tests[] = {
>  	{ "privilege", ssch_privilege },
>  	{ "orb cpa zero", ssch_orb_cpa_zero },
> @@ -204,6 +216,7 @@ static struct tests ssh_tests[] = {
>  	{ "data access", ssch_data_access },
>  	{ "CCW access", ssch_ccw_access },
>  	{ "CCW in DMA31", ssch_ccw_dma31 },
> +	{ "ORB MIDAW unsupported", ssch_orb_midaw },
>  	{ NULL, NULL }
>  };
>  


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW
  2021-04-06 15:58   ` Cornelia Huck
@ 2021-04-07 10:06     ` Pierre Morel
  2021-04-07 10:14       ` Cornelia Huck
  0 siblings, 1 reply; 30+ messages in thread
From: Pierre Morel @ 2021-04-07 10:06 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: kvm, frankja, david, thuth, imbrenda



On 4/6/21 5:58 PM, Cornelia Huck wrote:
> On Tue,  6 Apr 2021 09:40:48 +0200
> Pierre Morel <pmorel@linux.ibm.com> wrote:
> 
>> Verify that using MIDAW triggers a operand exception.
> 
> This is only for current QEMU; a future QEMU or another hypervisor may
> support it. I think in those cases the failure mode may be different
> (as the ccw does not use midaws?)

Yes, should I let fall this test case?




-- 
Pierre Morel
IBM Lab Boeblingen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits
  2021-04-06 15:51   ` Cornelia Huck
@ 2021-04-07 10:07     ` Pierre Morel
  2021-04-07 10:15       ` Cornelia Huck
  0 siblings, 1 reply; 30+ messages in thread
From: Pierre Morel @ 2021-04-07 10:07 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: kvm, frankja, david, thuth, imbrenda



On 4/6/21 5:51 PM, Cornelia Huck wrote:
> On Tue,  6 Apr 2021 09:40:49 +0200
> Pierre Morel <pmorel@linux.ibm.com> wrote:
> 
>> Several bits of the ORB are reserved and must be zero.
>> Their use will trigger a operand exception.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>>   s390x/css.c | 21 +++++++++++++++++++++
>>   1 file changed, 21 insertions(+)
>>
>> diff --git a/s390x/css.c b/s390x/css.c
>> index 56adc16..26f5da6 100644
>> --- a/s390x/css.c
>> +++ b/s390x/css.c
>> @@ -209,6 +209,26 @@ static void ssch_orb_midaw(void)
>>   	orb->ctrl = tmp;
>>   }
>>   
>> +static void ssch_orb_ctrl(void)
>> +{
>> +	uint32_t tmp = orb->ctrl;
>> +	char buffer[80];
>> +	int i;
>> +
>> +	/* Check the reserved bits of the ORB CTRL field */
>> +	for (i = 26; i <= 30; i++) {
> 
> This looks very magic; can we get some defines?

OK, I can use something like ORB_FIRST_RESERVED_BIT - ORB_LAST_RESERVED_BIT


> 
>> +		orb->ctrl |= (0x01 << (31 - i));
>> +		snprintf(buffer, 80, " %d", i);
>> +		report_prefix_push(buffer);
>> +		expect_pgm_int();
>> +		ssch(test_device_sid, orb);
>> +		check_pgm_int_code(PGM_INT_CODE_OPERAND);
>> +		report_prefix_pop();
>> +
>> +		orb->ctrl = tmp;
>> +	}
>> +}
>> +
>>   static struct tests ssh_tests[] = {
>>   	{ "privilege", ssch_privilege },
>>   	{ "orb cpa zero", ssch_orb_cpa_zero },
>> @@ -217,6 +237,7 @@ static struct tests ssh_tests[] = {
>>   	{ "CCW access", ssch_ccw_access },
>>   	{ "CCW in DMA31", ssch_ccw_dma31 },
>>   	{ "ORB MIDAW unsupported", ssch_orb_midaw },
>> +	{ "ORB reserved CTRL bits", ssch_orb_ctrl },
>>   	{ NULL, NULL }
>>   };
>>   
> 

-- 
Pierre Morel
IBM Lab Boeblingen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW
  2021-04-07 10:06     ` Pierre Morel
@ 2021-04-07 10:14       ` Cornelia Huck
  0 siblings, 0 replies; 30+ messages in thread
From: Cornelia Huck @ 2021-04-07 10:14 UTC (permalink / raw)
  To: Pierre Morel; +Cc: kvm, frankja, david, thuth, imbrenda

On Wed, 7 Apr 2021 12:06:03 +0200
Pierre Morel <pmorel@linux.ibm.com> wrote:

> On 4/6/21 5:58 PM, Cornelia Huck wrote:
> > On Tue,  6 Apr 2021 09:40:48 +0200
> > Pierre Morel <pmorel@linux.ibm.com> wrote:
> >   
> >> Verify that using MIDAW triggers a operand exception.  
> > 
> > This is only for current QEMU; a future QEMU or another hypervisor may
> > support it. I think in those cases the failure mode may be different
> > (as the ccw does not use midaws?)  
> 
> Yes, should I let fall this test case?

I'm not sure how much value it adds, so I'm for dropping it.

Any other opinions?


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits
  2021-04-07 10:07     ` Pierre Morel
@ 2021-04-07 10:15       ` Cornelia Huck
  0 siblings, 0 replies; 30+ messages in thread
From: Cornelia Huck @ 2021-04-07 10:15 UTC (permalink / raw)
  To: Pierre Morel; +Cc: kvm, frankja, david, thuth, imbrenda

On Wed, 7 Apr 2021 12:07:13 +0200
Pierre Morel <pmorel@linux.ibm.com> wrote:

> On 4/6/21 5:51 PM, Cornelia Huck wrote:
> > On Tue,  6 Apr 2021 09:40:49 +0200
> > Pierre Morel <pmorel@linux.ibm.com> wrote:
> >   
> >> Several bits of the ORB are reserved and must be zero.
> >> Their use will trigger a operand exception.
> >>
> >> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> >> ---
> >>   s390x/css.c | 21 +++++++++++++++++++++
> >>   1 file changed, 21 insertions(+)
> >>
> >> diff --git a/s390x/css.c b/s390x/css.c
> >> index 56adc16..26f5da6 100644
> >> --- a/s390x/css.c
> >> +++ b/s390x/css.c
> >> @@ -209,6 +209,26 @@ static void ssch_orb_midaw(void)
> >>   	orb->ctrl = tmp;
> >>   }
> >>   
> >> +static void ssch_orb_ctrl(void)
> >> +{
> >> +	uint32_t tmp = orb->ctrl;
> >> +	char buffer[80];
> >> +	int i;
> >> +
> >> +	/* Check the reserved bits of the ORB CTRL field */
> >> +	for (i = 26; i <= 30; i++) {  
> > 
> > This looks very magic; can we get some defines?  
> 
> OK, I can use something like ORB_FIRST_RESERVED_BIT - ORB_LAST_RESERVED_BIT

Yep, something like that.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 13/16] s390x: css: checking for CSS extensions
  2021-04-06 15:50   ` Cornelia Huck
@ 2021-04-07 10:42     ` Pierre Morel
  0 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-07 10:42 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: kvm, frankja, david, thuth, imbrenda



On 4/6/21 5:50 PM, Cornelia Huck wrote:
> On Tue,  6 Apr 2021 09:40:50 +0200
> Pierre Morel <pmorel@linux.ibm.com> wrote:
> 
>> We verify that these extensions are not install before running simple
> 
> s/not install/installed/ ?
> 
> Testing extensions that are not installed does not make that much sense
> :)
> 
>> tests.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>>   lib/s390x/css.h |  2 ++
>>   s390x/css.c     | 31 +++++++++++++++++++++++++++++++
>>   2 files changed, 33 insertions(+)
>>
>> diff --git a/lib/s390x/css.h b/lib/s390x/css.h
>> index d824e34..08b2974 100644
>> --- a/lib/s390x/css.h
>> +++ b/lib/s390x/css.h
>> @@ -338,7 +338,9 @@ struct chsc_scsc {
>>   	uint8_t reserved[9];
>>   	struct chsc_header res;
>>   	uint32_t res_fmt;
>> +#define CSSC_ORB_EXTENSIONS		0
>>   #define CSSC_EXTENDED_MEASUREMENT_BLOCK 48
>> +#define CSSC_FC_EXTENSIONS		88
>>   	uint64_t general_char[255];
>>   	uint64_t chsc_char[254];
>>   };
>> diff --git a/s390x/css.c b/s390x/css.c
>> index 26f5da6..f8c6688 100644
>> --- a/s390x/css.c
>> +++ b/s390x/css.c
>> @@ -229,6 +229,35 @@ static void ssch_orb_ctrl(void)
>>   	}
>>   }
>>   
>> +static void ssch_orb_extension(void)
>> +{
>> +	if (!css_test_general_feature(CSSC_ORB_EXTENSIONS)) {
>> +		report_skip("ORB extensions not installed");
>> +		return;
>> +	}
>> +	/* Place holder for checking ORB extensions */
>> +	report_info("ORB extensions installed but not tested");
>> +}
>> +
>> +static void ssch_orb_fcx(void)
>> +{
>> +	uint32_t tmp = orb->ctrl;
>> +
>> +	if (!css_test_general_feature(CSSC_FC_EXTENSIONS)) {
>> +		report_skip("Fibre-channel extensions not installed");
>> +		return;
>> +	}
>> +
>> +	report_prefix_push("Channel-Program Type Control");
>> +	orb->ctrl |= ORB_CTRL_CPTC;
>> +	expect_pgm_int();
>> +	ssch(test_device_sid, orb);
>> +	check_pgm_int_code(PGM_INT_CODE_OPERAND);
>> +	report_prefix_pop();
> 
> I don't quite understand what you're testing here; shouldn't the device
> accept a transport-mode orb if fcx is installed? The problem would be
> if the program consists of ccws instead, so it's more a malformed block
> handling test?

Yes, OK, non sense.
I let fall this test.

-- 
Pierre Morel
IBM Lab Boeblingen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 14/16] s390x: css: issuing SSCH when the channel is status pending
  2021-04-06 15:34   ` Cornelia Huck
@ 2021-04-07 10:46     ` Pierre Morel
  0 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-07 10:46 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: kvm, frankja, david, thuth, imbrenda



On 4/6/21 5:34 PM, Cornelia Huck wrote:
> On Tue,  6 Apr 2021 09:40:51 +0200
> Pierre Morel <pmorel@linux.ibm.com> wrote:
> 
>> We await CC=1 when we issue a SSCH on a channel with status pending.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>>   lib/s390x/css.h |  2 ++
>>   s390x/css.c     | 10 ++++++++++
>>   2 files changed, 12 insertions(+)
>>
>> diff --git a/lib/s390x/css.h b/lib/s390x/css.h
>> index 08b2974..3eb6957 100644
>> --- a/lib/s390x/css.h
>> +++ b/lib/s390x/css.h
>> @@ -90,6 +90,8 @@ struct scsw {
>>   #define SCSW_ESW_FORMAT		0x04000000
>>   #define SCSW_SUSPEND_CTRL	0x08000000
>>   #define SCSW_KEY		0xf0000000
>> +#define SCSW_SSCH_COMPLETED	(SCSW_CCW_FORMAT | SCSW_FC_START | SCSW_SC_PENDING | SCSW_SC_SECONDARY | \
>> +				 SCSW_SC_PRIMARY)
>>   	uint32_t ctrl;
>>   	uint32_t ccw_addr;
>>   #define SCSW_DEVS_DEV_END	0x04
>> diff --git a/s390x/css.c b/s390x/css.c
>> index f8c6688..52264f2 100644
>> --- a/s390x/css.c
>> +++ b/s390x/css.c
>> @@ -258,6 +258,15 @@ static void ssch_orb_fcx(void)
>>   	orb->ctrl = tmp;
>>   }
>>   
>> +static void ssch_status_pending(void)
>> +{
>> +	assert(ssch(test_device_sid, orb) == 0);
>> +	report(ssch(test_device_sid, orb) == 1, "CC = 1");
> 
> I don't think that's correct in the general case (although it will work
> for QEMU).
> 
> The PoP has a note about some models discarding the status pending, if
> we have secondary status only (although I don't think that would happen
> with this sequence.) You might also end up with cc 2 here, I think. In
> theory, you could also get a cc 3 on real hardware, but that would be a
> real edge case, and subsequent tests would fail anyway.


OK, yes and it could also fail if we introduce asynchronousity in QEMU 
CCW too.
So I let fall all tests about starting a second instruction before 
testing the sub channel.
I have more in csch and hsch...

> 
>> +	/* now we clear the status */
>> +	assert(tsch(test_device_sid, &irb) == 0);
>> +	check_io_completion(test_device_sid, SCSW_SSCH_COMPLETED);
>> +}
>> +
>>   static struct tests ssh_tests[] = {
>>   	{ "privilege", ssch_privilege },
>>   	{ "orb cpa zero", ssch_orb_cpa_zero },
>> @@ -269,6 +278,7 @@ static struct tests ssh_tests[] = {
>>   	{ "ORB reserved CTRL bits", ssch_orb_ctrl },
>>   	{ "ORB extensions", ssch_orb_extension},
>>   	{ "FC extensions", ssch_orb_fcx},
>> +	{ "status pending before ssch", ssch_status_pending},
>>   	{ NULL, NULL }
>>   };
>>   
> 

-- 
Pierre Morel
IBM Lab Boeblingen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [kvm-unit-tests PATCH v3 03/16] s390x: css: simplify skipping tests on no device
  2021-04-06 12:44   ` Cornelia Huck
@ 2021-04-07 10:53     ` Pierre Morel
  0 siblings, 0 replies; 30+ messages in thread
From: Pierre Morel @ 2021-04-07 10:53 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: kvm, frankja, david, thuth, imbrenda



On 4/6/21 2:44 PM, Cornelia Huck wrote:
> On Tue,  6 Apr 2021 09:40:40 +0200
> Pierre Morel <pmorel@linux.ibm.com> wrote:
> 
>> We will have to test if a device is present for every tests
>> in the future.
>> Let's provide separate the first tests from the test loop and
>> skip the remaining tests if no device is present.
> 
> What about the following patch description:
> 
> "We keep adding tests that act upon a concrete device, and we have to
> test that a device is present for all of those.
> 
> Instead, just skip all of the tests requiring a device if we were not
> able to set it up in the first place. The enumeration test will already
> have failed in that case."

ok yes better.

> 
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>>   s390x/css.c | 36 ++++++++++++++----------------------
>>   1 file changed, 14 insertions(+), 22 deletions(-)
>>
> 
> (...)
> 
>> @@ -336,8 +316,6 @@ static struct {
>>   	void (*func)(void);
>>   } tests[] = {
>>   	/* The css_init test is needed to initialize the CSS Characteristics */
> 
> If you remove the css_init test from this list, the above comment does
> not make sense anymore :)


grrr I thought I did remove this.
will do.

> 
>> -	{ "initialize CSS (chsc)", css_init },
>> -	{ "enumerate (stsch)", test_enumerate },
>>   	{ "enable (msch)", test_enable },
>>   	{ "sense (ssch/tsch)", test_sense },
>>   	{ "measurement block (schm)", test_schm },
>> @@ -352,11 +330,25 @@ int main(int argc, char *argv[])
>>   
>>   	report_prefix_push("Channel Subsystem");
>>   	enable_io_isc(0x80 >> IO_SCH_ISC);
>> +
>> +	report_prefix_push("initialize CSS (chsc)");
>> +	css_init();
>> +	report_prefix_pop();
>> +
>> +	report_prefix_push("enumerate (stsch)");
>> +	test_enumerate();
>> +	report_prefix_pop();
> 
> Could we maybe have two lists of tests: one that don't require a
> device, and one that does?

Yes, I can do that.

> 
>> +
>> +	if (!test_device_sid)
>> +		goto end;
> 
> In any case, I think we should log an explicit message that we skip the
> remaining tests because of no device being available.

OK, I will re-arrange the test order.

Thanks,
Pierre

-- 
Pierre Morel
IBM Lab Boeblingen

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2021-04-07 10:53 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06  7:40 [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 01/16] s390x: lib: css: disabling a subchannel Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 02/16] s390x: lib: css: SCSW bit definitions Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 03/16] s390x: css: simplify skipping tests on no device Pierre Morel
2021-04-06 12:44   ` Cornelia Huck
2021-04-07 10:53     ` Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 04/16] s390x: lib: css: separate wait for IRQ and check I/O completion Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 05/16] s390x: lib: css: add SCSW ctrl expectations to " Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 06/16] s390x: lib: css: checking I/O errors Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 07/16] s390x: css: testing ssch errors Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 08/16] s390x: css: ssch check for cpa zero Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 09/16] s390x: css: ssch with mis aligned ORB Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 10/16] s390x: css: ssch checking addressing errors Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW Pierre Morel
2021-04-06 15:58   ` Cornelia Huck
2021-04-07 10:06     ` Pierre Morel
2021-04-07 10:14       ` Cornelia Huck
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits Pierre Morel
2021-04-06 15:51   ` Cornelia Huck
2021-04-07 10:07     ` Pierre Morel
2021-04-07 10:15       ` Cornelia Huck
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 13/16] s390x: css: checking for CSS extensions Pierre Morel
2021-04-06 15:50   ` Cornelia Huck
2021-04-07 10:42     ` Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 14/16] s390x: css: issuing SSCH when the channel is status pending Pierre Morel
2021-04-06 15:34   ` Cornelia Huck
2021-04-07 10:46     ` Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 15/16] s390x: css: testing halt subchannel Pierre Morel
2021-04-06  7:40 ` [kvm-unit-tests PATCH v3 16/16] s390x: css: testing clear subchannel Pierre Morel
2021-04-06 12:21 ` [kvm-unit-tests PATCH v3 00/16] s390x: Testing SSCH, CSCH and HSCH for errors Pierre Morel

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.