Skip to contentSkip to conversation

s390x: smp lib improvements and more

GIT PULL Applied Claudio Imbrenda 2 participants 11 messages Feb 17, 2022 KVM

lore
Share & tools
lore
#0 lore raw

Hi Paolo,

please merge the following changes:
* SMP lib improvements to increase correctness of SMP tests
* fix some tests so that each test has a unique output line
* add a few function to detect the hypervisor
* rename some macros to bring them in line with the kernel

MERGE:
https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/merge_requests/25

PIPELINE:
https://gitlab.com/imbrenda/kvm-unit-tests/-/pipelines/473371669

PULL:
https://gitlab.com/imbrenda/kvm-unit-tests.git s390x-next-20220217

Christian Borntraeger (1):
s390x/cpumodel: give each test a unique output line

Claudio Imbrenda (6):
s390x: firq: fix running in PV
lib: s390x: smp: guarantee that boot CPU has index 0
lib: s390x: smp: refactor smp functions to accept indexes
s390x: smp: use CPU indexes instead of addresses
s390x: firq: use CPU indexes instead of addresses
s390x: skrf: use CPU indexes instead of addresses

Janosch Frank (1):
s390x: uv: Fix UVC cmd prepare reset name

Pierre Morel (1):
s390x: stsi: Define vm_is_kvm to be used in different tests

 lib/s390x/asm/uv.h  |   4 +-
 lib/s390x/smp.h     |  20 +++--
 lib/s390x/stsi.h    |  32 ++++++++
 lib/s390x/vm.h      |   2 +
 lib/s390x/smp.c     | 173 +++++++++++++++++++++++++++-----------------
 lib/s390x/vm.c      |  51 ++++++++++++-
 s390x/cpumodel.c    |   5 +-
 s390x/firq.c        |  26 ++-----
 s390x/skrf.c        |   2 +-
 s390x/smp.c         |  22 +++---
 s390x/stsi.c        |  23 +-----
 s390x/uv-guest.c    |   2 +-
 s390x/uv-host.c     |   2 +-
 s390x/unittests.cfg |  18 ++++-
 14 files changed, 243 insertions(+), 139 deletions(-)
 create mode 100644 lib/s390x/stsi.h
Signature · 1 line
2.34.1
#1 lore raw

[kvm-unit-tests GIT PULL 1/9] s390x/cpumodel: give each test a unique output line

From: Christian Borntraeger <[email protected]>

Until now we had multiple tests running under the same prefix. This can result in multiple identical lines like
SKIP: cpumodel: dependency: facility 5 not present
SKIP: cpumodel: dependency: facility 5 not present

Make this unique by adding a proper prefix.

---
 s390x/cpumodel.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
s390x/cpumodel.c +3 -2
index 67bb6543..23ccf842 100644
@@ -116,14 +116,15 @@ int main(void)
 
 	report_prefix_push("dependency");
 	for (i = 0; i < ARRAY_SIZE(dep); i++) {
+		report_prefix_pushf("%d implies %d", dep[i].facility, dep[i].implied);
 		if (test_facility(dep[i].facility)) {
 			report_xfail(dep[i].expected_tcg_fail && vm_is_tcg(),
 				     test_facility(dep[i].implied),
-				     "%d implies %d",
-				     dep[i].facility, dep[i].implied);
+				     "implication not correct");
 		} else {
 			report_skip("facility %d not present", dep[i].facility);
 		}
+		report_prefix_pop();
 	}
 	report_prefix_pop();
 
Signature · 1 line
2.34.1
#2 lore raw

[kvm-unit-tests GIT PULL 4/9] lib: s390x: smp: guarantee that boot CPU has index 0

In reply to Claudio Imbrenda

Guarantee that the boot CPU has index 0. This simplifies the implementation of tests that require multiple CPUs.

Also fix a small bug in the allocation of the cpus array.

Fixes f77c0515 ("s390x: Add initial smp code")
Fixes 52076a63 ("s390x: Consolidate sclp read info")
---
 lib/s390x/smp.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)
lib/s390x/smp.c +19 -8
index b753eab5..eae742d2 100644
@@ -25,7 +25,6 @@
 #include "sclp.h"
 
 static struct cpu *cpus;
-static struct cpu *cpu0;
 static struct spinlock lock;
 
 extern void smp_cpu_setup_state(void);
@@ -69,7 +68,7 @@ static int smp_cpu_stop_nolock(uint16_t addr, bool store)
 	uint8_t order = store ? SIGP_STOP_AND_STORE_STATUS : SIGP_STOP;
 
 	cpu = smp_cpu_from_addr(addr);
-	if (!cpu || cpu == cpu0)
+	if (!cpu || addr == cpus[0].addr)
 		return -1;
 
 	if (sigp_retry(addr, order, 0, NULL))
@@ -193,7 +192,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
 	sigp_retry(cpu->addr, SIGP_SET_PREFIX, (unsigned long )lc, NULL);
 
 	/* Copy all exception psws. */
-	memcpy(lc, cpu0->lowcore, 512);
+	memcpy(lc, cpus[0].lowcore, 512);
 
 	/* Setup stack */
 	cpu->stack = (uint64_t *)alloc_pages(2);
@@ -251,15 +250,27 @@ void smp_setup(void)
 	if (num > 1)
 		printf("SMP: Initializing, found %d cpus\n", num);
 
-	cpus = calloc(num, sizeof(cpus));
+	cpus = calloc(num, sizeof(*cpus));
 	for (i = 0; i < num; i++) {
 		cpus[i].addr = entry[i].address;
 		cpus[i].active = false;
+		/*
+		 * Fill in the boot CPU. If the boot CPU is not at index 0,
+		 * swap it with the one at index 0. This guarantees that the
+		 * boot CPU will always have index 0. If the boot CPU was
+		 * already at index 0, a few extra useless assignments are
+		 * performed, but everything will work ok.
+		 * Notice that there is no guarantee that the list of CPUs
+		 * returned by the Read SCP Info command is in any
+		 * particular order, or that its order will stay consistent
+		 * across multiple invocations.
+		 */
 		if (entry[i].address == cpu0_addr) {
-			cpu0 = &cpus[i];
-			cpu0->stack = stackptr;
-			cpu0->lowcore = (void *)0;
-			cpu0->active = true;
+			cpus[i].addr = cpus[0].addr;
+			cpus[0].addr = cpu0_addr;
+			cpus[0].stack = stackptr;
+			cpus[0].lowcore = (void *)0;
+			cpus[0].active = true;
 		}
 	}
 	spin_unlock(&lock);
Signature · 1 line
2.34.1
#3 lore raw

[kvm-unit-tests GIT PULL 7/9] s390x: firq: use CPU indexes instead of addresses

In reply to Claudio Imbrenda

Adapt the test to the new semantics of the smp_* functions, and use CPU indexes instead of addresses.

replace the checks with asserts, the 3 CPUs are guaranteed to be there.

---
 s390x/firq.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)
s390x/firq.c +6 -20
index fb9a2906..b4b3542e 100644
@@ -44,24 +44,13 @@ static void test_wait_state_delivery(void)
 		goto out;
 	}
 
-	if (stap()) {
-		report_skip("need to start on CPU #0");
-		goto out;
-	}
-
-	/*
-	 * We want CPU #2 to be stopped. This should be the case at this
-	 * point, however, we want to sense if it even exists as well.
-	 */
+	/* Stop CPU #2. It must succeed because we have at least 3 CPUs */
 	ret = smp_cpu_stop(2);
-	if (ret) {
-		report_skip("CPU #2 not found");
-		goto out;
-	}
+	assert(!ret);
 
 	/*
-	 * We're going to perform an SCLP service call but expect
-	 * the interrupt on CPU #1 while it is in the wait state.
+	 * We're going to perform an SCLP service call but expect the
+	 * interrupt on CPU #1 while it is in the wait state.
 	 */
 	sclp_mark_busy();
 
@@ -69,11 +58,8 @@ static void test_wait_state_delivery(void)
 	psw.mask = extract_psw_mask();
 	psw.addr = (unsigned long)wait_for_sclp_int;
 	ret = smp_cpu_setup(1, psw);
-	if (ret) {
-		sclp_clear_busy();
-		report_skip("cpu #1 not found");
-		goto out;
-	}
+	/* This must not fail because we have at least 3 CPUs */
+	assert(!ret);
 
 	/*
 	 * We'd have to jump trough some hoops to sense e.g., via SIGP
Signature · 1 line
2.34.1
#4 lore raw

[kvm-unit-tests GIT PULL 6/9] s390x: smp: use CPU indexes instead of addresses

In reply to Claudio Imbrenda

Adapt the test to the new semantics of the smp_* functions, and use CPU indexes instead of addresses.

---
 s390x/smp.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
s390x/smp.c +11 -11
index 1bbe4c31..068ac74d 100644
@@ -56,7 +56,7 @@ static void test_start(void)
  */
 static void test_restart(void)
 {
-	struct cpu *cpu = smp_cpu_from_addr(1);
+	struct cpu *cpu = smp_cpu_from_idx(1);
 	struct lowcore *lc = cpu->lowcore;
 
 	lc->restart_new_psw.mask = extract_psw_mask();
@@ -92,7 +92,7 @@ static void test_stop(void)
 
 static void test_stop_store_status(void)
 {
-	struct cpu *cpu = smp_cpu_from_addr(1);
+	struct cpu *cpu = smp_cpu_from_idx(1);
 	struct lowcore *lc = (void *)0x0;
 
 	report_prefix_push("stop store status");
@@ -129,7 +129,7 @@ static void test_store_status(void)
 
 	report_prefix_push("running");
 	smp_cpu_restart(1);
-	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, &r);
+	smp_sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, &r);
 	report(r == SIGP_STATUS_INCORRECT_STATE, "incorrect state");
 	report(!memcmp(status, (void *)status + PAGE_SIZE, PAGE_SIZE),
 	       "status not written");
@@ -138,7 +138,7 @@ static void test_store_status(void)
 	memset(status, 0, PAGE_SIZE);
 	report_prefix_push("stopped");
 	smp_cpu_stop(1);
-	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
+	smp_sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
 	while (!status->prefix) { mb(); }
 	report_pass("status written");
 	free_pages(status);
@@ -176,7 +176,7 @@ static void test_ecall(void)
 	smp_cpu_start(1, psw);
 	wait_for_flag();
 	set_flag(0);
-	sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
+	smp_sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
 	wait_for_flag();
 	smp_cpu_stop(1);
 	report_prefix_pop();
@@ -210,7 +210,7 @@ static void test_emcall(void)
 	smp_cpu_start(1, psw);
 	wait_for_flag();
 	set_flag(0);
-	sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL);
+	smp_sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL);
 	wait_for_flag();
 	smp_cpu_stop(1);
 	report_prefix_pop();
@@ -253,8 +253,8 @@ static void test_reset_initial(void)
 	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);
+	smp_sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
+	smp_sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
 
 	report_prefix_push("clear");
 	report(!status->psw.mask && !status->psw.addr, "psw");
@@ -299,11 +299,11 @@ 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_sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL);
+	smp_sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
 	smp_cpu_start(1, psw);
 
-	sigp_retry(1, SIGP_CPU_RESET, 0, NULL);
+	smp_sigp_retry(1, SIGP_CPU_RESET, 0, NULL);
 	report(smp_cpu_stopped(1), "cpu stopped");
 
 	set_flag(0);
Signature · 1 line
2.34.1
#5 lore raw

[kvm-unit-tests GIT PULL 8/9] s390x: skrf: use CPU indexes instead of addresses

In reply to Claudio Imbrenda

Adapt the test to the new semantics of the smp_* functions, and use CPU indexes instead of addresses.

---
 s390x/skrf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/skrf.c +1 -1
index ca4efbf1..b9a2e902 100644
@@ -176,7 +176,7 @@ static void test_exception_ext_new(void)
 	wait_for_flag();
 	set_flag(0);
 
-	sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
+	smp_sigp(1, SIGP_EXTERNAL_CALL, 0, NULL);
 	wait_for_flag();
 	smp_cpu_stop(1);
 	report_prefix_pop();
Signature · 1 line
2.34.1
#6 lore raw

[kvm-unit-tests GIT PULL 9/9] s390x: stsi: Define vm_is_kvm to be used in different tests

In reply to Claudio Imbrenda

From: Pierre Morel <[email protected]>

Several tests are in need of a way to check on which hypervisor and virtualization level they are running on to be able to fence certain tests. This patch adds functions that return true if a vm is running under KVM, LPAR or generally as a level 2 guest.

To check if we're running under KVM we use the STSI 3.2.2 instruction, let's define it's response structure in a central header.

---
 lib/s390x/stsi.h | 32 ++++++++++++++++++++++++++++++
 lib/s390x/vm.h   |  2 ++
 lib/s390x/vm.c   | 51 ++++++++++++++++++++++++++++++++++++++++++++++--
 s390x/stsi.c     | 23 ++--------------------
 4 files changed, 85 insertions(+), 23 deletions(-)
 create mode 100644 lib/s390x/stsi.h
lib/s390x/stsi.h new file +32 -0
new file mode 100644
index 00000000..bebc492d
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Structures used to Store System Information
+ *
+ * Copyright IBM Corp. 2022
+ */
+
+#ifndef _S390X_STSI_H_
+#define _S390X_STSI_H_
+
+struct sysinfo_3_2_2 {
+	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];
+};
+
+#endif  /* _S390X_STSI_H_ */
lib/s390x/vm.h +2 -0
index 7abba0cc..4456b48c 100644
@@ -9,5 +9,7 @@
 #define _S390X_VM_H_
 
 bool vm_is_tcg(void);
+bool vm_is_kvm(void);
+bool vm_is_lpar(void);
 
 #endif  /* _S390X_VM_H_ */
lib/s390x/vm.c +49 -2

67 lines not on this page · raw message

s390x/stsi.c +2 -21
index 391f8849..dccc53e7 100644
@@ -13,27 +13,8 @@
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
 #include <smp.h>
+#include <stsi.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)
@@ -91,7 +72,7 @@ static void test_3_2_2(void)
 	/* 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;
+	struct sysinfo_3_2_2 *data = (void *)pagebuf;
 
 	report_prefix_push("3.2.2");
 
Signature · 1 line
2.34.1
#7 lore raw

[kvm-unit-tests GIT PULL 2/9] s390x: uv: Fix UVC cmd prepare reset name

In reply to Claudio Imbrenda

From: Janosch Frank <[email protected]>

The specification and the kernel use UVC_CMD_PREPARE_RESET so let's fix our naming up.

The call bit is named correctly but is not the same as the name we use on KVM. So let's clear that up too.

---
 lib/s390x/asm/uv.h | 4 ++--
 s390x/uv-guest.c   | 2 +-
 s390x/uv-host.c    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
lib/s390x/asm/uv.h +2 -2
index 97c90e81..70bf65c4 100644
@@ -39,7 +39,7 @@
 #define UVC_CMD_VERIFY_IMG		0x0302
 #define UVC_CMD_CPU_RESET		0x0310
 #define UVC_CMD_CPU_RESET_INITIAL	0x0311
-#define UVC_CMD_PERF_CONF_CLEAR_RESET	0x0320
+#define UVC_CMD_PREPARE_RESET		0x0320
 #define UVC_CMD_CPU_RESET_CLEAR		0x0321
 #define UVC_CMD_CPU_SET_STATE		0x0330
 #define UVC_CMD_SET_UNSHARED_ALL	0x0340
@@ -66,7 +66,7 @@ enum uv_cmds_inst {
 	BIT_UVC_CMD_CPU_RESET = 15,
 	BIT_UVC_CMD_CPU_RESET_INITIAL = 16,
 	BIT_UVC_CMD_CPU_SET_STATE = 17,
-	BIT_UVC_CMD_PREPARE_CLEAR_RESET = 18,
+	BIT_UVC_CMD_PREPARE_RESET = 18,
 	BIT_UVC_CMD_CPU_PERFORM_CLEAR_RESET = 19,
 	BIT_UVC_CMD_UNSHARE_ALL = 20,
 	BIT_UVC_CMD_PIN_PAGE_SHARED = 21,
s390x/uv-guest.c +1 -1
index 44ad2154..99120cae 100644
@@ -142,7 +142,7 @@ static struct {
 	{ "verify", UVC_CMD_VERIFY_IMG, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_VERIFY_IMG },
 	{ "cpu reset", UVC_CMD_CPU_RESET, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_CPU_RESET },
 	{ "cpu initial reset", UVC_CMD_CPU_RESET_INITIAL, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_CPU_RESET_INITIAL },
-	{ "conf clear reset", UVC_CMD_PERF_CONF_CLEAR_RESET, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_PREPARE_CLEAR_RESET },
+	{ "prepare clear reset", UVC_CMD_PREPARE_RESET, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_PREPARE_RESET },
 	{ "cpu clear reset", UVC_CMD_CPU_RESET_CLEAR, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_CPU_PERFORM_CLEAR_RESET },
 	{ "cpu set state", UVC_CMD_CPU_SET_STATE, sizeof(struct uv_cb_cpu_set_state), BIT_UVC_CMD_CPU_SET_STATE },
 	{ "pin shared", UVC_CMD_PIN_PAGE_SHARED, sizeof(struct uv_cb_cfs), BIT_UVC_CMD_PIN_PAGE_SHARED },
s390x/uv-host.c +1 -1
index 92a41069..de2e4850 100644
@@ -55,7 +55,7 @@ static struct cmd_list cmds[] = {
 	{ "verify", UVC_CMD_VERIFY_IMG, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_VERIFY_IMG },
 	{ "cpu reset", UVC_CMD_CPU_RESET, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_CPU_RESET },
 	{ "cpu initial reset", UVC_CMD_CPU_RESET_INITIAL, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_CPU_RESET_INITIAL },
-	{ "conf clear reset", UVC_CMD_PERF_CONF_CLEAR_RESET, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_PREPARE_CLEAR_RESET },
+	{ "conf clear reset", UVC_CMD_PREPARE_RESET, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_PREPARE_RESET },
 	{ "cpu clear reset", UVC_CMD_CPU_RESET_CLEAR, sizeof(struct uv_cb_nodata), BIT_UVC_CMD_CPU_PERFORM_CLEAR_RESET },
 	{ "cpu set state", UVC_CMD_CPU_SET_STATE, sizeof(struct uv_cb_cpu_set_state), BIT_UVC_CMD_CPU_SET_STATE },
 	{ "pin shared", UVC_CMD_PIN_PAGE_SHARED, sizeof(struct uv_cb_cfs), BIT_UVC_CMD_PIN_PAGE_SHARED },
Signature · 1 line
2.34.1
#8 lore raw

[kvm-unit-tests GIT PULL 3/9] s390x: firq: fix running in PV

In reply to Claudio Imbrenda

If using the qemu CPU type, Protected Virtualization is not available, and the test will fail to start when run in PV. If specifying the host CPU type, the test will fail to start with TCG because the host CPU type requires KVM. In both cases the test will show up as failed.

This patch adds a copy of the firq test definitions for KVM, using the host CPU type, and specifying that KVM is to be used. The existing firq tests are then fixed by specifying that TCG is to be used.

When running the tests normally, both variants will be run. If an accelerator is specified explicitly when running the tests, only one variant will run and the other will be skipped (and not fail).

Fixes 8b98745d ("s390x: firq: floating interrupt test")
---
 s390x/unittests.cfg | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
s390x/unittests.cfg +16 -2
index 054560c2..1600e714 100644
@@ -113,12 +113,26 @@ file = mvpg-sie.elf
 [spec_ex-sie]
 file = spec_ex-sie.elf
 
-[firq-linear-cpu-ids]
+[firq-linear-cpu-ids-kvm]
+file = firq.elf
+timeout = 20
+extra_params = -smp 1,maxcpus=3 -device host-s390x-cpu,core-id=1 -device host-s390x-cpu,core-id=2
+accel = kvm
+
+[firq-nonlinear-cpu-ids-kvm]
+file = firq.elf
+timeout = 20
+extra_params = -smp 1,maxcpus=3 -device host-s390x-cpu,core-id=2 -device host-s390x-cpu,core-id=1
+accel = kvm
+
+[firq-linear-cpu-ids-tcg]
 file = firq.elf
 timeout = 20
 extra_params = -smp 1,maxcpus=3 -cpu qemu -device qemu-s390x-cpu,core-id=1 -device qemu-s390x-cpu,core-id=2
+accel = tcg
 
-[firq-nonlinear-cpu-ids]
+[firq-nonlinear-cpu-ids-tcg]
 file = firq.elf
 timeout = 20
 extra_params = -smp 1,maxcpus=3 -cpu qemu -device qemu-s390x-cpu,core-id=2 -device qemu-s390x-cpu,core-id=1
+accel = tcg
Signature · 1 line
2.34.1
#9 lore raw

[kvm-unit-tests GIT PULL 5/9] lib: s390x: smp: refactor smp functions to accept indexes

In reply to Claudio Imbrenda

Refactor all the smp_* functions to accept CPU indexes instead of CPU addresses.

Add SIGP wrappers to use indexes instead of addresses. Raw SIGP calls using addresses are still possible. Some of the reworked functions also use the new wrappers internally, for clarity, even though that will cause unnecessary redundant checks on the validity of the CPU index.

Add a few other useful functions to deal with CPU indexes.

---
 lib/s390x/smp.h |  20 ++++---
 lib/s390x/smp.c | 148 ++++++++++++++++++++++++++++--------------------
 2 files changed, 99 insertions(+), 69 deletions(-)
lib/s390x/smp.h +12 -8
index a2609f11..1e69a7de 100644
@@ -37,15 +37,19 @@ 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_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);
-int smp_cpu_stop_store_status(uint16_t addr);
-int smp_cpu_destroy(uint16_t addr);
-int smp_cpu_setup(uint16_t addr, struct psw psw);
+struct cpu *smp_cpu_from_idx(uint16_t idx);
+uint16_t smp_cpu_addr(uint16_t idx);
+bool smp_cpu_stopped(uint16_t idx);
+bool smp_sense_running_status(uint16_t idx);
+int smp_cpu_restart(uint16_t idx);
+int smp_cpu_start(uint16_t idx, struct psw psw);
+int smp_cpu_stop(uint16_t idx);
+int smp_cpu_stop_store_status(uint16_t idx);
+int smp_cpu_destroy(uint16_t idx);
+int smp_cpu_setup(uint16_t idx, struct psw psw);
 void smp_teardown(void);
 void smp_setup(void);
+int smp_sigp(uint16_t idx, uint8_t order, unsigned long parm, uint32_t *status);
+int smp_sigp_retry(uint16_t idx, uint8_t order, unsigned long parm, uint32_t *status);
 
 #endif
lib/s390x/smp.c +87 -61

272 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Applied
#10 lore raw
In reply to Claudio Imbrenda
Quoted 49 lines · Claudio Imbrenda

Hi Paolo,

please merge the following changes:
* SMP lib improvements to increase correctness of SMP tests
* fix some tests so that each test has a unique output line
* add a few function to detect the hypervisor
* rename some macros to bring them in line with the kernel

MERGE:
https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/merge_requests/25

PIPELINE:
https://gitlab.com/imbrenda/kvm-unit-tests/-/pipelines/473371669

PULL:
https://gitlab.com/imbrenda/kvm-unit-tests.git s390x-next-20220217

Christian Borntraeger (1):
s390x/cpumodel: give each test a unique output line

Claudio Imbrenda (6):
s390x: firq: fix running in PV
lib: s390x: smp: guarantee that boot CPU has index 0
lib: s390x: smp: refactor smp functions to accept indexes
s390x: smp: use CPU indexes instead of addresses
s390x: firq: use CPU indexes instead of addresses
s390x: skrf: use CPU indexes instead of addresses

Janosch Frank (1):
s390x: uv: Fix UVC cmd prepare reset name

Pierre Morel (1):
s390x: stsi: Define vm_is_kvm to be used in different tests

  lib/s390x/asm/uv.h  |   4 +-
  lib/s390x/smp.h     |  20 +++--
  lib/s390x/stsi.h    |  32 ++++++++
  lib/s390x/vm.h      |   2 +
  lib/s390x/smp.c     | 173 +++++++++++++++++++++++++++-----------------
  lib/s390x/vm.c      |  51 ++++++++++++-
  s390x/cpumodel.c    |   5 +-
  s390x/firq.c        |  26 ++-----
  s390x/skrf.c        |   2 +-
  s390x/smp.c         |  22 +++---
  s390x/stsi.c        |  23 +-----
  s390x/uv-guest.c    |   2 +-
  s390x/uv-host.c     |   2 +-
  s390x/unittests.cfg |  18 ++++-
  14 files changed, 243 insertions(+), 139 deletions(-)
Quoted 2 lines

create mode 100644 lib/s390x/stsi.h

Merged, thanks.

Paolo