kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v2 0/7] s390x: smp: Improve smp code and reset checks
@ 2020-01-16 12:05 Janosch Frank
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 1/7] s390x: smp: Cleanup smp.c Janosch Frank
                   ` (6 more replies)
  0 siblings, 7 replies; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 12:05 UTC (permalink / raw)
  To: kvm; +Cc: thuth, borntraeger, linux-s390, david, cohuck

Let's extend sigp reset testing and clean up the smp library as well.

GIT: https://github.com/frankjaa/kvm-unit-tests/tree/smp_cleanup

v2:
	* Added cpu stop to test_store_status()
	* Added smp_cpu_destroy() to the end of smp.c main()
	* New patch that prints cpu id on interrupt errors
	* New patch that reworks cpu start in the smp library (needed for lpar)
	* New patch that waits for cpu setup in smp_cpu_setup() (needed for lpar)
	* nullp is now an array

Janosch Frank (7):
  s390x: smp: Cleanup smp.c
  s390x: smp: Only use smp_cpu_setup once
  s390x: Add cpu id to interrupt error prints
  s390x: smp: Rework cpu start and active tracking
  s390x: smp: Wait for cpu setup to finish
  s390x: smp: Test all CRs on initial reset
  s390x: smp: Dirty fpc before initial reset test

 lib/s390x/interrupt.c | 20 +++++------
 lib/s390x/smp.c       | 47 +++++++++++++-----------
 s390x/cstart64.S      |  2 ++
 s390x/smp.c           | 84 +++++++++++++++++++++++++++++--------------
 4 files changed, 96 insertions(+), 57 deletions(-)

-- 
2.20.1


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

* [kvm-unit-tests PATCH v2 1/7] s390x: smp: Cleanup smp.c
  2020-01-16 12:05 [kvm-unit-tests PATCH v2 0/7] s390x: smp: Improve smp code and reset checks Janosch Frank
@ 2020-01-16 12:05 ` Janosch Frank
  2020-01-16 12:13   ` David Hildenbrand
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 2/7] s390x: smp: Only use smp_cpu_setup once Janosch Frank
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 12:05 UTC (permalink / raw)
  To: kvm; +Cc: thuth, borntraeger, linux-s390, david, cohuck

Let's remove a lot of badly formatted code by introducing the
wait_for_flag() function.

Also let's remove some stray spaces.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
 s390x/smp.c | 42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/s390x/smp.c b/s390x/smp.c
index ab7e46c..02204fd 100644
--- a/s390x/smp.c
+++ b/s390x/smp.c
@@ -22,6 +22,13 @@
 
 static int testflag = 0;
 
+static void wait_for_flag(void)
+{
+	while (!testflag) {
+		mb();
+	}
+}
+
 static void cpu_loop(void)
 {
 	for (;;) {}
@@ -37,13 +44,11 @@ static void test_func(void)
 static void test_start(void)
 {
 	struct psw psw;
-	psw.mask =  extract_psw_mask();
+	psw.mask = extract_psw_mask();
 	psw.addr = (unsigned long)test_func;
 
 	smp_cpu_setup(1, psw);
-	while (!testflag) {
-		mb();
-	}
+	wait_for_flag();
 	report(1, "start");
 }
 
@@ -98,6 +103,7 @@ static void test_store_status(void)
 	report(1, "status written");
 	free_pages(status, PAGE_SIZE * 2);
 	report_prefix_pop();
+	smp_cpu_stop(1);
 
 	report_prefix_pop();
 }
@@ -115,24 +121,24 @@ static void ecall(void)
 	testflag = 1;
 	while (lc->ext_int_code != 0x1202) { mb(); }
 	report(1, "ecall");
-	testflag= 1;
+	testflag = 1;
 }
 
 static void test_ecall(void)
 {
 	struct psw psw;
-	psw.mask =  extract_psw_mask();
+	psw.mask = extract_psw_mask();
 	psw.addr = (unsigned long)ecall;
 
 	report_prefix_push("ecall");
-	testflag= 0;
+	testflag = 0;
 	smp_cpu_destroy(1);
 
 	smp_cpu_setup(1, psw);
-	while (!testflag) { mb(); }
-	testflag= 0;
+	wait_for_flag();
+	testflag = 0;
 	sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
-	while(!testflag) {mb();}
+	wait_for_flag();
 	smp_cpu_stop(1);
 	report_prefix_pop();
 }
@@ -147,7 +153,7 @@ static void emcall(void)
 	mask = extract_psw_mask();
 	mask |= PSW_MASK_EXT;
 	load_psw_mask(mask);
-	testflag= 1;
+	testflag = 1;
 	while (lc->ext_int_code != 0x1201) { mb(); }
 	report(1, "ecall");
 	testflag = 1;
@@ -156,18 +162,18 @@ static void emcall(void)
 static void test_emcall(void)
 {
 	struct psw psw;
-	psw.mask =  extract_psw_mask();
+	psw.mask = extract_psw_mask();
 	psw.addr = (unsigned long)emcall;
 
 	report_prefix_push("emcall");
-	testflag= 0;
+	testflag = 0;
 	smp_cpu_destroy(1);
 
 	smp_cpu_setup(1, psw);
-	while (!testflag) { mb(); }
-	testflag= 0;
+	wait_for_flag();
+	testflag = 0;
 	sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL);
-	while(!testflag) { mb(); }
+	wait_for_flag();
 	smp_cpu_stop(1);
 	report_prefix_pop();
 }
@@ -177,7 +183,7 @@ static void test_reset_initial(void)
 	struct cpu_status *status = alloc_pages(0);
 	struct psw psw;
 
-	psw.mask =  extract_psw_mask();
+	psw.mask = extract_psw_mask();
 	psw.addr = (unsigned long)test_func;
 
 	report_prefix_push("reset initial");
@@ -208,7 +214,7 @@ static void test_reset(void)
 {
 	struct psw psw;
 
-	psw.mask =  extract_psw_mask();
+	psw.mask = extract_psw_mask();
 	psw.addr = (unsigned long)test_func;
 
 	report_prefix_push("cpu reset");
-- 
2.20.1


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

* [kvm-unit-tests PATCH v2 2/7] s390x: smp: Only use smp_cpu_setup once
  2020-01-16 12:05 [kvm-unit-tests PATCH v2 0/7] s390x: smp: Improve smp code and reset checks Janosch Frank
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 1/7] s390x: smp: Cleanup smp.c Janosch Frank
@ 2020-01-16 12:05 ` Janosch Frank
  2020-01-16 12:18   ` David Hildenbrand
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints Janosch Frank
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 12:05 UTC (permalink / raw)
  To: kvm; +Cc: thuth, borntraeger, linux-s390, david, cohuck

Let's stop and start instead of using setup to run a function on a
cpu.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
 s390x/smp.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/s390x/smp.c b/s390x/smp.c
index 02204fd..d430638 100644
--- a/s390x/smp.c
+++ b/s390x/smp.c
@@ -47,7 +47,7 @@ static void test_start(void)
 	psw.mask = extract_psw_mask();
 	psw.addr = (unsigned long)test_func;
 
-	smp_cpu_setup(1, psw);
+	smp_cpu_start(1, psw);
 	wait_for_flag();
 	report(1, "start");
 }
@@ -132,9 +132,8 @@ static void test_ecall(void)
 
 	report_prefix_push("ecall");
 	testflag = 0;
-	smp_cpu_destroy(1);
 
-	smp_cpu_setup(1, psw);
+	smp_cpu_start(1, psw);
 	wait_for_flag();
 	testflag = 0;
 	sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
@@ -167,9 +166,8 @@ static void test_emcall(void)
 
 	report_prefix_push("emcall");
 	testflag = 0;
-	smp_cpu_destroy(1);
 
-	smp_cpu_setup(1, psw);
+	smp_cpu_start(1, psw);
 	wait_for_flag();
 	testflag = 0;
 	sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL);
@@ -187,7 +185,7 @@ static void test_reset_initial(void)
 	psw.addr = (unsigned long)test_func;
 
 	report_prefix_push("reset initial");
-	smp_cpu_setup(1, psw);
+	smp_cpu_start(1, psw);
 
 	sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
 	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
@@ -218,7 +216,7 @@ static void test_reset(void)
 	psw.addr = (unsigned long)test_func;
 
 	report_prefix_push("cpu reset");
-	smp_cpu_setup(1, psw);
+	smp_cpu_start(1, psw);
 
 	sigp_retry(1, SIGP_CPU_RESET, 0, NULL);
 	report(smp_cpu_stopped(1), "cpu stopped");
@@ -227,6 +225,7 @@ static void test_reset(void)
 
 int main(void)
 {
+	struct psw psw;
 	report_prefix_push("smp");
 
 	if (smp_query_num_cpus() == 1) {
@@ -234,6 +233,12 @@ int main(void)
 		goto done;
 	}
 
+	/* Setting up the cpu to give it a stack and lowcore */
+	psw.mask = extract_psw_mask();
+	psw.addr = (unsigned long)cpu_loop;
+	smp_cpu_setup(1, psw);
+	smp_cpu_stop(1);
+
 	test_start();
 	test_stop();
 	test_stop_store_status();
@@ -242,6 +247,7 @@ int main(void)
 	test_emcall();
 	test_reset();
 	test_reset_initial();
+	smp_cpu_destroy(1);
 
 done:
 	report_prefix_pop();
-- 
2.20.1


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

* [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints
  2020-01-16 12:05 [kvm-unit-tests PATCH v2 0/7] s390x: smp: Improve smp code and reset checks Janosch Frank
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 1/7] s390x: smp: Cleanup smp.c Janosch Frank
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 2/7] s390x: smp: Only use smp_cpu_setup once Janosch Frank
@ 2020-01-16 12:05 ` Janosch Frank
  2020-01-16 12:17   ` David Hildenbrand
  2020-01-16 13:59   ` Cornelia Huck
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 4/7] s390x: smp: Rework cpu start and active tracking Janosch Frank
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 12:05 UTC (permalink / raw)
  To: kvm; +Cc: thuth, borntraeger, linux-s390, david, cohuck

It's good to know which cpu broke the test.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 lib/s390x/interrupt.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
index 05f30be..773752a 100644
--- a/lib/s390x/interrupt.c
+++ b/lib/s390x/interrupt.c
@@ -107,8 +107,8 @@ static void fixup_pgm_int(void)
 void handle_pgm_int(void)
 {
 	if (!pgm_int_expected)
-		report_abort("Unexpected program interrupt: %d at %#lx, ilen %d\n",
-			     lc->pgm_int_code, lc->pgm_old_psw.addr,
+		report_abort("Unexpected program interrupt: %d on cpu %d at %#lx, ilen %d\n",
+			     lc->pgm_int_code, stap(), lc->pgm_old_psw.addr,
 			     lc->pgm_int_id);
 
 	pgm_int_expected = false;
@@ -119,8 +119,8 @@ void handle_ext_int(void)
 {
 	if (!ext_int_expected &&
 	    lc->ext_int_code != EXT_IRQ_SERVICE_SIG) {
-		report_abort("Unexpected external call interrupt (code %#x): at %#lx",
-			     lc->ext_int_code, lc->ext_old_psw.addr);
+		report_abort("Unexpected external call interrupt (code %#x): on cpu %d at %#lx",
+			     stap(), lc->ext_int_code, lc->ext_old_psw.addr);
 		return;
 	}
 
@@ -137,18 +137,18 @@ void handle_ext_int(void)
 
 void handle_mcck_int(void)
 {
-	report_abort("Unexpected machine check interrupt: at %#lx",
-		     lc->mcck_old_psw.addr);
+	report_abort("Unexpected machine check interrupt: on cpu %d at %#lx",
+		     stap(), lc->mcck_old_psw.addr);
 }
 
 void handle_io_int(void)
 {
-	report_abort("Unexpected io interrupt: at %#lx",
-		     lc->io_old_psw.addr);
+	report_abort("Unexpected io interrupt: on cpu %d at %#lx",
+		     stap(), lc->io_old_psw.addr);
 }
 
 void handle_svc_int(void)
 {
-	report_abort("Unexpected supervisor call interrupt: at %#lx",
-		     lc->svc_old_psw.addr);
+	report_abort("Unexpected supervisor call interrupt: on cpu %d at %#lx",
+		     stap(), lc->svc_old_psw.addr);
 }
-- 
2.20.1


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

* [kvm-unit-tests PATCH v2 4/7] s390x: smp: Rework cpu start and active tracking
  2020-01-16 12:05 [kvm-unit-tests PATCH v2 0/7] s390x: smp: Improve smp code and reset checks Janosch Frank
                   ` (2 preceding siblings ...)
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints Janosch Frank
@ 2020-01-16 12:05 ` Janosch Frank
  2020-01-16 14:14   ` Cornelia Huck
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 5/7] s390x: smp: Wait for cpu setup to finish Janosch Frank
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 12:05 UTC (permalink / raw)
  To: kvm; +Cc: thuth, borntraeger, linux-s390, david, cohuck

sigp is not synchronous on all hypervisors, so we need to wait until
the cpu runs until we return from the setup/start function.

As there was a lot of duplicate code a common function for cpu
restarts has been intropduced.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 lib/s390x/smp.c | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c
index f57f420..f984a34 100644
--- a/lib/s390x/smp.c
+++ b/lib/s390x/smp.c
@@ -104,35 +104,41 @@ int smp_cpu_stop_store_status(uint16_t addr)
 	return rc;
 }
 
+static int smp_cpu_restart_nolock(uint16_t addr, struct psw *psw)
+{
+	int rc;
+	struct cpu *cpu = smp_cpu_from_addr(addr);
+
+	if (!cpu)
+		return -1;
+	if (psw) {
+		cpu->lowcore->restart_new_psw.mask = psw->mask;
+		cpu->lowcore->restart_new_psw.addr = psw->addr;
+	}
+	rc = sigp(addr, SIGP_RESTART, 0, NULL);
+	if (rc)
+		return rc;
+	while (!smp_cpu_running(addr)) { mb(); }
+	cpu->active = true;
+	return 0;
+}
+
 int smp_cpu_restart(uint16_t addr)
 {
-	int rc = -1;
-	struct cpu *cpu;
+	int rc;
 
 	spin_lock(&lock);
-	cpu = smp_cpu_from_addr(addr);
-	if (cpu) {
-		rc = sigp(addr, SIGP_RESTART, 0, NULL);
-		cpu->active = true;
-	}
+	rc = smp_cpu_restart_nolock(addr, NULL);
 	spin_unlock(&lock);
 	return rc;
 }
 
 int smp_cpu_start(uint16_t addr, struct psw psw)
 {
-	int rc = -1;
-	struct cpu *cpu;
-	struct lowcore *lc;
+	int rc;
 
 	spin_lock(&lock);
-	cpu = smp_cpu_from_addr(addr);
-	if (cpu) {
-		lc = cpu->lowcore;
-		lc->restart_new_psw.mask = psw.mask;
-		lc->restart_new_psw.addr = psw.addr;
-		rc = sigp(addr, SIGP_RESTART, 0, NULL);
-	}
+	rc = smp_cpu_restart_nolock(addr, &psw);
 	spin_unlock(&lock);
 	return rc;
 }
@@ -192,10 +198,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
 	lc->sw_int_crs[0] = 0x0000000000040000UL;
 
 	/* Start processing */
-	rc = sigp_retry(cpu->addr, SIGP_RESTART, 0, NULL);
-	if (!rc)
-		cpu->active = true;
-
+	smp_cpu_restart_nolock(addr, NULL);
 out:
 	spin_unlock(&lock);
 	return rc;
-- 
2.20.1


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

* [kvm-unit-tests PATCH v2 5/7] s390x: smp: Wait for cpu setup to finish
  2020-01-16 12:05 [kvm-unit-tests PATCH v2 0/7] s390x: smp: Improve smp code and reset checks Janosch Frank
                   ` (3 preceding siblings ...)
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 4/7] s390x: smp: Rework cpu start and active tracking Janosch Frank
@ 2020-01-16 12:05 ` Janosch Frank
  2020-01-16 12:19   ` David Hildenbrand
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 6/7] s390x: smp: Test all CRs on initial reset Janosch Frank
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 7/7] s390x: smp: Dirty fpc before initial reset test Janosch Frank
  6 siblings, 1 reply; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 12:05 UTC (permalink / raw)
  To: kvm; +Cc: thuth, borntraeger, linux-s390, david, cohuck

We store the user provided psw address into restart new, so a psw
restart does not lead us through setup again.

Also we wait on smp_cpu_setup() until the cpu has finished setup
before returning. This is necessary for z/VM and LPAR where sigp is
asynchronous.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 lib/s390x/smp.c  | 2 ++
 s390x/cstart64.S | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c
index f984a34..0a0bc1c 100644
--- a/lib/s390x/smp.c
+++ b/lib/s390x/smp.c
@@ -199,6 +199,8 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
 
 	/* Start processing */
 	smp_cpu_restart_nolock(addr, NULL);
+	/* Wait until the cpu has finished setup and started the provided psw */
+	while (lc->restart_new_psw.addr != psw.addr) { mb(); }
 out:
 	spin_unlock(&lock);
 	return rc;
diff --git a/s390x/cstart64.S b/s390x/cstart64.S
index 86dd4c4..9af6bb3 100644
--- a/s390x/cstart64.S
+++ b/s390x/cstart64.S
@@ -159,6 +159,8 @@ smp_cpu_setup_state:
 	xgr	%r1, %r1
 	lmg     %r0, %r15, GEN_LC_SW_INT_GRS
 	lctlg   %c0, %c0, GEN_LC_SW_INT_CRS
+	/* We should only go once through cpu setup and not for every restart */
+	stg	%r14, GEN_LC_RESTART_NEW_PSW + 8
 	br	%r14
 
 pgm_int:
-- 
2.20.1


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

* [kvm-unit-tests PATCH v2 6/7] s390x: smp: Test all CRs on initial reset
  2020-01-16 12:05 [kvm-unit-tests PATCH v2 0/7] s390x: smp: Improve smp code and reset checks Janosch Frank
                   ` (4 preceding siblings ...)
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 5/7] s390x: smp: Wait for cpu setup to finish Janosch Frank
@ 2020-01-16 12:05 ` Janosch Frank
  2020-01-16 12:24   ` David Hildenbrand
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 7/7] s390x: smp: Dirty fpc before initial reset test Janosch Frank
  6 siblings, 1 reply; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 12:05 UTC (permalink / raw)
  To: kvm; +Cc: thuth, borntraeger, linux-s390, david, cohuck

All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values,
so we also need to test 1-13 and 15 for 0.

And while we're at it, let's also set some values to cr 1, 7 and 13, so
we can actually be sure that they will be zeroed.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/smp.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/s390x/smp.c b/s390x/smp.c
index d430638..ce3215d 100644
--- a/s390x/smp.c
+++ b/s390x/smp.c
@@ -176,16 +176,31 @@ static void test_emcall(void)
 	report_prefix_pop();
 }
 
+/* Used to dirty registers of cpu #1 before it is reset */
+static void test_func_initial(void)
+{
+	lctlg(1, 0x42000UL);
+	lctlg(7, 0x43000UL);
+	lctlg(13, 0x44000UL);
+	testflag = 1;
+	mb();
+	cpu_loop();
+}
+
 static void test_reset_initial(void)
 {
 	struct cpu_status *status = alloc_pages(0);
+	uint64_t nullp[12] = {};
 	struct psw psw;
 
 	psw.mask = extract_psw_mask();
-	psw.addr = (unsigned long)test_func;
+	psw.addr = (unsigned long)test_func_initial;
 
 	report_prefix_push("reset initial");
+	testflag = 0;
+	mb();
 	smp_cpu_start(1, psw);
+	wait_for_flag();
 
 	sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
 	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
@@ -196,6 +211,8 @@ static void test_reset_initial(void)
 	report(!status->fpc, "fpc");
 	report(!status->cputm, "cpu timer");
 	report(!status->todpr, "todpr");
+	report(!memcmp(&status->crs[1], nullp, sizeof(status->crs[1]) * 12), "cr1-13 == 0");
+	report(status->crs[15] == 0, "cr15 == 0");
 	report_prefix_pop();
 
 	report_prefix_push("initialized");
-- 
2.20.1


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

* [kvm-unit-tests PATCH v2 7/7] s390x: smp: Dirty fpc before initial reset test
  2020-01-16 12:05 [kvm-unit-tests PATCH v2 0/7] s390x: smp: Improve smp code and reset checks Janosch Frank
                   ` (5 preceding siblings ...)
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 6/7] s390x: smp: Test all CRs on initial reset Janosch Frank
@ 2020-01-16 12:05 ` Janosch Frank
  2020-01-17 10:20   ` David Hildenbrand
  6 siblings, 1 reply; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 12:05 UTC (permalink / raw)
  To: kvm; +Cc: thuth, borntraeger, linux-s390, david, cohuck

Let's dirty the fpc, before we test if the initial reset sets it to 0.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
 s390x/smp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/s390x/smp.c b/s390x/smp.c
index ce3215d..97a9dda 100644
--- a/s390x/smp.c
+++ b/s390x/smp.c
@@ -179,6 +179,9 @@ static void test_emcall(void)
 /* Used to dirty registers of cpu #1 before it is reset */
 static void test_func_initial(void)
 {
+	asm volatile(
+		"	sfpc	%0\n"
+		: : "d" (0x11) : );
 	lctlg(1, 0x42000UL);
 	lctlg(7, 0x43000UL);
 	lctlg(13, 0x44000UL);
-- 
2.20.1


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

* Re: [kvm-unit-tests PATCH v2 1/7] s390x: smp: Cleanup smp.c
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 1/7] s390x: smp: Cleanup smp.c Janosch Frank
@ 2020-01-16 12:13   ` David Hildenbrand
  2020-01-16 13:01     ` Janosch Frank
  0 siblings, 1 reply; 27+ messages in thread
From: David Hildenbrand @ 2020-01-16 12:13 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck

On 16.01.20 13:05, Janosch Frank wrote:
> Let's remove a lot of badly formatted code by introducing the
> wait_for_flag() function.
> 
> Also let's remove some stray spaces.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> ---
>  s390x/smp.c | 42 ++++++++++++++++++++++++------------------
>  1 file changed, 24 insertions(+), 18 deletions(-)
> 
> diff --git a/s390x/smp.c b/s390x/smp.c
> index ab7e46c..02204fd 100644
> --- a/s390x/smp.c
> +++ b/s390x/smp.c
> @@ -22,6 +22,13 @@
>  
>  static int testflag = 0;
>  
> +static void wait_for_flag(void)
> +{
> +	while (!testflag) {
> +		mb();
> +	}
> +}
> +
>  static void cpu_loop(void)
>  {
>  	for (;;) {}
> @@ -37,13 +44,11 @@ static void test_func(void)
>  static void test_start(void)
>  {
>  	struct psw psw;
> -	psw.mask =  extract_psw_mask();
> +	psw.mask = extract_psw_mask();
>  	psw.addr = (unsigned long)test_func;
>  
>  	smp_cpu_setup(1, psw);
> -	while (!testflag) {
> -		mb();
> -	}
> +	wait_for_flag();
>  	report(1, "start");
>  }
>  
> @@ -98,6 +103,7 @@ static void test_store_status(void)
>  	report(1, "status written");
>  	free_pages(status, PAGE_SIZE * 2);
>  	report_prefix_pop();
> +	smp_cpu_stop(1);

This hunk does not seem to belong into this patch.

Apart from that, looks good to me.


-- 
Thanks,

David / dhildenb


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

* Re: [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints Janosch Frank
@ 2020-01-16 12:17   ` David Hildenbrand
  2020-01-16 13:04     ` Janosch Frank
  2020-01-16 13:59   ` Cornelia Huck
  1 sibling, 1 reply; 27+ messages in thread
From: David Hildenbrand @ 2020-01-16 12:17 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck

On 16.01.20 13:05, Janosch Frank wrote:
> It's good to know which cpu broke the test.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  lib/s390x/interrupt.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
> index 05f30be..773752a 100644
> --- a/lib/s390x/interrupt.c
> +++ b/lib/s390x/interrupt.c
> @@ -107,8 +107,8 @@ static void fixup_pgm_int(void)
>  void handle_pgm_int(void)
>  {
>  	if (!pgm_int_expected)
> -		report_abort("Unexpected program interrupt: %d at %#lx, ilen %d\n",
> -			     lc->pgm_int_code, lc->pgm_old_psw.addr,
> +		report_abort("Unexpected program interrupt: %d on cpu %d at %#lx, ilen %d\n",
> +			     lc->pgm_int_code, stap(), lc->pgm_old_psw.addr,
>  			     lc->pgm_int_id);

nit: "cpu: %d"

>  
>  	pgm_int_expected = false;
> @@ -119,8 +119,8 @@ void handle_ext_int(void)
>  {
>  	if (!ext_int_expected &&
>  	    lc->ext_int_code != EXT_IRQ_SERVICE_SIG) {
> -		report_abort("Unexpected external call interrupt (code %#x): at %#lx",
> -			     lc->ext_int_code, lc->ext_old_psw.addr);
> +		report_abort("Unexpected external call interrupt (code %#x): on cpu %d at %#lx",
> +			     stap(), lc->ext_int_code, lc->ext_old_psw.addr);

nit: "(code %#x) on cpu: %d" ...

Same comment for the ones below

Reviewed-by: David Hildenbrand <david@redhat.com>

>  		return;
>  	}
>  
> @@ -137,18 +137,18 @@ void handle_ext_int(void)
>  
>  void handle_mcck_int(void)
>  {
> -	report_abort("Unexpected machine check interrupt: at %#lx",
> -		     lc->mcck_old_psw.addr);
> +	report_abort("Unexpected machine check interrupt: on cpu %d at %#lx",
> +		     stap(), lc->mcck_old_psw.addr);
>  }
>  
>  void handle_io_int(void)
>  {
> -	report_abort("Unexpected io interrupt: at %#lx",
> -		     lc->io_old_psw.addr);
> +	report_abort("Unexpected io interrupt: on cpu %d at %#lx",
> +		     stap(), lc->io_old_psw.addr);
>  }
>  
>  void handle_svc_int(void)
>  {
> -	report_abort("Unexpected supervisor call interrupt: at %#lx",
> -		     lc->svc_old_psw.addr);
> +	report_abort("Unexpected supervisor call interrupt: on cpu %d at %#lx",
> +		     stap(), lc->svc_old_psw.addr);
>  }
> 

-- 
Thanks,

David / dhildenb


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

* Re: [kvm-unit-tests PATCH v2 2/7] s390x: smp: Only use smp_cpu_setup once
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 2/7] s390x: smp: Only use smp_cpu_setup once Janosch Frank
@ 2020-01-16 12:18   ` David Hildenbrand
  2020-01-16 13:01     ` Janosch Frank
  0 siblings, 1 reply; 27+ messages in thread
From: David Hildenbrand @ 2020-01-16 12:18 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck

On 16.01.20 13:05, Janosch Frank wrote:
> Let's stop and start instead of using setup to run a function on a
> cpu.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> ---
>  s390x/smp.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/s390x/smp.c b/s390x/smp.c
> index 02204fd..d430638 100644
> --- a/s390x/smp.c
> +++ b/s390x/smp.c
> @@ -47,7 +47,7 @@ static void test_start(void)
>  	psw.mask = extract_psw_mask();
>  	psw.addr = (unsigned long)test_func;
>  
> -	smp_cpu_setup(1, psw);
> +	smp_cpu_start(1, psw);
>  	wait_for_flag();
>  	report(1, "start");
>  }
> @@ -132,9 +132,8 @@ static void test_ecall(void)
>  
>  	report_prefix_push("ecall");
>  	testflag = 0;
> -	smp_cpu_destroy(1);
>  
> -	smp_cpu_setup(1, psw);
> +	smp_cpu_start(1, psw);
>  	wait_for_flag();
>  	testflag = 0;
>  	sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
> @@ -167,9 +166,8 @@ static void test_emcall(void)
>  
>  	report_prefix_push("emcall");
>  	testflag = 0;
> -	smp_cpu_destroy(1);
>  
> -	smp_cpu_setup(1, psw);
> +	smp_cpu_start(1, psw);
>  	wait_for_flag();
>  	testflag = 0;
>  	sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL);
> @@ -187,7 +185,7 @@ static void test_reset_initial(void)
>  	psw.addr = (unsigned long)test_func;
>  
>  	report_prefix_push("reset initial");
> -	smp_cpu_setup(1, psw);
> +	smp_cpu_start(1, psw);
>  
>  	sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
>  	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
> @@ -218,7 +216,7 @@ static void test_reset(void)
>  	psw.addr = (unsigned long)test_func;
>  
>  	report_prefix_push("cpu reset");
> -	smp_cpu_setup(1, psw);
> +	smp_cpu_start(1, psw);
>  
>  	sigp_retry(1, SIGP_CPU_RESET, 0, NULL);
>  	report(smp_cpu_stopped(1), "cpu stopped");
> @@ -227,6 +225,7 @@ static void test_reset(void)
>  
>  int main(void)
>  {
> +	struct psw psw;
>  	report_prefix_push("smp");
>  
>  	if (smp_query_num_cpus() == 1) {
> @@ -234,6 +233,12 @@ int main(void)
>  		goto done;
>  	}
>  
> +	/* Setting up the cpu to give it a stack and lowcore */
> +	psw.mask = extract_psw_mask();
> +	psw.addr = (unsigned long)cpu_loop;
> +	smp_cpu_setup(1, psw);
> +	smp_cpu_stop(1);
> +
>  	test_start();
>  	test_stop();
>  	test_stop_store_status();
> @@ -242,6 +247,7 @@ int main(void)
>  	test_emcall();
>  	test_reset();
>  	test_reset_initial();
> +	smp_cpu_destroy(1);
>  
>  done:
>  	report_prefix_pop();
> 

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


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

* Re: [kvm-unit-tests PATCH v2 5/7] s390x: smp: Wait for cpu setup to finish
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 5/7] s390x: smp: Wait for cpu setup to finish Janosch Frank
@ 2020-01-16 12:19   ` David Hildenbrand
  0 siblings, 0 replies; 27+ messages in thread
From: David Hildenbrand @ 2020-01-16 12:19 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck

On 16.01.20 13:05, Janosch Frank wrote:
> We store the user provided psw address into restart new, so a psw
> restart does not lead us through setup again.
> 
> Also we wait on smp_cpu_setup() until the cpu has finished setup
> before returning. This is necessary for z/VM and LPAR where sigp is
> asynchronous.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  lib/s390x/smp.c  | 2 ++
>  s390x/cstart64.S | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c
> index f984a34..0a0bc1c 100644
> --- a/lib/s390x/smp.c
> +++ b/lib/s390x/smp.c
> @@ -199,6 +199,8 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
>  
>  	/* Start processing */
>  	smp_cpu_restart_nolock(addr, NULL);
> +	/* Wait until the cpu has finished setup and started the provided psw */
> +	while (lc->restart_new_psw.addr != psw.addr) { mb(); }
>  out:
>  	spin_unlock(&lock);
>  	return rc;
> diff --git a/s390x/cstart64.S b/s390x/cstart64.S
> index 86dd4c4..9af6bb3 100644
> --- a/s390x/cstart64.S
> +++ b/s390x/cstart64.S
> @@ -159,6 +159,8 @@ smp_cpu_setup_state:
>  	xgr	%r1, %r1
>  	lmg     %r0, %r15, GEN_LC_SW_INT_GRS
>  	lctlg   %c0, %c0, GEN_LC_SW_INT_CRS
> +	/* We should only go once through cpu setup and not for every restart */
> +	stg	%r14, GEN_LC_RESTART_NEW_PSW + 8
>  	br	%r14
>  
>  pgm_int:
> 


Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


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

* Re: [kvm-unit-tests PATCH v2 6/7] s390x: smp: Test all CRs on initial reset
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 6/7] s390x: smp: Test all CRs on initial reset Janosch Frank
@ 2020-01-16 12:24   ` David Hildenbrand
  2020-01-16 13:07     ` Janosch Frank
  0 siblings, 1 reply; 27+ messages in thread
From: David Hildenbrand @ 2020-01-16 12:24 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck

On 16.01.20 13:05, Janosch Frank wrote:
> All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values,
> so we also need to test 1-13 and 15 for 0.
> 
> And while we're at it, let's also set some values to cr 1, 7 and 13, so
> we can actually be sure that they will be zeroed.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  s390x/smp.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/s390x/smp.c b/s390x/smp.c
> index d430638..ce3215d 100644
> --- a/s390x/smp.c
> +++ b/s390x/smp.c
> @@ -176,16 +176,31 @@ static void test_emcall(void)
>  	report_prefix_pop();
>  }
>  
> +/* Used to dirty registers of cpu #1 before it is reset */
> +static void test_func_initial(void)
> +{
> +	lctlg(1, 0x42000UL);
> +	lctlg(7, 0x43000UL);
> +	lctlg(13, 0x44000UL);
> +	testflag = 1;
> +	mb();
> +	cpu_loop();

Can we make cpu_loop() the default when this function returns? (IOW, an
endless loop whenever a cpu finished executing the function?)

Do we need the mb() here?

> +}
> +
>  static void test_reset_initial(void)
>  {
>  	struct cpu_status *status = alloc_pages(0);
> +	uint64_t nullp[12] = {};
>  	struct psw psw;
>  
>  	psw.mask = extract_psw_mask();
> -	psw.addr = (unsigned long)test_func;
> +	psw.addr = (unsigned long)test_func_initial;
>  
>  	report_prefix_push("reset initial");
> +	testflag = 0;
> +	mb();
>  	smp_cpu_start(1, psw);
> +	wait_for_flag();
>  
>  	sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
>  	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
> @@ -196,6 +211,8 @@ static void test_reset_initial(void)
>  	report(!status->fpc, "fpc");
>  	report(!status->cputm, "cpu timer");
>  	report(!status->todpr, "todpr");
> +	report(!memcmp(&status->crs[1], nullp, sizeof(status->crs[1]) * 12), "cr1-13 == 0");
> +	report(status->crs[15] == 0, "cr15 == 0");
>  	report_prefix_pop();
>  
>  	report_prefix_push("initialized");
> 


-- 
Thanks,

David / dhildenb


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

* Re: [kvm-unit-tests PATCH v2 1/7] s390x: smp: Cleanup smp.c
  2020-01-16 12:13   ` David Hildenbrand
@ 2020-01-16 13:01     ` Janosch Frank
  0 siblings, 0 replies; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 13:01 UTC (permalink / raw)
  To: David Hildenbrand, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck


[-- Attachment #1.1: Type: text/plain, Size: 1593 bytes --]

On 1/16/20 1:13 PM, David Hildenbrand wrote:
> On 16.01.20 13:05, Janosch Frank wrote:
>> Let's remove a lot of badly formatted code by introducing the
>> wait_for_flag() function.
>>
>> Also let's remove some stray spaces.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
>> ---
>>  s390x/smp.c | 42 ++++++++++++++++++++++++------------------
>>  1 file changed, 24 insertions(+), 18 deletions(-)
>>
>> diff --git a/s390x/smp.c b/s390x/smp.c
>> index ab7e46c..02204fd 100644
>> --- a/s390x/smp.c
>> +++ b/s390x/smp.c
>> @@ -22,6 +22,13 @@
>>  
>>  static int testflag = 0;
>>  
>> +static void wait_for_flag(void)
>> +{
>> +	while (!testflag) {
>> +		mb();
>> +	}
>> +}
>> +
>>  static void cpu_loop(void)
>>  {
>>  	for (;;) {}
>> @@ -37,13 +44,11 @@ static void test_func(void)
>>  static void test_start(void)
>>  {
>>  	struct psw psw;
>> -	psw.mask =  extract_psw_mask();
>> +	psw.mask = extract_psw_mask();
>>  	psw.addr = (unsigned long)test_func;
>>  
>>  	smp_cpu_setup(1, psw);
>> -	while (!testflag) {
>> -		mb();
>> -	}
>> +	wait_for_flag();
>>  	report(1, "start");
>>  }
>>  
>> @@ -98,6 +103,7 @@ static void test_store_status(void)
>>  	report(1, "status written");
>>  	free_pages(status, PAGE_SIZE * 2);
>>  	report_prefix_pop();
>> +	smp_cpu_stop(1);
> 
> This hunk does not seem to belong into this patch.
> 
> Apart from that, looks good to me.

Hunk was moved to the next patch and I pushed the branch


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [kvm-unit-tests PATCH v2 2/7] s390x: smp: Only use smp_cpu_setup once
  2020-01-16 12:18   ` David Hildenbrand
@ 2020-01-16 13:01     ` Janosch Frank
  0 siblings, 0 replies; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 13:01 UTC (permalink / raw)
  To: David Hildenbrand, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck


[-- Attachment #1.1: Type: text/plain, Size: 2815 bytes --]

On 1/16/20 1:18 PM, David Hildenbrand wrote:
> On 16.01.20 13:05, Janosch Frank wrote:
>> Let's stop and start instead of using setup to run a function on a
>> cpu.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
>> ---
>>  s390x/smp.c | 20 +++++++++++++-------
>>  1 file changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/s390x/smp.c b/s390x/smp.c
>> index 02204fd..d430638 100644
>> --- a/s390x/smp.c
>> +++ b/s390x/smp.c
>> @@ -47,7 +47,7 @@ static void test_start(void)
>>  	psw.mask = extract_psw_mask();
>>  	psw.addr = (unsigned long)test_func;
>>  
>> -	smp_cpu_setup(1, psw);
>> +	smp_cpu_start(1, psw);
>>  	wait_for_flag();
>>  	report(1, "start");
>>  }
>> @@ -132,9 +132,8 @@ static void test_ecall(void)
>>  
>>  	report_prefix_push("ecall");
>>  	testflag = 0;
>> -	smp_cpu_destroy(1);
>>  
>> -	smp_cpu_setup(1, psw);
>> +	smp_cpu_start(1, psw);
>>  	wait_for_flag();
>>  	testflag = 0;
>>  	sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
>> @@ -167,9 +166,8 @@ static void test_emcall(void)
>>  
>>  	report_prefix_push("emcall");
>>  	testflag = 0;
>> -	smp_cpu_destroy(1);
>>  
>> -	smp_cpu_setup(1, psw);
>> +	smp_cpu_start(1, psw);
>>  	wait_for_flag();
>>  	testflag = 0;
>>  	sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL);
>> @@ -187,7 +185,7 @@ static void test_reset_initial(void)
>>  	psw.addr = (unsigned long)test_func;
>>  
>>  	report_prefix_push("reset initial");
>> -	smp_cpu_setup(1, psw);
>> +	smp_cpu_start(1, psw);
>>  
>>  	sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
>>  	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
>> @@ -218,7 +216,7 @@ static void test_reset(void)
>>  	psw.addr = (unsigned long)test_func;
>>  
>>  	report_prefix_push("cpu reset");
>> -	smp_cpu_setup(1, psw);
>> +	smp_cpu_start(1, psw);
>>  
>>  	sigp_retry(1, SIGP_CPU_RESET, 0, NULL);
>>  	report(smp_cpu_stopped(1), "cpu stopped");
>> @@ -227,6 +225,7 @@ static void test_reset(void)
>>  
>>  int main(void)
>>  {
>> +	struct psw psw;
>>  	report_prefix_push("smp");
>>  
>>  	if (smp_query_num_cpus() == 1) {
>> @@ -234,6 +233,12 @@ int main(void)
>>  		goto done;
>>  	}
>>  
>> +	/* Setting up the cpu to give it a stack and lowcore */
>> +	psw.mask = extract_psw_mask();
>> +	psw.addr = (unsigned long)cpu_loop;
>> +	smp_cpu_setup(1, psw);
>> +	smp_cpu_stop(1);
>> +
>>  	test_start();
>>  	test_stop();
>>  	test_stop_store_status();
>> @@ -242,6 +247,7 @@ int main(void)
>>  	test_emcall();
>>  	test_reset();
>>  	test_reset_initial();
>> +	smp_cpu_destroy(1);
>>  
>>  done:
>>  	report_prefix_pop();
>>
> 
> Acked-by: David Hildenbrand <david@redhat.com>
Thanks!



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints
  2020-01-16 12:17   ` David Hildenbrand
@ 2020-01-16 13:04     ` Janosch Frank
  2020-01-16 13:19       ` David Hildenbrand
  0 siblings, 1 reply; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 13:04 UTC (permalink / raw)
  To: David Hildenbrand, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck


[-- Attachment #1.1: Type: text/plain, Size: 2475 bytes --]

On 1/16/20 1:17 PM, David Hildenbrand wrote:
> On 16.01.20 13:05, Janosch Frank wrote:
>> It's good to know which cpu broke the test.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  lib/s390x/interrupt.c | 20 ++++++++++----------
>>  1 file changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
>> index 05f30be..773752a 100644
>> --- a/lib/s390x/interrupt.c
>> +++ b/lib/s390x/interrupt.c
>> @@ -107,8 +107,8 @@ static void fixup_pgm_int(void)
>>  void handle_pgm_int(void)
>>  {
>>  	if (!pgm_int_expected)
>> -		report_abort("Unexpected program interrupt: %d at %#lx, ilen %d\n",
>> -			     lc->pgm_int_code, lc->pgm_old_psw.addr,
>> +		report_abort("Unexpected program interrupt: %d on cpu %d at %#lx, ilen %d\n",
>> +			     lc->pgm_int_code, stap(), lc->pgm_old_psw.addr,
>>  			     lc->pgm_int_id);
> 
> nit: "cpu: %d"
> 
>>  
>>  	pgm_int_expected = false;
>> @@ -119,8 +119,8 @@ void handle_ext_int(void)
>>  {
>>  	if (!ext_int_expected &&
>>  	    lc->ext_int_code != EXT_IRQ_SERVICE_SIG) {
>> -		report_abort("Unexpected external call interrupt (code %#x): at %#lx",
>> -			     lc->ext_int_code, lc->ext_old_psw.addr);
>> +		report_abort("Unexpected external call interrupt (code %#x): on cpu %d at %#lx",
>> +			     stap(), lc->ext_int_code, lc->ext_old_psw.addr);
> 
> nit: "(code %#x) on cpu: %d" ...

So, should I move the old : or add a second one?

> 
> Same comment for the ones below
> 
> Reviewed-by: David Hildenbrand <david@redhat.com>
> 
>>  		return;
>>  	}
>>  
>> @@ -137,18 +137,18 @@ void handle_ext_int(void)
>>  
>>  void handle_mcck_int(void)
>>  {
>> -	report_abort("Unexpected machine check interrupt: at %#lx",
>> -		     lc->mcck_old_psw.addr);
>> +	report_abort("Unexpected machine check interrupt: on cpu %d at %#lx",
>> +		     stap(), lc->mcck_old_psw.addr);
>>  }
>>  
>>  void handle_io_int(void)
>>  {
>> -	report_abort("Unexpected io interrupt: at %#lx",
>> -		     lc->io_old_psw.addr);
>> +	report_abort("Unexpected io interrupt: on cpu %d at %#lx",
>> +		     stap(), lc->io_old_psw.addr);
>>  }
>>  
>>  void handle_svc_int(void)
>>  {
>> -	report_abort("Unexpected supervisor call interrupt: at %#lx",
>> -		     lc->svc_old_psw.addr);
>> +	report_abort("Unexpected supervisor call interrupt: on cpu %d at %#lx",
>> +		     stap(), lc->svc_old_psw.addr);
>>  }
>>
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [kvm-unit-tests PATCH v2 6/7] s390x: smp: Test all CRs on initial reset
  2020-01-16 12:24   ` David Hildenbrand
@ 2020-01-16 13:07     ` Janosch Frank
  2020-01-16 13:18       ` David Hildenbrand
  0 siblings, 1 reply; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 13:07 UTC (permalink / raw)
  To: David Hildenbrand, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck


[-- Attachment #1.1: Type: text/plain, Size: 2244 bytes --]

On 1/16/20 1:24 PM, David Hildenbrand wrote:
> On 16.01.20 13:05, Janosch Frank wrote:
>> All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values,
>> so we also need to test 1-13 and 15 for 0.
>>
>> And while we're at it, let's also set some values to cr 1, 7 and 13, so
>> we can actually be sure that they will be zeroed.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  s390x/smp.c | 19 ++++++++++++++++++-
>>  1 file changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/s390x/smp.c b/s390x/smp.c
>> index d430638..ce3215d 100644
>> --- a/s390x/smp.c
>> +++ b/s390x/smp.c
>> @@ -176,16 +176,31 @@ static void test_emcall(void)
>>  	report_prefix_pop();
>>  }
>>  
>> +/* Used to dirty registers of cpu #1 before it is reset */
>> +static void test_func_initial(void)
>> +{
>> +	lctlg(1, 0x42000UL);
>> +	lctlg(7, 0x43000UL);
>> +	lctlg(13, 0x44000UL);
>> +	testflag = 1;
>> +	mb();
>> +	cpu_loop();
> 
> Can we make cpu_loop() the default when this function returns? (IOW, an
> endless loop whenever a cpu finished executing the function?)

So adding it to cstart64.S after the br 14?

> 
> Do we need the mb() here?

Would the compiler reorder the lctlcg and testflag if it could?

> 
>> +}
>> +
>>  static void test_reset_initial(void)
>>  {
>>  	struct cpu_status *status = alloc_pages(0);
>> +	uint64_t nullp[12] = {};
>>  	struct psw psw;
>>  
>>  	psw.mask = extract_psw_mask();
>> -	psw.addr = (unsigned long)test_func;
>> +	psw.addr = (unsigned long)test_func_initial;
>>  
>>  	report_prefix_push("reset initial");
>> +	testflag = 0;
>> +	mb();
>>  	smp_cpu_start(1, psw);
>> +	wait_for_flag();
>>  
>>  	sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
>>  	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
>> @@ -196,6 +211,8 @@ static void test_reset_initial(void)
>>  	report(!status->fpc, "fpc");
>>  	report(!status->cputm, "cpu timer");
>>  	report(!status->todpr, "todpr");
>> +	report(!memcmp(&status->crs[1], nullp, sizeof(status->crs[1]) * 12), "cr1-13 == 0");
>> +	report(status->crs[15] == 0, "cr15 == 0");
>>  	report_prefix_pop();
>>  
>>  	report_prefix_push("initialized");
>>
> 
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [kvm-unit-tests PATCH v2 6/7] s390x: smp: Test all CRs on initial reset
  2020-01-16 13:07     ` Janosch Frank
@ 2020-01-16 13:18       ` David Hildenbrand
  0 siblings, 0 replies; 27+ messages in thread
From: David Hildenbrand @ 2020-01-16 13:18 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck

On 16.01.20 14:07, Janosch Frank wrote:
> On 1/16/20 1:24 PM, David Hildenbrand wrote:
>> On 16.01.20 13:05, Janosch Frank wrote:
>>> All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values,
>>> so we also need to test 1-13 and 15 for 0.
>>>
>>> And while we're at it, let's also set some values to cr 1, 7 and 13, so
>>> we can actually be sure that they will be zeroed.
>>>
>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>> ---
>>>  s390x/smp.c | 19 ++++++++++++++++++-
>>>  1 file changed, 18 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/s390x/smp.c b/s390x/smp.c
>>> index d430638..ce3215d 100644
>>> --- a/s390x/smp.c
>>> +++ b/s390x/smp.c
>>> @@ -176,16 +176,31 @@ static void test_emcall(void)
>>>  	report_prefix_pop();
>>>  }
>>>  
>>> +/* Used to dirty registers of cpu #1 before it is reset */
>>> +static void test_func_initial(void)
>>> +{
>>> +	lctlg(1, 0x42000UL);
>>> +	lctlg(7, 0x43000UL);
>>> +	lctlg(13, 0x44000UL);
>>> +	testflag = 1;
>>> +	mb();
>>> +	cpu_loop();
>>
>> Can we make cpu_loop() the default when this function returns? (IOW, an
>> endless loop whenever a cpu finished executing the function?)
> 
> So adding it to cstart64.S after the br 14?

Yes I think so.

> 
>>
>> Do we need the mb() here?
> 
> Would the compiler reorder the lctlcg and testflag if it could?

lctlg() does not have a "memory" constraint, so I guess it would be
valid if it would reorder.

I assume the mb() would have to be moved in front of the testflag=1?

-- 
Thanks,

David / dhildenb


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

* Re: [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints
  2020-01-16 13:04     ` Janosch Frank
@ 2020-01-16 13:19       ` David Hildenbrand
  0 siblings, 0 replies; 27+ messages in thread
From: David Hildenbrand @ 2020-01-16 13:19 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck

On 16.01.20 14:04, Janosch Frank wrote:
> On 1/16/20 1:17 PM, David Hildenbrand wrote:
>> On 16.01.20 13:05, Janosch Frank wrote:
>>> It's good to know which cpu broke the test.
>>>
>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>> ---
>>>  lib/s390x/interrupt.c | 20 ++++++++++----------
>>>  1 file changed, 10 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
>>> index 05f30be..773752a 100644
>>> --- a/lib/s390x/interrupt.c
>>> +++ b/lib/s390x/interrupt.c
>>> @@ -107,8 +107,8 @@ static void fixup_pgm_int(void)
>>>  void handle_pgm_int(void)
>>>  {
>>>  	if (!pgm_int_expected)
>>> -		report_abort("Unexpected program interrupt: %d at %#lx, ilen %d\n",
>>> -			     lc->pgm_int_code, lc->pgm_old_psw.addr,
>>> +		report_abort("Unexpected program interrupt: %d on cpu %d at %#lx, ilen %d\n",
>>> +			     lc->pgm_int_code, stap(), lc->pgm_old_psw.addr,
>>>  			     lc->pgm_int_id);
>>
>> nit: "cpu: %d"
>>
>>>  
>>>  	pgm_int_expected = false;
>>> @@ -119,8 +119,8 @@ void handle_ext_int(void)
>>>  {
>>>  	if (!ext_int_expected &&
>>>  	    lc->ext_int_code != EXT_IRQ_SERVICE_SIG) {
>>> -		report_abort("Unexpected external call interrupt (code %#x): at %#lx",
>>> -			     lc->ext_int_code, lc->ext_old_psw.addr);
>>> +		report_abort("Unexpected external call interrupt (code %#x): on cpu %d at %#lx",
>>> +			     stap(), lc->ext_int_code, lc->ext_old_psw.addr);
>>
>> nit: "(code %#x) on cpu: %d" ...
> 
> So, should I move the old : or add a second one?

No strong feelings, whatever you prefer. (you can also keep it
unchanged, it's just a test error output after all)


-- 
Thanks,

David / dhildenb


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

* Re: [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints Janosch Frank
  2020-01-16 12:17   ` David Hildenbrand
@ 2020-01-16 13:59   ` Cornelia Huck
  2020-01-16 14:11     ` Janosch Frank
  1 sibling, 1 reply; 27+ messages in thread
From: Cornelia Huck @ 2020-01-16 13:59 UTC (permalink / raw)
  To: Janosch Frank; +Cc: kvm, thuth, borntraeger, linux-s390, david

On Thu, 16 Jan 2020 07:05:09 -0500
Janosch Frank <frankja@linux.ibm.com> wrote:

> It's good to know which cpu broke the test.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  lib/s390x/interrupt.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)

With whatever formatting tweaks you choose:

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


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

* Re: [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints
  2020-01-16 13:59   ` Cornelia Huck
@ 2020-01-16 14:11     ` Janosch Frank
  0 siblings, 0 replies; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 14:11 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: kvm, thuth, borntraeger, linux-s390, david


[-- Attachment #1.1: Type: text/plain, Size: 532 bytes --]

On 1/16/20 2:59 PM, Cornelia Huck wrote:
> On Thu, 16 Jan 2020 07:05:09 -0500
> Janosch Frank <frankja@linux.ibm.com> wrote:
> 
>> It's good to know which cpu broke the test.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  lib/s390x/interrupt.c | 20 ++++++++++----------
>>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> With whatever formatting tweaks you choose:
> 
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Thanks!


I think I might just stick with the old formatting.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [kvm-unit-tests PATCH v2 4/7] s390x: smp: Rework cpu start and active tracking
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 4/7] s390x: smp: Rework cpu start and active tracking Janosch Frank
@ 2020-01-16 14:14   ` Cornelia Huck
  2020-01-16 14:44     ` Janosch Frank
  0 siblings, 1 reply; 27+ messages in thread
From: Cornelia Huck @ 2020-01-16 14:14 UTC (permalink / raw)
  To: Janosch Frank; +Cc: kvm, thuth, borntraeger, linux-s390, david

On Thu, 16 Jan 2020 07:05:10 -0500
Janosch Frank <frankja@linux.ibm.com> wrote:

> sigp is not synchronous on all hypervisors, so we need to wait until

"The architecture specifies that processing sigp orders may be
asynchronous, and this is indeed the case on some hypervisors, so..."

? (Or is that overkill?)

> the cpu runs until we return from the setup/start function.

s/until we return/before we return/

> 
> As there was a lot of duplicate code a common function for cpu

s/code/code,/

> restarts has been intropduced.

s/intropduced/introduced/

> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  lib/s390x/smp.c | 45 ++++++++++++++++++++++++---------------------
>  1 file changed, 24 insertions(+), 21 deletions(-)
> 
> diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c
> index f57f420..f984a34 100644
> --- a/lib/s390x/smp.c
> +++ b/lib/s390x/smp.c
> @@ -104,35 +104,41 @@ int smp_cpu_stop_store_status(uint16_t addr)
>  	return rc;
>  }
>  
> +static int smp_cpu_restart_nolock(uint16_t addr, struct psw *psw)
> +{
> +	int rc;
> +	struct cpu *cpu = smp_cpu_from_addr(addr);
> +
> +	if (!cpu)
> +		return -1;
> +	if (psw) {
> +		cpu->lowcore->restart_new_psw.mask = psw->mask;
> +		cpu->lowcore->restart_new_psw.addr = psw->addr;
> +	}
> +	rc = sigp(addr, SIGP_RESTART, 0, NULL);
> +	if (rc)
> +		return rc;
> +	while (!smp_cpu_running(addr)) { mb(); }

Maybe split this statement? Also, maybe add a comment

/*
 * The order has been accepted, but the actual restart may not
 * have been performed yet, so wait until the cpu is running.
 */

?

> +	cpu->active = true;
> +	return 0;
> +}

The changes look good to me AFAICS.

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


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

* Re: [kvm-unit-tests PATCH v2 4/7] s390x: smp: Rework cpu start and active tracking
  2020-01-16 14:14   ` Cornelia Huck
@ 2020-01-16 14:44     ` Janosch Frank
  2020-01-16 15:05       ` Cornelia Huck
  0 siblings, 1 reply; 27+ messages in thread
From: Janosch Frank @ 2020-01-16 14:44 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: kvm, thuth, borntraeger, linux-s390, david


[-- Attachment #1.1: Type: text/plain, Size: 2035 bytes --]

On 1/16/20 3:14 PM, Cornelia Huck wrote:
> On Thu, 16 Jan 2020 07:05:10 -0500
> Janosch Frank <frankja@linux.ibm.com> wrote:
> 
>> sigp is not synchronous on all hypervisors, so we need to wait until
> 
> "The architecture specifies that processing sigp orders may be
> asynchronous, and this is indeed the case on some hypervisors, so..."
> 
> ? (Or is that overkill?)
> 
>> the cpu runs until we return from the setup/start function.
> 
> s/until we return/before we return/
> 
>>
>> As there was a lot of duplicate code a common function for cpu
> 
> s/code/code,/
> 
>> restarts has been intropduced.
> 
> s/intropduced/introduced/
> 
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  lib/s390x/smp.c | 45 ++++++++++++++++++++++++---------------------
>>  1 file changed, 24 insertions(+), 21 deletions(-)
>>
>> diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c
>> index f57f420..f984a34 100644
>> --- a/lib/s390x/smp.c
>> +++ b/lib/s390x/smp.c
>> @@ -104,35 +104,41 @@ int smp_cpu_stop_store_status(uint16_t addr)
>>  	return rc;
>>  }
>>  
>> +static int smp_cpu_restart_nolock(uint16_t addr, struct psw *psw)
>> +{
>> +	int rc;
>> +	struct cpu *cpu = smp_cpu_from_addr(addr);
>> +
>> +	if (!cpu)
>> +		return -1;
>> +	if (psw) {
>> +		cpu->lowcore->restart_new_psw.mask = psw->mask;
>> +		cpu->lowcore->restart_new_psw.addr = psw->addr;
>> +	}
>> +	rc = sigp(addr, SIGP_RESTART, 0, NULL);
>> +	if (rc)
>> +		return rc;
>> +	while (!smp_cpu_running(addr)) { mb(); }
> 
> Maybe split this statement? Also, maybe add a comment

/* Wait until the target cpu is running */
?

This is not QEMU with two line ifs taking up 3 lines :)

> 
> /*
>  * The order has been accepted, but the actual restart may not
>  * have been performed yet, so wait until the cpu is running.
>  */
> 
> ?
> 
>> +	cpu->active = true;
>> +	return 0;
>> +}
> 
> The changes look good to me AFAICS.
> 
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Thanks!



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [kvm-unit-tests PATCH v2 4/7] s390x: smp: Rework cpu start and active tracking
  2020-01-16 14:44     ` Janosch Frank
@ 2020-01-16 15:05       ` Cornelia Huck
  0 siblings, 0 replies; 27+ messages in thread
From: Cornelia Huck @ 2020-01-16 15:05 UTC (permalink / raw)
  To: Janosch Frank; +Cc: kvm, thuth, borntraeger, linux-s390, david

[-- Attachment #1: Type: text/plain, Size: 1324 bytes --]

On Thu, 16 Jan 2020 15:44:24 +0100
Janosch Frank <frankja@linux.ibm.com> wrote:

> On 1/16/20 3:14 PM, Cornelia Huck wrote:
> > On Thu, 16 Jan 2020 07:05:10 -0500
> > Janosch Frank <frankja@linux.ibm.com> wrote:

> >> +static int smp_cpu_restart_nolock(uint16_t addr, struct psw *psw)
> >> +{
> >> +	int rc;
> >> +	struct cpu *cpu = smp_cpu_from_addr(addr);
> >> +
> >> +	if (!cpu)
> >> +		return -1;
> >> +	if (psw) {
> >> +		cpu->lowcore->restart_new_psw.mask = psw->mask;
> >> +		cpu->lowcore->restart_new_psw.addr = psw->addr;
> >> +	}
> >> +	rc = sigp(addr, SIGP_RESTART, 0, NULL);
> >> +	if (rc)
> >> +		return rc;
> >> +	while (!smp_cpu_running(addr)) { mb(); }  
> > 
> > Maybe split this statement? Also, maybe add a comment  
> 
> /* Wait until the target cpu is running */
> ?

Fine with me as well :)

> 
> This is not QEMU with two line ifs taking up 3 lines :)

Heh, it's just the style I'm used to :)

> 
> > 
> > /*
> >  * The order has been accepted, but the actual restart may not
> >  * have been performed yet, so wait until the cpu is running.
> >  */
> > 
> > ?
> >   
> >> +	cpu->active = true;
> >> +	return 0;
> >> +}  
> > 
> > The changes look good to me AFAICS.
> > 
> > Reviewed-by: Cornelia Huck <cohuck@redhat.com>  
> 
> Thanks!
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [kvm-unit-tests PATCH v2 7/7] s390x: smp: Dirty fpc before initial reset test
  2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 7/7] s390x: smp: Dirty fpc before initial reset test Janosch Frank
@ 2020-01-17 10:20   ` David Hildenbrand
  2020-01-17 10:29     ` Thomas Huth
  0 siblings, 1 reply; 27+ messages in thread
From: David Hildenbrand @ 2020-01-17 10:20 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: thuth, borntraeger, linux-s390, cohuck

On 16.01.20 13:05, Janosch Frank wrote:
> Let's dirty the fpc, before we test if the initial reset sets it to 0.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> ---
>  s390x/smp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/s390x/smp.c b/s390x/smp.c
> index ce3215d..97a9dda 100644
> --- a/s390x/smp.c
> +++ b/s390x/smp.c
> @@ -179,6 +179,9 @@ static void test_emcall(void)
>  /* Used to dirty registers of cpu #1 before it is reset */
>  static void test_func_initial(void)
>  {
> +	asm volatile(
> +		"	sfpc	%0\n"
> +		: : "d" (0x11) : );

FWIW, I'd make this one easier to read

asm volatile("sfpc %0\n" :: "d" (0x11));

or sth like that

Reviewed-by: David Hildenbrand <david@redhat.com>

>  	lctlg(1, 0x42000UL);
>  	lctlg(7, 0x43000UL);
>  	lctlg(13, 0x44000UL);
> 


-- 
Thanks,

David / dhildenb


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

* Re: [kvm-unit-tests PATCH v2 7/7] s390x: smp: Dirty fpc before initial reset test
  2020-01-17 10:20   ` David Hildenbrand
@ 2020-01-17 10:29     ` Thomas Huth
  2020-01-17 10:41       ` Janosch Frank
  0 siblings, 1 reply; 27+ messages in thread
From: Thomas Huth @ 2020-01-17 10:29 UTC (permalink / raw)
  To: David Hildenbrand, Janosch Frank, kvm; +Cc: borntraeger, linux-s390, cohuck

On 17/01/2020 11.20, David Hildenbrand wrote:
> On 16.01.20 13:05, Janosch Frank wrote:
>> Let's dirty the fpc, before we test if the initial reset sets it to 0.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
>> ---
>>  s390x/smp.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/s390x/smp.c b/s390x/smp.c
>> index ce3215d..97a9dda 100644
>> --- a/s390x/smp.c
>> +++ b/s390x/smp.c
>> @@ -179,6 +179,9 @@ static void test_emcall(void)
>>  /* Used to dirty registers of cpu #1 before it is reset */
>>  static void test_func_initial(void)
>>  {
>> +	asm volatile(
>> +		"	sfpc	%0\n"
>> +		: : "d" (0x11) : );
> 
> FWIW, I'd make this one easier to read
> 
> asm volatile("sfpc %0\n" :: "d" (0x11));

By the way, since it's only one line, you can also drop the \n here.

 Thomas


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

* Re: [kvm-unit-tests PATCH v2 7/7] s390x: smp: Dirty fpc before initial reset test
  2020-01-17 10:29     ` Thomas Huth
@ 2020-01-17 10:41       ` Janosch Frank
  0 siblings, 0 replies; 27+ messages in thread
From: Janosch Frank @ 2020-01-17 10:41 UTC (permalink / raw)
  To: Thomas Huth, David Hildenbrand, kvm; +Cc: borntraeger, linux-s390, cohuck


[-- Attachment #1.1: Type: text/plain, Size: 1050 bytes --]

On 1/17/20 11:29 AM, Thomas Huth wrote:
> On 17/01/2020 11.20, David Hildenbrand wrote:
>> On 16.01.20 13:05, Janosch Frank wrote:
>>> Let's dirty the fpc, before we test if the initial reset sets it to 0.
>>>
>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
>>> ---
>>>  s390x/smp.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/s390x/smp.c b/s390x/smp.c
>>> index ce3215d..97a9dda 100644
>>> --- a/s390x/smp.c
>>> +++ b/s390x/smp.c
>>> @@ -179,6 +179,9 @@ static void test_emcall(void)
>>>  /* Used to dirty registers of cpu #1 before it is reset */
>>>  static void test_func_initial(void)
>>>  {
>>> +	asm volatile(
>>> +		"	sfpc	%0\n"
>>> +		: : "d" (0x11) : );
>>
>> FWIW, I'd make this one easier to read
>>
>> asm volatile("sfpc %0\n" :: "d" (0x11));
> 
> By the way, since it's only one line, you can also drop the \n here.
> 
>  Thomas
> 

Both suggestions applied :)
Thanks!


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2020-01-17 10:41 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 12:05 [kvm-unit-tests PATCH v2 0/7] s390x: smp: Improve smp code and reset checks Janosch Frank
2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 1/7] s390x: smp: Cleanup smp.c Janosch Frank
2020-01-16 12:13   ` David Hildenbrand
2020-01-16 13:01     ` Janosch Frank
2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 2/7] s390x: smp: Only use smp_cpu_setup once Janosch Frank
2020-01-16 12:18   ` David Hildenbrand
2020-01-16 13:01     ` Janosch Frank
2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 3/7] s390x: Add cpu id to interrupt error prints Janosch Frank
2020-01-16 12:17   ` David Hildenbrand
2020-01-16 13:04     ` Janosch Frank
2020-01-16 13:19       ` David Hildenbrand
2020-01-16 13:59   ` Cornelia Huck
2020-01-16 14:11     ` Janosch Frank
2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 4/7] s390x: smp: Rework cpu start and active tracking Janosch Frank
2020-01-16 14:14   ` Cornelia Huck
2020-01-16 14:44     ` Janosch Frank
2020-01-16 15:05       ` Cornelia Huck
2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 5/7] s390x: smp: Wait for cpu setup to finish Janosch Frank
2020-01-16 12:19   ` David Hildenbrand
2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 6/7] s390x: smp: Test all CRs on initial reset Janosch Frank
2020-01-16 12:24   ` David Hildenbrand
2020-01-16 13:07     ` Janosch Frank
2020-01-16 13:18       ` David Hildenbrand
2020-01-16 12:05 ` [kvm-unit-tests PATCH v2 7/7] s390x: smp: Dirty fpc before initial reset test Janosch Frank
2020-01-17 10:20   ` David Hildenbrand
2020-01-17 10:29     ` Thomas Huth
2020-01-17 10:41       ` Janosch Frank

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).