Skip to contentSkip to conversation

s390x updates

GIT PULL David Hildenbrand 2 participants 19 messages Apr 30, 2020 – May 4, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Paolo,

The following changes since commit 5c052c904ded7ecd80d8f7efe2803821b45ce483:

kvm-unit-tests: nSVM: Test that CR0[63:32] are not set on VMRUN of nested guests (2020-04-21 12:16:07 -0400)

are available in the Git repository at:

https://github.com/davidhildenbrand/kvm-unit-tests.git tags/s390x-2020-04-30

for you to fetch changes up to f7df29115f736b9ffe8e529ba9c2b418d2f5e736:

s390x: Fix library constant definitions (2020-04-30 16:52:14 +0200)

----------------------------------------------------------------
New maintainer, reviewer, and cc list. New STSI test. Lots of minor fixes and cleanups

----------------------------------------------------------------
Andrew Jones (1):

      s390x: unittests: Use smp parameter

Christian Borntraeger (2):

      s390x/smp: fix detection of "running"
      s390x/smp: add minimal test for sigp sense running status

Cornelia Huck (2):

      MAINTAINERS: s390x: add myself as reviewer
      MAINTAINERS: s390x: add linux-s390 list

David Hildenbrand (1):

      s390x: STFLE operates on doublewords

Janosch Frank (10):

      s390x: Add stsi 3.2.2 tests
      s390x: smp: Test all CRs on initial reset
      s390x: smp: Dirty fpc before initial reset test
      s390x: smp: Test stop and store status on a running and stopped cpu
      s390x: smp: Test local interrupts after cpu reset
      s390x: smp: Loop if secondary cpu returns into cpu setup again
      s390x: smp: Remove unneeded cpu loops
      s390x: smp: Use full PSW to bringup new cpu
      s390x: smp: Add restart when running test
      s390x: Fix library constant definitions

Thomas Huth (1):

      MAINTAINERS: Add Janosch as a s390x maintainer
 MAINTAINERS              |   4 +-
 lib/s390x/asm/arch_def.h |   8 ++--
 lib/s390x/asm/facility.h |  14 +++----
 lib/s390x/io.c           |   2 +-
 lib/s390x/smp.c          |   6 ++-
 lib/s390x/smp.h          |   2 +-
 s390x/cstart64.S         |   5 ++-
 s390x/smp.c              | 105 +++++++++++++++++++++++++++++++++++++++++++----
 s390x/stsi.c             |  73 ++++++++++++++++++++++++++++++++
 s390x/unittests.cfg      |   3 +-
 10 files changed, 196 insertions(+), 26 deletions(-)
#1 lore raw

[kvm-unit-tests PULL 01/17] MAINTAINERS: Add Janosch as a s390x maintainer

From: Thomas Huth <[email protected]>

Both, David and I, often do not have as much spare time for the kvm-unit-tests as we would like to have, so we could use a little bit of additional help here. Janosch did some excellent work for the s390x kvm-unit-tests in the past months and is listed as reviewer for these patches since quite a while already, so he's a very well suited for the maintainer job here, too.

Message-Id: <[email protected]>

---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
index 48da1db..082be95 100644
@@ -80,7 +80,7 @@ F: lib/ppc64/*
 S390X
 M: Thomas Huth <[email protected]>
 M: David Hildenbrand <[email protected]>
-R: Janosch Frank <[email protected]>
+M: Janosch Frank <[email protected]>
 L: [email protected]
 F: s390x/*
 F: lib/s390x/*
Signature · 1 line
2.25.3
#2 lore raw

[kvm-unit-tests PULL 02/17] MAINTAINERS: s390x: add myself as reviewer

In reply to David Hildenbrand

From: Cornelia Huck <[email protected]>

Message-Id: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 082be95..4642909 100644
@@ -81,6 +81,7 @@ S390X
 M: Thomas Huth <[email protected]>
 M: David Hildenbrand <[email protected]>
 M: Janosch Frank <[email protected]>
+R: Cornelia Huck <[email protected]>
 L: [email protected]
 F: s390x/*
 F: lib/s390x/*
Signature · 1 line
2.25.3
#3 lore raw

[kvm-unit-tests PULL 03/17] MAINTAINERS: s390x: add linux-s390 list

In reply to David Hildenbrand

From: Cornelia Huck <[email protected]>

It makes sense to cc: patches there as well.

Message-Id: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 4642909..52a3eb6 100644
@@ -83,6 +83,7 @@ M: David Hildenbrand <[email protected]>
 M: Janosch Frank <[email protected]>
 R: Cornelia Huck <[email protected]>
 L: [email protected]
+L: [email protected]
 F: s390x/*
 F: lib/s390x/*
 
Signature · 1 line
2.25.3
#4 lore raw

[kvm-unit-tests PULL 05/17] s390x/smp: fix detection of "running"

In reply to David Hildenbrand

From: Christian Borntraeger <[email protected]>

On s390x hosts with a single CPU, the smp test case hangs (loops). The check if our restart has finished is wrong.
Sigp sense running status checks if the CPU is currently backed by a real CPU. This means that on single CPU hosts a sigp sense running will never claim that a target is running. We need to check for not being stopped instead.

Message-Id: <[email protected]>

---
 lib/s390x/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/s390x/smp.c +1 -1
index 3f86243..203792a 100644
@@ -128,7 +128,7 @@ static int smp_cpu_restart_nolock(uint16_t addr, struct psw *psw)
 	 * The order has been accepted, but the actual restart may not
 	 * have been performed yet, so wait until the cpu is running.
 	 */
-	while (!smp_cpu_running(addr))
+	while (smp_cpu_stopped(addr))
 		mb();
 	cpu->active = true;
 	return 0;
Signature · 1 line
2.25.3
#5 lore raw

[kvm-unit-tests PULL 04/17] s390x: Add stsi 3.2.2 tests

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

Subcode 3.2.2 is handled by KVM/QEMU and should therefore be tested a bit more thoroughly.

In this test we set a custom name and uuid through the QEMU command line. Both parameters will be passed to the guest on a stsi subcode 3.2.2 call and will then be checked.

We also compare the configured cpu numbers against the smp reported numbers and if the reserved + configured add up to the total number reported.

Message-Id: <[email protected]>

---
 s390x/stsi.c        | 73 +++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  1 +
 2 files changed, 74 insertions(+)
s390x/stsi.c +73 -0
index e9206bc..66b4257 100644
@@ -14,7 +14,28 @@
 #include <asm/page.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
+#include <smp.h>
 
+struct stsi_322 {
+	uint8_t reserved[31];
+	uint8_t count;
+	struct {
+		uint8_t reserved2[4];
+		uint16_t total_cpus;
+		uint16_t conf_cpus;
+		uint16_t standby_cpus;
+		uint16_t reserved_cpus;
+		uint8_t name[8];
+		uint32_t caf;
+		uint8_t cpi[16];
+		uint8_t reserved5[3];
+		uint8_t ext_name_encoding;
+		uint32_t reserved3;
+		uint8_t uuid[16];
+	} vm[8];
+	uint8_t reserved4[1504];
+	uint8_t ext_names[8][256];
+};
 static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2)));
 
 static void test_specs(void)
@@ -76,11 +97,63 @@ static void test_fc(void)
 	report(stsi_get_fc(pagebuf) >= 2, "query fc >= 2");
 }
 
+static void test_3_2_2(void)
+{
+	int rc;
+	/* EBCDIC for "kvm-unit" */
+	const uint8_t vm_name[] = { 0x92, 0xa5, 0x94, 0x60, 0xa4, 0x95, 0x89,
+				    0xa3 };
+	const uint8_t uuid[] = { 0x0f, 0xb8, 0x4a, 0x86, 0x72, 0x7c,
+				 0x11, 0xea, 0xbc, 0x55, 0x02, 0x42, 0xac, 0x13,
+				 0x00, 0x03 };
+	/* EBCDIC for "KVM/" */
+	const uint8_t cpi_kvm[] = { 0xd2, 0xe5, 0xd4, 0x61 };
+	const char *vm_name_ext = "kvm-unit-test";
+	struct stsi_322 *data = (void *)pagebuf;
+
+	report_prefix_push("3.2.2");
+
+	/* Is the function code available at all? */
+	if (stsi_get_fc(pagebuf) < 3) {
+		report_skip("Running under lpar, no level 3 to test.");
+		goto out;
+	}
+
+	rc = stsi(pagebuf, 3, 2, 2);
+	report(!rc, "call");
+
+	/* For now we concentrate on KVM/QEMU */
+	if (memcmp(&data->vm[0].cpi, cpi_kvm, sizeof(cpi_kvm))) {
+		report_skip("Not running under KVM/QEMU.");
+		goto out;
+	}
+
+	report(!memcmp(data->vm[0].uuid, uuid, sizeof(uuid)), "uuid");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].total_cpus ==
+	       data->vm[0].reserved_cpus + data->vm[0].conf_cpus,
+	       "cpu # total == conf + reserved");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(!memcmp(data->vm[0].name, vm_name, sizeof(data->vm[0].name)),
+	       "VM name == kvm-unit-test");
+
+	if (data->vm[0].ext_name_encoding != 2) {
+		report_skip("Extended VM names are not UTF-8.");
+		goto out;
+	}
+	report(!memcmp(data->ext_names[0], vm_name_ext, sizeof(vm_name_ext)),
+		       "ext VM name == kvm-unit-test");
+
+out:
+	report_prefix_pop();
+}
+
 int main(void)
 {
 	report_prefix_push("stsi");
 	test_priv();
 	test_specs();
 	test_fc();
+	test_3_2_2();
 	return report_summary();
 }
s390x/unittests.cfg +1 -0
index 07013b2..535db21 100644
@@ -71,6 +71,7 @@ extra_params=-device diag288,id=watchdog0 --watchdog-action inject-nmi
 
 [stsi]
 file = stsi.elf
+extra_params=-name kvm-unit-test --uuid 0fb84a86-727c-11ea-bc55-0242ac130003 -smp 1,maxcpus=8
 
 [smp]
 file = smp.elf
Signature · 1 line
2.25.3
#6 lore raw

[kvm-unit-tests PULL 06/17] s390x: STFLE operates on doublewords

In reply to David Hildenbrand

STFLE operates on doublewords, not bytes. Passing in "256" resulted in some ignored bits getting set. Not bad, but also not clean.

Let's just convert our stfle handling code to operate on doublewords.

Message-Id: <[email protected]>

---
 lib/s390x/asm/facility.h | 14 +++++++-------
 lib/s390x/io.c           |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)
lib/s390x/asm/facility.h +7 -7
index e34dc2c..def2705 100644
@@ -14,12 +14,12 @@
 #include <asm/facility.h>
 #include <asm/arch_def.h>
 
-#define NR_STFL_BYTES 256
-extern uint8_t stfl_bytes[];
+#define NB_STFL_DOUBLEWORDS 32
+extern uint64_t stfl_doublewords[];
 
 static inline bool test_facility(int nr)
 {
-	return stfl_bytes[nr / 8] & (0x80U >> (nr % 8));
+	return stfl_doublewords[nr / 64] & (0x8000000000000000UL >> (nr % 64));
 }
 
 static inline void stfl(void)
@@ -27,9 +27,9 @@ static inline void stfl(void)
 	asm volatile("	stfl	0(0)\n" : : : "memory");
 }
 
-static inline void stfle(uint8_t *fac, unsigned int len)
+static inline void stfle(uint64_t *fac, unsigned int nb_doublewords)
 {
-	register unsigned long r0 asm("0") = len - 1;
+	register unsigned long r0 asm("0") = nb_doublewords - 1;
 
 	asm volatile("	.insn	s,0xb2b00000,0(%1)\n"
 		     : "+d" (r0) : "a" (fac) : "memory", "cc");
@@ -40,9 +40,9 @@ static inline void setup_facilities(void)
 	struct lowcore *lc = NULL;
 
 	stfl();
-	memcpy(stfl_bytes, &lc->stfl, sizeof(lc->stfl));
+	memcpy(stfl_doublewords, &lc->stfl, sizeof(lc->stfl));
 	if (test_facility(7))
-		stfle(stfl_bytes, NR_STFL_BYTES);
+		stfle(stfl_doublewords, NB_STFL_DOUBLEWORDS);
 }
 
 #endif
lib/s390x/io.c +1 -1
index e091c37..c0f0bf7 100644
@@ -19,7 +19,7 @@
 #include "smp.h"
 
 extern char ipl_args[];
-uint8_t stfl_bytes[NR_STFL_BYTES] __attribute__((aligned(8)));
+uint64_t stfl_doublewords[NB_STFL_DOUBLEWORDS];
 
 static struct spinlock lock;
 
Signature · 1 line
2.25.3
#7 lore raw

[kvm-unit-tests PULL 07/17] s390x/smp: add minimal test for sigp sense running status

In reply to David Hildenbrand

From: Christian Borntraeger <[email protected]>

Two minimal tests:
- our own CPU should be running when we check ourselves
- a CPU should at least have some times with a not running indication. To speed things up we stop CPU1

Also rename smp_cpu_running to smp_sense_running_status.

Message-Id: <[email protected]>

---
 lib/s390x/smp.c |  2 +-
 lib/s390x/smp.h |  2 +-
 s390x/smp.c     | 14 ++++++++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)
lib/s390x/smp.c +1 -1
index 203792a..df8dcd9 100644
@@ -58,7 +58,7 @@ bool smp_cpu_stopped(uint16_t addr)
 	return !!(status & (SIGP_STATUS_CHECK_STOP|SIGP_STATUS_STOPPED));
 }
 
-bool smp_cpu_running(uint16_t addr)
+bool smp_sense_running_status(uint16_t addr)
 {
 	if (sigp(addr, SIGP_SENSE_RUNNING, 0, NULL) != SIGP_CC_STATUS_STORED)
 		return true;
lib/s390x/smp.h +1 -1
index ce63a89..d66e39a 100644
@@ -40,7 +40,7 @@ struct cpu_status {
 int smp_query_num_cpus(void);
 struct cpu *smp_cpu_from_addr(uint16_t addr);
 bool smp_cpu_stopped(uint16_t addr);
-bool smp_cpu_running(uint16_t addr);
+bool smp_sense_running_status(uint16_t addr);
 int smp_cpu_restart(uint16_t addr);
 int smp_cpu_start(uint16_t addr, struct psw psw);
 int smp_cpu_stop(uint16_t addr);
s390x/smp.c +14 -0
index fa40753..1641979 100644
@@ -182,6 +182,19 @@ static void test_emcall(void)
 	report_prefix_pop();
 }
 
+static void test_sense_running(void)
+{
+	report_prefix_push("sense_running");
+	/* we (CPU0) are running */
+	report(smp_sense_running_status(0), "CPU0 sense claims running");
+	/* stop the target CPU (CPU1) to speed up the not running case */
+	smp_cpu_stop(1);
+	/* Make sure to have at least one time with a not running indication */
+	while(smp_sense_running_status(1));
+	report(true, "CPU1 sense claims not running");
+	report_prefix_pop();
+}
+
 static void test_reset_initial(void)
 {
 	struct cpu_status *status = alloc_pages(0);
@@ -251,6 +264,7 @@ int main(void)
 	test_store_status();
 	test_ecall();
 	test_emcall();
+	test_sense_running();
 	test_reset();
 	test_reset_initial();
 	smp_cpu_destroy(1);
Signature · 1 line
2.25.3
#8 lore raw

[kvm-unit-tests PULL 08/17] s390x: unittests: Use smp parameter

In reply to David Hildenbrand

From: Andrew Jones <[email protected]>

Message-Id: <[email protected]>

---
 s390x/unittests.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/unittests.cfg +1 -1
index 535db21..b307329 100644
@@ -75,7 +75,7 @@ extra_params=-name kvm-unit-test --uuid 0fb84a86-727c-11ea-bc55-0242ac130003 -sm
 
 [smp]
 file = smp.elf
-extra_params =-smp 2
+smp = 2
 
 [sclp-1g]
 file = sclp.elf
Signature · 1 line
2.25.3
#9 lore raw

[kvm-unit-tests PULL 09/17] s390x: smp: Test all CRs on initial reset

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

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.

Message-Id: <[email protected]>

---
 s390x/smp.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
s390x/smp.c +17 -1
index 1641979..08fa770 100644
@@ -195,16 +195,28 @@ static void test_sense_running(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);
+	set_flag(1);
+}
+
 static void test_reset_initial(void)
 {
 	struct cpu_status *status = alloc_pages(0);
 	struct psw psw;
+	int i;
 
 	psw.mask = extract_psw_mask();
-	psw.addr = (unsigned long)test_func;
+	psw.addr = (unsigned long)test_func_initial;
 
 	report_prefix_push("reset initial");
+	set_flag(0);
 	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);
@@ -215,6 +227,10 @@ static void test_reset_initial(void)
 	report(!status->fpc, "fpc");
 	report(!status->cputm, "cpu timer");
 	report(!status->todpr, "todpr");
+	for (i = 1; i <= 13; i++) {
+		report(status->crs[i] == 0, "cr%d == 0", i);
+	}
+	report(status->crs[15] == 0, "cr15 == 0");
 	report_prefix_pop();
 
 	report_prefix_push("initialized");
Signature · 1 line
2.25.3
#10 lore raw

[kvm-unit-tests PULL 11/17] s390x: smp: Test stop and store status on a running and stopped cpu

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

Let's also test the stop portion of the "stop and store status" sigp order.

Message-Id: <[email protected]>

---
 s390x/smp.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
s390x/smp.c +14 -0
index bf082d1..57eacb2 100644
@@ -76,6 +76,18 @@ static void test_stop_store_status(void)
 	struct lowcore *lc = (void *)0x0;
 
 	report_prefix_push("stop store status");
+	report_prefix_push("running");
+	smp_cpu_restart(1);
+	lc->prefix_sa = 0;
+	lc->grs_sa[15] = 0;
+	smp_cpu_stop_store_status(1);
+	mb();
+	report(lc->prefix_sa == (uint32_t)(uintptr_t)cpu->lowcore, "prefix");
+	report(lc->grs_sa[15], "stack");
+	report(smp_cpu_stopped(1), "cpu stopped");
+	report_prefix_pop();
+
+	report_prefix_push("stopped");
 	lc->prefix_sa = 0;
 	lc->grs_sa[15] = 0;
 	smp_cpu_stop_store_status(1);
@@ -83,6 +95,8 @@ static void test_stop_store_status(void)
 	report(lc->prefix_sa == (uint32_t)(uintptr_t)cpu->lowcore, "prefix");
 	report(lc->grs_sa[15], "stack");
 	report_prefix_pop();
+
+	report_prefix_pop();
 }
 
 static void test_store_status(void)
Signature · 1 line
2.25.3
#11 lore raw

[kvm-unit-tests PULL 10/17] s390x: smp: Dirty fpc before initial reset test

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

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

Message-Id: <[email protected]>

---
 s390x/smp.c | 1 +
 1 file changed, 1 insertion(+)
s390x/smp.c +1 -0
index 08fa770..bf082d1 100644
@@ -198,6 +198,7 @@ static void test_sense_running(void)
 /* Used to dirty registers of cpu #1 before it is reset */
 static void test_func_initial(void)
 {
+	asm volatile("sfpc %0" :: "d" (0x11));
 	lctlg(1, 0x42000UL);
 	lctlg(7, 0x43000UL);
 	lctlg(13, 0x44000UL);
Signature · 1 line
2.25.3
#12 lore raw

[kvm-unit-tests PULL 13/17] s390x: smp: Loop if secondary cpu returns into cpu setup again

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

Up to now a secondary cpu could have returned from the function it was executing and ending up somewhere in cstart64.S. This was mostly circumvented by an endless loop in the function that it executed.

Let's add a loop to the end of the cpu setup, so we don't have to rely on added loops in the tests.

Message-Id: <[email protected]>

---
 s390x/cstart64.S | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
s390x/cstart64.S +3 -1
index 9af6bb3..ecffbe0 100644
@@ -161,7 +161,9 @@ smp_cpu_setup_state:
 	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
+	brasl	%r14, %r14
+	/* If the function returns, just loop here */
+0:	j	0
 
 pgm_int:
 	SAVE_REGS
Signature · 1 line
2.25.3
#13 lore raw

[kvm-unit-tests PULL 12/17] s390x: smp: Test local interrupts after cpu reset

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

Local interrupts (external and emergency call) should be cleared after any cpu reset.

Message-Id: <[email protected]>

---
 s390x/smp.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
s390x/smp.c +21 -0
index 57eacb2..447b998 100644
@@ -258,6 +258,19 @@ static void test_reset_initial(void)
 	report_prefix_pop();
 }
 
+static void test_local_ints(void)
+{
+	unsigned long mask;
+
+	/* Open masks for ecall and emcall */
+	ctl_set_bit(0, 13);
+	ctl_set_bit(0, 14);
+	mask = extract_psw_mask();
+	mask |= PSW_MASK_EXT;
+	load_psw_mask(mask);
+	set_flag(1);
+}
+
 static void test_reset(void)
 {
 	struct psw psw;
@@ -266,10 +279,18 @@ static void test_reset(void)
 	psw.addr = (unsigned long)test_func;
 
 	report_prefix_push("cpu reset");
+	sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL);
+	sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
 	smp_cpu_start(1, psw);
 
 	sigp_retry(1, SIGP_CPU_RESET, 0, NULL);
 	report(smp_cpu_stopped(1), "cpu stopped");
+
+	set_flag(0);
+	psw.addr = (unsigned long)test_local_ints;
+	smp_cpu_start(1, psw);
+	wait_for_flag();
+	report(true, "local interrupts cleared");
 	report_prefix_pop();
 }
 
Signature · 1 line
2.25.3
#14 lore raw

[kvm-unit-tests PULL 14/17] s390x: smp: Remove unneeded cpu loops

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

Now that we have a loop which is executed after we return from the main function of a secondary cpu, we can remove the surplus loops.

Message-Id: <[email protected]>

---
 s390x/smp.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
s390x/smp.c +1 -7
index 447b998..f2319c4 100644
@@ -35,15 +35,9 @@ static void set_flag(int val)
 	mb();
 }
 
-static void cpu_loop(void)
-{
-	for (;;) {}
-}
-
 static void test_func(void)
 {
 	set_flag(1);
-	cpu_loop();
 }
 
 static void test_start(void)
@@ -306,7 +300,7 @@ int main(void)
 
 	/* Setting up the cpu to give it a stack and lowcore */
 	psw.mask = extract_psw_mask();
-	psw.addr = (unsigned long)cpu_loop;
+	psw.addr = (unsigned long)test_func;
 	smp_cpu_setup(1, psw);
 	smp_cpu_stop(1);
 
Signature · 1 line
2.25.3
#15 lore raw

[kvm-unit-tests PULL 15/17] s390x: smp: Use full PSW to bringup new cpu

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

Up to now we ignored the psw mask and only used the psw address when bringing up a new cpu. For DAT we need to also load the mask, so let's do that.

Message-Id: <[email protected]>

---
 lib/s390x/smp.c  | 2 ++
 s390x/cstart64.S | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
lib/s390x/smp.c +2 -0
index df8dcd9..2860e9c 100644
@@ -202,6 +202,8 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
 	cpu->stack = (uint64_t *)alloc_pages(2);
 
 	/* Start without DAT and any other mask bits. */
+	cpu->lowcore->sw_int_psw.mask = psw.mask;
+	cpu->lowcore->sw_int_psw.addr = psw.addr;
 	cpu->lowcore->sw_int_grs[14] = psw.addr;
 	cpu->lowcore->sw_int_grs[15] = (uint64_t)cpu->stack + (PAGE_SIZE * 4);
 	lc->restart_new_psw.mask = 0x0000000180000000UL;
s390x/cstart64.S +2 -1
index ecffbe0..e084f13 100644
@@ -161,7 +161,8 @@ smp_cpu_setup_state:
 	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
-	brasl	%r14, %r14
+	larl	%r14, 0f
+	lpswe	GEN_LC_SW_INT_PSW
 	/* If the function returns, just loop here */
 0:	j	0
 
Signature · 1 line
2.25.3
#16 lore raw

[kvm-unit-tests PULL 16/17] s390x: smp: Add restart when running test

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

Let's make sure we can restart a cpu that is already running. Restarting it if it is stopped is implicitely tested by the the other restart calls in the smp test.

Message-Id: <[email protected]>

---
 s390x/smp.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
s390x/smp.c +29 -0
index f2319c4..ad30e3c 100644
@@ -52,6 +52,34 @@ static void test_start(void)
 	report(1, "start");
 }
 
+/*
+ * Does only test restart when the target is running.
+ * The other tests do restarts when stopped multiple times already.
+ */
+static void test_restart(void)
+{
+	struct cpu *cpu = smp_cpu_from_addr(1);
+	struct lowcore *lc = cpu->lowcore;
+
+	lc->restart_new_psw.mask = extract_psw_mask();
+	lc->restart_new_psw.addr = (unsigned long)test_func;
+
+	/* Make sure cpu is running */
+	smp_cpu_stop(0);
+	set_flag(0);
+	smp_cpu_restart(1);
+	wait_for_flag();
+
+	/*
+	 * Wait until cpu 1 has set the flag because it executed the
+	 * restart function.
+	 */
+	set_flag(0);
+	smp_cpu_restart(1);
+	wait_for_flag();
+	report(1, "restart while running");
+}
+
 static void test_stop(void)
 {
 	smp_cpu_stop(1);
@@ -305,6 +333,7 @@ int main(void)
 	smp_cpu_stop(1);
 
 	test_start();
+	test_restart();
 	test_stop();
 	test_stop_store_status();
 	test_store_status();
Signature · 1 line
2.25.3
#17 lore raw

[kvm-unit-tests PULL 17/17] s390x: Fix library constant definitions

In reply to David Hildenbrand

From: Janosch Frank <[email protected]>

Seems like I uppercased the whole region instead of only the ULs when I added those definitions. Let's make the x lowercase again.

Message-Id: <[email protected]>

---
 lib/s390x/asm/arch_def.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/s390x/asm/arch_def.h +4 -4
index 15a4d49..1b3bb0c 100644
@@ -19,10 +19,10 @@ struct psw {
 #define PSW_MASK_DAT			0x0400000000000000UL
 #define PSW_MASK_PSTATE			0x0001000000000000UL
 
-#define CR0_EXTM_SCLP			0X0000000000000200UL
-#define CR0_EXTM_EXTC			0X0000000000002000UL
-#define CR0_EXTM_EMGC			0X0000000000004000UL
-#define CR0_EXTM_MASK			0X0000000000006200UL
+#define CR0_EXTM_SCLP			0x0000000000000200UL
+#define CR0_EXTM_EXTC			0x0000000000002000UL
+#define CR0_EXTM_EMGC			0x0000000000004000UL
+#define CR0_EXTM_MASK			0x0000000000006200UL
 
 struct lowcore {
 	uint8_t		pad_0x0000[0x0080 - 0x0000];	/* 0x0000 */
Signature · 1 line
2.25.3