Skip to contentSkip to conversation

s390x: Testing SSCH, CSCH and HSCH for errors

PATCH In review Pierre Morel 2 participants 30 messages Apr 6, 2021 – Apr 7, 2021 KVM

lore
Share & tools
lore
#0 lore raw

v3 cover s390x: Testing SSCH, CSCH and HSCH for errors

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(-)
Signature · 42 lines
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)
#1 lore raw

PATCH v3 1/16 s390x: lib: css: disabling a subchannel

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

---
 lib/s390x/css.h     |  1 +
 lib/s390x/css_lib.c | 63 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
lib/s390x/css.h +1 -0
index 7e3d261..b0de3a3 100644
@@ -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);
lib/s390x/css_lib.c +63 -0

69 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 2/16 s390x: lib: css: SCSW bit definitions

In reply to Pierre Morel

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

---
 lib/s390x/css.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
lib/s390x/css.h +23 -0
index b0de3a3..0058355 100644
@@ -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
Signature · 1 line
2.17.1
#3 lore raw

PATCH v3 3/16 s390x: css: simplify skipping tests on no device

In reply to Pierre Morel

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.

---
 s390x/css.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)
s390x/css.c +14 -22
index c340c53..17a6e1d 100644
@@ -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();
Signature · 1 line
2.17.1
#4 lore raw

Re: [kvm-unit-tests PATCH v3 03/16] s390x: css: simplify skipping tests on no device

Quoted 4 lines · On Tue, 6 Apr 2021 09:40:40 +0200 Pierre Morel <[email protected]> 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."

Quoted 6 lines
---
 s390x/css.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

(...)

s390x/css.c static struct { · line 318

Quoted 4 lines
s390x/css.c +0 -0
@@ -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 :)

Quoted 7 lines
s390x/css.c +0 -2
-	{ "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[])
 

s390x/css.c int main(int argc, char *argv[]) · line 340

Quoted 10 lines
s390x/css.c +8 -0
 	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?

s390x/css.c int main(int argc, char *argv[]) · line 343

Quoted 3 lines
s390x/css.c +3 -0
+
+	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.

Quoted 11 lines
s390x/css.c +3 -0
+
 	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();
#5 lore raw

Re: [kvm-unit-tests PATCH v3 03/16] s390x: css: simplify skipping tests on no device

Quoted 8 lines · Cornelia Huck
Quoted 4 lines · On Tue, 6 Apr 2021 09:40:40 +0200 Pierre Morel <[email protected]> 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.

Quoted 8 lines

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.

Quoted 10 lines
Quoted 7 lines
---
  s390x/css.c | 36 ++++++++++++++----------------------
  1 file changed, 14 insertions(+), 22 deletions(-)

(...)

Quoted 7 lines

s390x/css.c static struct { · line 318

Quoted 4 lines
s390x/css.c +0 -0
@@ -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.

Quoted 8 lines
Quoted 8 lines
s390x/css.c +0 -2
-	{ "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[])
 
Quoted 13 lines

s390x/css.c int main(int argc, char *argv[]) · line 340

Quoted 10 lines
s390x/css.c +8 -0
  	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.

Quoted 7 lines

s390x/css.c int main(int argc, char *argv[]) · line 343

Quoted 4 lines
s390x/css.c +3 -0
+
+	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

Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen
#6 lore raw

PATCH v3 4/16 s390x: lib: css: separate wait for IRQ and check I/O completion

In reply to Pierre Morel

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.

---
 lib/s390x/css.h     |  1 +
 lib/s390x/css_lib.c | 34 +++++++++++++++++++---------------
 2 files changed, 20 insertions(+), 15 deletions(-)
lib/s390x/css.h +1 -0
index 0058355..5d1e1f0 100644
@@ -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
lib/s390x/css_lib.c +19 -15
index 9711b0b..e81076a 100644
@@ -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;
Signature · 1 line
2.17.1
#7 lore raw

PATCH v3 5/16 s390x: lib: css: add SCSW ctrl expectations to check I/O completion

In reply to Pierre Morel

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.

---
 lib/s390x/css.h     |  4 ++--
 lib/s390x/css_lib.c | 21 ++++++++++++++++-----
 s390x/css.c         |  4 ++--
 3 files changed, 20 insertions(+), 9 deletions(-)
lib/s390x/css.h +2 -2
index 5d1e1f0..1603781 100644
@@ -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
lib/s390x/css_lib.c +16 -5
index e81076a..97bf032 100644
@@ -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",
s390x/css.c +2 -2
index 17a6e1d..f4b7af1 100644
@@ -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)
Signature · 1 line
2.17.1
#8 lore raw

PATCH v3 6/16 s390x: lib: css: checking I/O errors

In reply to Pierre Morel

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.

---
 lib/s390x/css.h     |  6 ++++--
 lib/s390x/css_lib.c | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)
lib/s390x/css.h +4 -2
index 1603781..a5a8427 100644
@@ -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
lib/s390x/css_lib.c +24 -0
index 97bf032..65159aa 100644
@@ -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.
Signature · 1 line
2.17.1
#9 lore raw

PATCH v3 7/16 s390x: css: testing ssch errors

In reply to Pierre Morel

Setup testing environment and check privilege.

---
 s390x/css.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 68 insertions(+), 4 deletions(-)
s390x/css.c +68 -4
index f4b7af1..da21ccc 100644
@@ -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 },
Signature · 1 line
2.17.1
#10 lore raw

PATCH v3 8/16 s390x: css: ssch check for cpa zero

In reply to Pierre Morel

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

---
 lib/s390x/css.h     |  1 +
 lib/s390x/css_lib.c |  4 ++--
 s390x/css.c         | 13 +++++++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)
lib/s390x/css.h +1 -0
index a5a8427..d824e34 100644
@@ -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
lib/s390x/css_lib.c +2 -2
index 65159aa..12ef874 100644
@@ -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;
s390x/css.c +13 -0
index da21ccc..d248cac 100644
@@ -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 }
 };
 
Signature · 1 line
2.17.1
#11 lore raw

PATCH v3 9/16 s390x: css: ssch with mis aligned ORB

In reply to Pierre Morel

We expect a specification exception for a misaligned ORB.

---
 s390x/css.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
s390x/css.c +21 -0
index d248cac..47452ba 100644
@@ -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 }
 };
 
Signature · 1 line
2.17.1
#12 lore raw

PATCH v3 10/16 s390x: css: ssch checking addressing errors

In reply to Pierre Morel

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

---
 s390x/css.c         | 79 +++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  8 +++--
 2 files changed, 85 insertions(+), 2 deletions(-)
s390x/css.c +79 -0
index 47452ba..f8f91cf 100644
@@ -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);
 }
 
 /*
s390x/unittests.cfg +6 -2
index 9f81a60..45569dc 100644
@@ -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
Signature · 1 line
2.17.1
#13 lore raw

PATCH v3 11/16 s390x: css: No support for MIDAW

In reply to Pierre Morel

Verify that using MIDAW triggers a operand exception.

---
 s390x/css.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
s390x/css.c +13 -0
index f8f91cf..56adc16 100644
@@ -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 }
 };
 
Signature · 1 line
2.17.1
#14 lore raw

Re: [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW

Quoted 1 line · On Tue, 6 Apr 2021 09:40:48 +0200 Pierre Morel <[email protected]> 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?)

Quoted 37 lines
---
 s390x/css.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
s390x/css.c +13 -0
index f8f91cf..56adc16 100644
@@ -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 }
 };
 
#15 lore raw

Re: [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW

Quoted 8 lines · Cornelia Huck
Quoted 1 line · On Tue, 6 Apr 2021 09:40:48 +0200 Pierre Morel <[email protected]> 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?

Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen
#16 lore raw

Re: [kvm-unit-tests PATCH v3 11/16] s390x: css: No support for MIDAW

Quoted 11 lines · On Wed, 7 Apr 2021 12:06:03 +0200 Pierre Morel <[email protected]> wrote:
Quoted 8 lines · Cornelia Huck
Quoted 1 line · On Tue, 6 Apr 2021 09:40:48 +0200 Pierre Morel <[email protected]> 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?

#17 lore raw

PATCH v3 12/16 s390x: css: Check ORB reserved bits

In reply to Pierre Morel

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

---
 s390x/css.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
s390x/css.c +21 -0
index 56adc16..26f5da6 100644
@@ -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 }
 };
 
Signature · 1 line
2.17.1
#18 lore raw

Re: [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits

Quoted 14 lines · On Tue, 6 Apr 2021 09:40:49 +0200 Pierre Morel <[email protected]> wrote:

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

---
 s390x/css.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
s390x/css.c +0 -0
index 56adc16..26f5da6 100644
@@ -209,6 +209,26 @@ static void ssch_orb_midaw(void)
 	orb->ctrl = tmp;

s390x/css.c static void ssch_orb_midaw(void) · line 219

Quoted 10 lines
s390x/css.c +8 -0
 }
 
+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?

Quoted 23 lines
s390x/css.c +13 -0
+		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 }
 };
 
#19 lore raw

Re: [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits

Quoted 19 lines · Cornelia Huck
Quoted 16 lines · On Tue, 6 Apr 2021 09:40:49 +0200 Pierre Morel <[email protected]> wrote:

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

---
  s390x/css.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
s390x/css.c +0 -0
index 56adc16..26f5da6 100644
@@ -209,6 +209,26 @@ static void ssch_orb_midaw(void)
  	orb->ctrl = tmp;
  }
 
Quoted 10 lines

s390x/css.c static void ssch_orb_midaw(void) · line 219

Quoted 8 lines
s390x/css.c +8 -0
+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

Quoted 25 lines
Quoted 24 lines
s390x/css.c +13 -0
+		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 }
  };
 
Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen
#20 lore raw

Re: [kvm-unit-tests PATCH v3 12/16] s390x: css: Check ORB reserved bits

Quoted 31 lines · On Wed, 7 Apr 2021 12:07:13 +0200 Pierre Morel <[email protected]> wrote:
Quoted 19 lines · Cornelia Huck
Quoted 16 lines · On Tue, 6 Apr 2021 09:40:49 +0200 Pierre Morel <[email protected]> wrote:

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

---
  s390x/css.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
s390x/css.c +0 -0
index 56adc16..26f5da6 100644
@@ -209,6 +209,26 @@ static void ssch_orb_midaw(void)
  	orb->ctrl = tmp;
  }
 
Quoted 10 lines

s390x/css.c static void ssch_orb_midaw(void) · line 219

Quoted 8 lines
s390x/css.c +8 -0
+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?

Quoted 1 line

OK, I can use something like ORB_FIRST_RESERVED_BIT - ORB_LAST_RESERVED_BIT

Yep, something like that.

#21 lore raw

PATCH v3 13/16 s390x: css: checking for CSS extensions

In reply to Pierre Morel

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

---
 lib/s390x/css.h |  2 ++
 s390x/css.c     | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
lib/s390x/css.h +2 -0
index d824e34..08b2974 100644
@@ -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];
 };
s390x/css.c +31 -0
index 26f5da6..f8c6688 100644
@@ -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 }
 };
 
Signature · 1 line
2.17.1
#22 lore raw

Re: [kvm-unit-tests PATCH v3 13/16] s390x: css: checking for CSS extensions

Quoted 1 line · On Tue, 6 Apr 2021 09:40:50 +0200 Pierre Morel <[email protected]> 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 :)

Quoted 45 lines

tests.

---
 lib/s390x/css.h |  2 ++
 s390x/css.c     | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
lib/s390x/css.h +2 -0
index d824e34..08b2974 100644
@@ -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];
 };
s390x/css.c +15 -0
index 26f5da6..f8c6688 100644
@@ -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)) {

s390x/css.c static void ssch_orb_ctrl(void) · line 256

Quoted 10 lines
s390x/css.c +10 -0
+		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?

Quoted 16 lines
s390x/css.c +6 -0
+
+	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 }
 };
 
#23 lore raw

Re: [kvm-unit-tests PATCH v3 13/16] s390x: css: checking for CSS extensions

Quoted 62 lines · Cornelia Huck
Quoted 1 line · On Tue, 6 Apr 2021 09:40:50 +0200 Pierre Morel <[email protected]> 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 :)

Quoted 52 lines

tests.

---
  lib/s390x/css.h |  2 ++
  s390x/css.c     | 31 +++++++++++++++++++++++++++++++
  2 files changed, 33 insertions(+)
lib/s390x/css.h +2 -0
index d824e34..08b2974 100644
@@ -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];
  };
s390x/css.c +22 -0
index 26f5da6..f8c6688 100644
@@ -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();
Quoted 8 lines

s390x/css.c static void ssch_orb_ctrl(void) · line 256

Quoted 3 lines
s390x/css.c +3 -0
+	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.

Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen
#24 lore raw

PATCH v3 14/16 s390x: css: issuing SSCH when the channel is status pending

In reply to Pierre Morel

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

---
 lib/s390x/css.h |  2 ++
 s390x/css.c     | 10 ++++++++++
 2 files changed, 12 insertions(+)
lib/s390x/css.h +2 -0
index 08b2974..3eb6957 100644
@@ -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
s390x/css.c +10 -0
index f8c6688..52264f2 100644
@@ -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 }
 };
 
Signature · 1 line
2.17.1
#25 lore raw

Re: [kvm-unit-tests PATCH v3 14/16] s390x: css: issuing SSCH when the channel is status pending

Quoted 26 lines · On Tue, 6 Apr 2021 09:40:51 +0200 Pierre Morel <[email protected]> wrote:

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

---
 lib/s390x/css.h |  2 ++
 s390x/css.c     | 10 ++++++++++
 2 files changed, 12 insertions(+)
lib/s390x/css.h +2 -0
index 08b2974..3eb6957 100644
@@ -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
s390x/css.c +0 -0
index f8c6688..52264f2 100644

s390x/css.c static void ssch_orb_fcx(void) · line 264

Quoted 7 lines
s390x/css.c +4 -0
@@ -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.

Quoted 16 lines
s390x/css.c +6 -0
+	/* 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 }
 };
 
#26 lore raw

Re: [kvm-unit-tests PATCH v3 14/16] s390x: css: issuing SSCH when the channel is status pending

Quoted 40 lines · Cornelia Huck
Quoted 26 lines · On Tue, 6 Apr 2021 09:40:51 +0200 Pierre Morel <[email protected]> wrote:

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

---
  lib/s390x/css.h |  2 ++
  s390x/css.c     | 10 ++++++++++
  2 files changed, 12 insertions(+)
lib/s390x/css.h +2 -0
index 08b2974..3eb6957 100644
@@ -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
s390x/css.c +0 -0
index f8c6688..52264f2 100644

s390x/css.c static void ssch_orb_fcx(void) · line 264

Quoted 7 lines
s390x/css.c +4 -0
@@ -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).

Quoted 5 lines

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...

Quoted 18 lines
Quoted 17 lines
s390x/css.c +6 -0
+	/* 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 }
  };
 
Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen
#27 lore raw

PATCH v3 15/16 s390x: css: testing halt subchannel

In reply to Pierre Morel

checking return values for HSCH for various configurations.

---
 lib/s390x/css.h     |  4 +++
 lib/s390x/css_lib.c |  4 +++
 s390x/css.c         | 63 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
lib/s390x/css.h +4 -0
index 3eb6957..90c8e4b 100644
@@ -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
lib/s390x/css_lib.c +4 -0
index 12ef874..4c4506a 100644
@@ -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);
s390x/css.c +63 -0

75 lines not on this page · raw message

Signature · 1 line
2.17.1
#28 lore raw

PATCH v3 16/16 s390x: css: testing clear subchannel

In reply to Pierre Morel

Checking return values for CSCH for various configurations.

---
 s390x/css.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
s390x/css.c +64 -0
index 0f80a44..00c77c7 100644
@@ -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 },
Signature · 1 line
2.17.1
#29 lore raw
In reply to Pierre Morel

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: <[email protected]>

Regards,
Pierre

Quoted 55 lines · Pierre Morel

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(-)
Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen