kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07
@ 2021-07-07 14:03 Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 1/8] s390x: snippets: Add gitignore as well as linker script and start assembly Janosch Frank
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Janosch Frank @ 2021-07-07 14:03 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

Dear Paolo,

please merge or pull the following changes:

* Add snippet support that makes starting guests in tests easier
* Cleanup

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

PIPELINE:
https://gitlab.com/frankja/kvm-unit-tests/-/pipelines/333035606

PULL:
The following changes since commit bc6f264386b4cb2cadc8b2492315f3e6e8a801a2:

  Merge branch 'arm/queue' into 'master' (2021-06-30 13:35:55 +0000)

are available in the Git repository at:

  https://gitlab.com/frankja/kvm-unit-tests.git s390x-pull-2021-07-07

for you to fetch changes up to 81598ca0d3fbeb52e02eecf5ddbc15e30f8c600a:

  lib: s390x: Remove left behing PGM report (2021-07-07 08:00:29 +0000)

Janosch Frank (7):
  s390x: snippets: Add gitignore as well as linker script and start
    assembly
  s390x: mvpg: Add SIE mvpg test
  s390x: sie: Add missing includes
  s390x: sie: Fix sie.h integer types
  lib: s390x: uv: Add offset comments to uv_query and extend it
  lib: s390x: Print if a pgm happened while in SIE
  lib: s390x: Remove left behing PGM report

Steffen Eiden (1):
  s390x: snippets: Add snippet compilation

 .gitignore                      |   1 +
 lib/s390x/asm/uv.h              |  33 +++----
 lib/s390x/interrupt.c           |  14 +--
 lib/s390x/sie.h                 |  11 ++-
 s390x/Makefile                  |  29 +++++--
 s390x/mvpg-sie.c                | 149 ++++++++++++++++++++++++++++++++
 s390x/snippets/c/cstart.S       |  16 ++++
 s390x/snippets/c/flat.lds       |  51 +++++++++++
 s390x/snippets/c/mvpg-snippet.c |  33 +++++++
 s390x/unittests.cfg             |   3 +
 10 files changed, 308 insertions(+), 32 deletions(-)
 create mode 100644 s390x/mvpg-sie.c
 create mode 100644 s390x/snippets/c/cstart.S
 create mode 100644 s390x/snippets/c/flat.lds
 create mode 100644 s390x/snippets/c/mvpg-snippet.c

-- 
2.31.1


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

* [kvm-unit-tests GIT PULL 1/8] s390x: snippets: Add gitignore as well as linker script and start assembly
  2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
@ 2021-07-07 14:03 ` Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 2/8] s390x: snippets: Add snippet compilation Janosch Frank
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Janosch Frank @ 2021-07-07 14:03 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

Snippets are small guests which can be run under a unit test that
implements a simple hypervisor. They can be written in C or
assembly. The C code needs a linker script and a start assembly file
that jumps to main to work properly. So let's add that as well as a
gitignore entry for the new files.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 .gitignore                |  1 +
 s390x/snippets/c/cstart.S | 16 ++++++++++++
 s390x/snippets/c/flat.lds | 51 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 s390x/snippets/c/cstart.S
 create mode 100644 s390x/snippets/c/flat.lds

diff --git a/.gitignore b/.gitignore
index 8534fb74..b3cf2cbd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@ cscope.*
 /api/dirty-log
 /api/dirty-log-perf
 /s390x/*.bin
+/s390x/snippets/*/*.gbin
diff --git a/s390x/snippets/c/cstart.S b/s390x/snippets/c/cstart.S
new file mode 100644
index 00000000..242568d6
--- /dev/null
+++ b/s390x/snippets/c/cstart.S
@@ -0,0 +1,16 @@
+#include <asm/sigp.h>
+
+.section .init
+	.globl start
+start:
+	/* XOR all registers with themselves to clear them fully. */
+	.irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+	xgr \i,\i
+	.endr
+	/* 0x3000 is the stack page for now */
+	lghi	%r15, 0x4000 - 160
+	sam64
+	brasl	%r14, main
+	/* For now let's only use cpu 0 in snippets so this will always work. */
+	xgr	%r0, %r0
+	sigp    %r2, %r0, SIGP_STOP
diff --git a/s390x/snippets/c/flat.lds b/s390x/snippets/c/flat.lds
new file mode 100644
index 00000000..ce3bfd69
--- /dev/null
+++ b/s390x/snippets/c/flat.lds
@@ -0,0 +1,51 @@
+SECTIONS
+{
+	.lowcore : {
+		/*
+		 * Initial short psw for disk boot, with 31 bit addressing for
+		 * non z/Arch environment compatibility and the instruction
+		 * address 0x4000 (cstart.S .init).
+		 */
+		. = 0;
+		 LONG(0x00080000)
+		 LONG(0x80004000)
+		 /* Restart new PSW for booting via PSW restart. */
+		 . = 0x1a0;
+		 QUAD(0x0000000180000000)
+		 QUAD(0x0000000000004000)
+	}
+	. = 0x4000;
+	.text : {
+		*(.init)
+		*(.text)
+		*(.text.*)
+	}
+	. = ALIGN(64K);
+	etext = .;
+	.opd : { *(.opd) }
+	. = ALIGN(16);
+	.dynamic : {
+		dynamic_start = .;
+		*(.dynamic)
+	}
+	.dynsym : {
+		dynsym_start = .;
+		*(.dynsym)
+	}
+	.rela.dyn : { *(.rela*) }
+	. = ALIGN(16);
+	.data : {
+		*(.data)
+		*(.data.rel*)
+	}
+	. = ALIGN(16);
+	.rodata : { *(.rodata) *(.rodata.*) }
+	. = ALIGN(16);
+	__bss_start = .;
+	.bss : { *(.bss) }
+	__bss_end = .;
+	. = ALIGN(64K);
+	edata = .;
+	. += 64K;
+	. = ALIGN(64K);
+}
-- 
2.31.1


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

* [kvm-unit-tests GIT PULL 2/8] s390x: snippets: Add snippet compilation
  2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 1/8] s390x: snippets: Add gitignore as well as linker script and start assembly Janosch Frank
@ 2021-07-07 14:03 ` Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 3/8] s390x: mvpg: Add SIE mvpg test Janosch Frank
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Janosch Frank @ 2021-07-07 14:03 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

From: Steffen Eiden <seiden@linux.ibm.com>

This patch provides the necessary make targets to properly compile
snippets and link them into their associated host.

To define the guest-host definition, we use the make-feature
`SECONDEXPANSION` in combination with `Target specific Variable
Values`. The variable `snippets` has different values depending on the
current target. This enables us to define which snippets (=guests)
belong to which hosts. Furthermore, using the second-expansion, we can
use `snippets` in the perquisites of the host's `%.elf` rule, which
otherwise would be not set.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Acked-by: Thomas Huth <thuth@redhat.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/Makefile | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/s390x/Makefile b/s390x/Makefile
index 8820e998..ba32f4c2 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -76,11 +76,26 @@ OBJDIRS += lib/s390x
 asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o
 
 FLATLIBS = $(libcflat)
-%.elf: %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(asmlib)
-	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) \
-		$(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\"
-	$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \
-		$(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
+
+SNIPPET_DIR = $(TEST_DIR)/snippets
+snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o
+
+# perquisites (=guests) for the snippet hosts.
+# $(TEST_DIR)/<snippet-host>.elf: snippets = $(SNIPPET_DIR)/<c/asm>/<snippet>.gbin
+
+$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o $(FLATLIBS)
+	$(OBJCOPY) -O binary $(patsubst %.gbin,%.o,$@) $@
+	$(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $@ $@
+
+$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_asmlib) $(FLATLIBS)
+	$(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds $(patsubst %.gbin,%.o,$@) $(snippet_asmlib) $(FLATLIBS)
+	$(OBJCOPY) -O binary $@ $@
+	$(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $@ $@
+
+.SECONDEXPANSION:
+%.elf: $$(snippets) %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(asmlib)
+	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\"
+	$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds $(filter %.o, $^) $(FLATLIBS) $(snippets) $(@:.elf=.aux.o)
 	$(RM) $(@:.elf=.aux.o)
 	@chmod a-x $@
 
@@ -94,7 +109,7 @@ FLATLIBS = $(libcflat)
 	$(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --no-verify --image $< -o $@
 
 arch_clean: asm_offsets_clean
-	$(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d lib/s390x/.*.d
+	$(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d $(SNIPPET_DIR)/c/*.{o,gbin} $(SNIPPET_DIR)/c/.*.d lib/s390x/.*.d
 
 generated-files = $(asm-offsets)
 $(tests:.elf=.o) $(asmlib) $(cflatobjs): $(generated-files)
-- 
2.31.1


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

* [kvm-unit-tests GIT PULL 3/8] s390x: mvpg: Add SIE mvpg test
  2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 1/8] s390x: snippets: Add gitignore as well as linker script and start assembly Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 2/8] s390x: snippets: Add snippet compilation Janosch Frank
@ 2021-07-07 14:03 ` Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 4/8] s390x: sie: Add missing includes Janosch Frank
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Janosch Frank @ 2021-07-07 14:03 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

Let's also check the PEI values to make sure our VSIE implementation
is correct.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Acked-by: Thomas Huth <thuth@redhat.com>
---
 s390x/Makefile                  |   2 +
 s390x/mvpg-sie.c                | 149 ++++++++++++++++++++++++++++++++
 s390x/snippets/c/mvpg-snippet.c |  33 +++++++
 s390x/unittests.cfg             |   3 +
 4 files changed, 187 insertions(+)
 create mode 100644 s390x/mvpg-sie.c
 create mode 100644 s390x/snippets/c/mvpg-snippet.c

diff --git a/s390x/Makefile b/s390x/Makefile
index ba32f4c2..07af26d0 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -23,6 +23,7 @@ tests += $(TEST_DIR)/sie.elf
 tests += $(TEST_DIR)/mvpg.elf
 tests += $(TEST_DIR)/uv-host.elf
 tests += $(TEST_DIR)/edat.elf
+tests += $(TEST_DIR)/mvpg-sie.elf
 
 tests_binary = $(patsubst %.elf,%.bin,$(tests))
 ifneq ($(HOST_KEY_DOCUMENT),)
@@ -82,6 +83,7 @@ snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o
 
 # perquisites (=guests) for the snippet hosts.
 # $(TEST_DIR)/<snippet-host>.elf: snippets = $(SNIPPET_DIR)/<c/asm>/<snippet>.gbin
+$(TEST_DIR)/mvpg-sie.elf: snippets = $(SNIPPET_DIR)/c/mvpg-snippet.gbin
 
 $(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o $(FLATLIBS)
 	$(OBJCOPY) -O binary $(patsubst %.gbin,%.o,$@) $@
diff --git a/s390x/mvpg-sie.c b/s390x/mvpg-sie.c
new file mode 100644
index 00000000..9bcd15a2
--- /dev/null
+++ b/s390x/mvpg-sie.c
@@ -0,0 +1,149 @@
+#include <libcflat.h>
+#include <asm/asm-offsets.h>
+#include <asm-generic/barrier.h>
+#include <asm/pgtable.h>
+#include <mmu.h>
+#include <asm/page.h>
+#include <asm/facility.h>
+#include <asm/mem.h>
+#include <alloc_page.h>
+#include <vm.h>
+#include <sclp.h>
+#include <sie.h>
+
+static u8 *guest;
+static u8 *guest_instr;
+static struct vm vm;
+
+static uint8_t *src;
+static uint8_t *dst;
+static uint8_t *cmp;
+
+extern const char _binary_s390x_snippets_c_mvpg_snippet_gbin_start[];
+extern const char _binary_s390x_snippets_c_mvpg_snippet_gbin_end[];
+int binary_size;
+
+static void sie(struct vm *vm)
+{
+	/* Reset icptcode so we don't trip over it below */
+	vm->sblk->icptcode = 0;
+
+	while (vm->sblk->icptcode == 0) {
+		sie64a(vm->sblk, &vm->save_area);
+		assert(vm->sblk->icptcode != ICPT_VALIDITY);
+	}
+	vm->save_area.guest.grs[14] = vm->sblk->gg14;
+	vm->save_area.guest.grs[15] = vm->sblk->gg15;
+}
+
+static void test_mvpg_pei(void)
+{
+	uint64_t **pei_dst = (uint64_t **)((uintptr_t) vm.sblk + 0xc0);
+	uint64_t **pei_src = (uint64_t **)((uintptr_t) vm.sblk + 0xc8);
+
+	report_prefix_push("pei");
+
+	report_prefix_push("src");
+	memset(dst, 0, PAGE_SIZE);
+	protect_page(src, PAGE_ENTRY_I);
+	sie(&vm);
+	report(vm.sblk->icptcode == ICPT_PARTEXEC, "Partial execution");
+	report((uintptr_t)**pei_src == (uintptr_t)src + PAGE_ENTRY_I, "PEI_SRC correct");
+	report((uintptr_t)**pei_dst == (uintptr_t)dst, "PEI_DST correct");
+	unprotect_page(src, PAGE_ENTRY_I);
+	report(!memcmp(cmp, dst, PAGE_SIZE), "Destination intact");
+	/*
+	 * We need to execute the diag44 which is used as a blocker
+	 * behind the mvpg. It makes sure we fail the tests above if
+	 * the mvpg wouldn't have intercepted.
+	 */
+	sie(&vm);
+	/* Make sure we intercepted for the diag44 and nothing else */
+	assert(vm.sblk->icptcode == ICPT_INST &&
+	       vm.sblk->ipa == 0x8300 && vm.sblk->ipb == 0x440000);
+	report_prefix_pop();
+
+	/* Clear PEI data for next check */
+	report_prefix_push("dst");
+	memset((uint64_t *)((uintptr_t) vm.sblk + 0xc0), 0, 16);
+	memset(dst, 0, PAGE_SIZE);
+	protect_page(dst, PAGE_ENTRY_I);
+	sie(&vm);
+	report(vm.sblk->icptcode == ICPT_PARTEXEC, "Partial execution");
+	report((uintptr_t)**pei_src == (uintptr_t)src, "PEI_SRC correct");
+	report((uintptr_t)**pei_dst == (uintptr_t)dst + PAGE_ENTRY_I, "PEI_DST correct");
+	/* Needed for the memcmp and general cleanup */
+	unprotect_page(dst, PAGE_ENTRY_I);
+	report(!memcmp(cmp, dst, PAGE_SIZE), "Destination intact");
+	report_prefix_pop();
+
+	report_prefix_pop();
+}
+
+static void test_mvpg(void)
+{
+	int binary_size = ((uintptr_t)_binary_s390x_snippets_c_mvpg_snippet_gbin_end -
+			   (uintptr_t)_binary_s390x_snippets_c_mvpg_snippet_gbin_start);
+
+	memcpy(guest, _binary_s390x_snippets_c_mvpg_snippet_gbin_start, binary_size);
+	memset(src, 0x42, PAGE_SIZE);
+	memset(dst, 0x43, PAGE_SIZE);
+	sie(&vm);
+	report(!memcmp(src, dst, PAGE_SIZE) && *dst == 0x42, "Page moved");
+}
+
+static void setup_guest(void)
+{
+	setup_vm();
+
+	/* Allocate 1MB as guest memory */
+	guest = alloc_pages(8);
+	/* The first two pages are the lowcore */
+	guest_instr = guest + PAGE_SIZE * 2;
+
+	vm.sblk = alloc_page();
+
+	vm.sblk->cpuflags = CPUSTAT_ZARCH | CPUSTAT_RUNNING;
+	vm.sblk->prefix = 0;
+	/*
+	 * Pageable guest with the same ASCE as the test programm, but
+	 * the guest memory 0x0 is offset to start at the allocated
+	 * guest pages and end after 1MB.
+	 *
+	 * It's not pretty but faster and easier than managing guest ASCEs.
+	 */
+	vm.sblk->mso = (u64)guest;
+	vm.sblk->msl = (u64)guest;
+	vm.sblk->ihcpu = 0xffff;
+
+	vm.sblk->crycbd = (uint64_t)alloc_page();
+
+	vm.sblk->gpsw.addr = PAGE_SIZE * 4;
+	vm.sblk->gpsw.mask = 0x0000000180000000ULL;
+	vm.sblk->ictl = ICTL_OPEREXC | ICTL_PINT;
+	/* Enable MVPG interpretation as we want to test KVM and not ourselves */
+	vm.sblk->eca = ECA_MVPGI;
+
+	src = guest + PAGE_SIZE * 6;
+	dst = guest + PAGE_SIZE * 5;
+	cmp = alloc_page();
+	memset(cmp, 0, PAGE_SIZE);
+}
+
+int main(void)
+{
+	report_prefix_push("mvpg-sie");
+	if (!sclp_facilities.has_sief2) {
+		report_skip("SIEF2 facility unavailable");
+		goto done;
+	}
+
+	setup_guest();
+	test_mvpg();
+	test_mvpg_pei();
+
+done:
+	report_prefix_pop();
+	return report_summary();
+
+}
diff --git a/s390x/snippets/c/mvpg-snippet.c b/s390x/snippets/c/mvpg-snippet.c
new file mode 100644
index 00000000..c1eb5d77
--- /dev/null
+++ b/s390x/snippets/c/mvpg-snippet.c
@@ -0,0 +1,33 @@
+#include <libcflat.h>
+
+static inline void force_exit(void)
+{
+	asm volatile("	diag	0,0,0x44\n");
+}
+
+static inline int mvpg(unsigned long r0, void *dest, void *src)
+{
+	register unsigned long reg0 asm ("0") = r0;
+	int cc;
+
+	asm volatile("	mvpg    %1,%2\n"
+		     "	ipm     %0\n"
+		     "	srl     %0,28"
+		     : "=d" (cc) : "a" (dest), "a" (src), "d" (reg0)
+		     : "memory", "cc");
+	return cc;
+}
+
+static void test_mvpg_real(void)
+{
+	mvpg(0, (void *)0x5000, (void *)0x6000);
+	force_exit();
+}
+
+__attribute__((section(".text"))) int main(void)
+{
+	test_mvpg_real();
+	test_mvpg_real();
+	test_mvpg_real();
+	return 0;
+}
diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
index a0ec8864..9e1802fd 100644
--- a/s390x/unittests.cfg
+++ b/s390x/unittests.cfg
@@ -106,3 +106,6 @@ timeout = 10
 
 [edat]
 file = edat.elf
+
+[mvpg-sie]
+file = mvpg-sie.elf
-- 
2.31.1


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

* [kvm-unit-tests GIT PULL 4/8] s390x: sie: Add missing includes
  2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
                   ` (2 preceding siblings ...)
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 3/8] s390x: mvpg: Add SIE mvpg test Janosch Frank
@ 2021-07-07 14:03 ` Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 5/8] s390x: sie: Fix sie.h integer types Janosch Frank
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Janosch Frank @ 2021-07-07 14:03 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

arch_def.h is needed for struct psw.
stdint.h is needed for the uint*_t types.

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

diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h
index db30d616..b4bb78c3 100644
--- a/lib/s390x/sie.h
+++ b/lib/s390x/sie.h
@@ -2,6 +2,9 @@
 #ifndef _S390X_SIE_H_
 #define _S390X_SIE_H_
 
+#include <stdint.h>
+#include <asm/arch_def.h>
+
 #define CPUSTAT_STOPPED    0x80000000
 #define CPUSTAT_WAIT       0x10000000
 #define CPUSTAT_ECALL_PEND 0x08000000
-- 
2.31.1


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

* [kvm-unit-tests GIT PULL 5/8] s390x: sie: Fix sie.h integer types
  2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
                   ` (3 preceding siblings ...)
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 4/8] s390x: sie: Add missing includes Janosch Frank
@ 2021-07-07 14:03 ` Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 6/8] lib: s390x: uv: Add offset comments to uv_query and extend it Janosch Frank
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Janosch Frank @ 2021-07-07 14:03 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

Let's only use the uint*_t types.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 lib/s390x/sie.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h
index b4bb78c3..6ba858a2 100644
--- a/lib/s390x/sie.h
+++ b/lib/s390x/sie.h
@@ -173,9 +173,9 @@ struct kvm_s390_sie_block {
 } __attribute__((packed));
 
 struct vm_save_regs {
-	u64 grs[16];
-	u64 fprs[16];
-	u32 fpc;
+	uint64_t grs[16];
+	uint64_t fprs[16];
+	uint32_t fpc;
 };
 
 /* We might be able to nestle all of this into the stack frame. But
@@ -191,7 +191,7 @@ struct vm {
 	struct kvm_s390_sie_block *sblk;
 	struct vm_save_area save_area;
 	/* Ptr to first guest page */
-	u8 *guest_mem;
+	uint8_t *guest_mem;
 };
 
 extern void sie_entry(void);
-- 
2.31.1


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

* [kvm-unit-tests GIT PULL 6/8] lib: s390x: uv: Add offset comments to uv_query and extend it
  2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
                   ` (4 preceding siblings ...)
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 5/8] s390x: sie: Fix sie.h integer types Janosch Frank
@ 2021-07-07 14:03 ` Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 7/8] lib: s390x: Print if a pgm happened while in SIE Janosch Frank
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Janosch Frank @ 2021-07-07 14:03 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

The struct is getting longer, let's add offset comments so we know
where we change things when we add struct members.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
 lib/s390x/asm/uv.h | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h
index dc3e02de..ec10d1c4 100644
--- a/lib/s390x/asm/uv.h
+++ b/lib/s390x/asm/uv.h
@@ -84,22 +84,23 @@ struct uv_cb_init {
 } __attribute__((packed))  __attribute__((aligned(8)));
 
 struct uv_cb_qui {
-	struct uv_cb_header header;
-	u64 reserved08;
-	u64 inst_calls_list[4];
-	u64 reserved30[2];
-	u64 uv_base_stor_len;
-	u64 reserved48;
-	u64 conf_base_phys_stor_len;
-	u64 conf_base_virt_stor_len;
-	u64 conf_virt_var_stor_len;
-	u64 cpu_stor_len;
-	u32 reserved70[3];
-	u32 max_num_sec_conf;
-	u64 max_guest_stor_addr;
-	u8  reserved88[158 - 136];
-	u16 max_guest_cpus;
-	u8  reserveda0[200 - 160];
+	struct uv_cb_header header;	/* 0x0000 */
+	u64 reserved08;			/* 0x0008 */
+	u64 inst_calls_list[4];		/* 0x0010 */
+	u64 reserved30[2];		/* 0x0030 */
+	u64 uv_base_stor_len;		/* 0x0040 */
+	u64 reserved48;			/* 0x0048 */
+	u64 conf_base_phys_stor_len;	/* 0x0050 */
+	u64 conf_base_virt_stor_len;	/* 0x0058 */
+	u64 conf_virt_var_stor_len;	/* 0x0060 */
+	u64 cpu_stor_len;		/* 0x0068 */
+	u32 reserved70[3];		/* 0x0070 */
+	u32 max_num_sec_conf;		/* 0x007c */
+	u64 max_guest_stor_addr;	/* 0x0080 */
+	u8  reserved88[158 - 136];	/* 0x0088 */
+	uint16_t max_guest_cpus;	/* 0x009e */
+	u64 uv_feature_indications;	/* 0x00a0 */
+	u8  reserveda8[200 - 168];	/* 0x00a8 */
 }  __attribute__((packed))  __attribute__((aligned(8)));
 
 struct uv_cb_cgc {
-- 
2.31.1


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

* [kvm-unit-tests GIT PULL 7/8] lib: s390x: Print if a pgm happened while in SIE
  2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
                   ` (5 preceding siblings ...)
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 6/8] lib: s390x: uv: Add offset comments to uv_query and extend it Janosch Frank
@ 2021-07-07 14:03 ` Janosch Frank
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 8/8] lib: s390x: Remove left behing PGM report Janosch Frank
  2021-07-07 17:33 ` [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Paolo Bonzini
  8 siblings, 0 replies; 10+ messages in thread
From: Janosch Frank @ 2021-07-07 14:03 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

For debugging it helps if you know if the PGM happened while being in
SIE or not.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
 lib/s390x/interrupt.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
index b627942f..109f2907 100644
--- a/lib/s390x/interrupt.c
+++ b/lib/s390x/interrupt.c
@@ -141,10 +141,15 @@ static void print_int_regs(struct stack_frame_int *stack)
 static void print_pgm_info(struct stack_frame_int *stack)
 
 {
+	bool in_sie;
+
+	in_sie = (lc->pgm_old_psw.addr >= (uintptr_t)sie_entry &&
+		  lc->pgm_old_psw.addr <= (uintptr_t)sie_exit);
+
 	printf("\n");
-	printf("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);
+	printf("Unexpected program interrupt %s: %d on cpu %d at %#lx, ilen %d\n",
+	       in_sie ? "in SIE" : "",
+	       lc->pgm_int_code, stap(), lc->pgm_old_psw.addr, lc->pgm_int_id);
 	print_int_regs(stack);
 	dump_stack();
 	report_summary();
-- 
2.31.1


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

* [kvm-unit-tests GIT PULL 8/8] lib: s390x: Remove left behing PGM report
  2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
                   ` (6 preceding siblings ...)
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 7/8] lib: s390x: Print if a pgm happened while in SIE Janosch Frank
@ 2021-07-07 14:03 ` Janosch Frank
  2021-07-07 17:33 ` [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Paolo Bonzini
  8 siblings, 0 replies; 10+ messages in thread
From: Janosch Frank @ 2021-07-07 14:03 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

When I added the backtrace support I forgot to remove the PGM report.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
 lib/s390x/interrupt.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c
index 109f2907..785b7355 100644
--- a/lib/s390x/interrupt.c
+++ b/lib/s390x/interrupt.c
@@ -162,9 +162,6 @@ void handle_pgm_int(struct stack_frame_int *stack)
 		/* Force sclp_busy to false, otherwise we will loop forever */
 		sclp_handle_ext();
 		print_pgm_info(stack);
-		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;
-- 
2.31.1


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

* Re: [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07
  2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
                   ` (7 preceding siblings ...)
  2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 8/8] lib: s390x: Remove left behing PGM report Janosch Frank
@ 2021-07-07 17:33 ` Paolo Bonzini
  8 siblings, 0 replies; 10+ messages in thread
From: Paolo Bonzini @ 2021-07-07 17:33 UTC (permalink / raw)
  To: Janosch Frank
  Cc: kvm, david, borntraeger, cohuck, linux-s390, imbrenda, thuth

On 07/07/21 16:03, Janosch Frank wrote:
> Dear Paolo,
> 
> please merge or pull the following changes:
> 
> * Add snippet support that makes starting guests in tests easier
> * Cleanup
> 
> MERGE:
> https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/merge_requests/13
> 
> PIPELINE:
> https://gitlab.com/frankja/kvm-unit-tests/-/pipelines/333035606
> 
> PULL:
> The following changes since commit bc6f264386b4cb2cadc8b2492315f3e6e8a801a2:
> 
>    Merge branch 'arm/queue' into 'master' (2021-06-30 13:35:55 +0000)
> 
> are available in the Git repository at:
> 
>    https://gitlab.com/frankja/kvm-unit-tests.git s390x-pull-2021-07-07
> 
> for you to fetch changes up to 81598ca0d3fbeb52e02eecf5ddbc15e30f8c600a:
> 
>    lib: s390x: Remove left behing PGM report (2021-07-07 08:00:29 +0000)
> 
> Janosch Frank (7):
>    s390x: snippets: Add gitignore as well as linker script and start
>      assembly
>    s390x: mvpg: Add SIE mvpg test
>    s390x: sie: Add missing includes
>    s390x: sie: Fix sie.h integer types
>    lib: s390x: uv: Add offset comments to uv_query and extend it
>    lib: s390x: Print if a pgm happened while in SIE
>    lib: s390x: Remove left behing PGM report
> 
> Steffen Eiden (1):
>    s390x: snippets: Add snippet compilation
> 
>   .gitignore                      |   1 +
>   lib/s390x/asm/uv.h              |  33 +++----
>   lib/s390x/interrupt.c           |  14 +--
>   lib/s390x/sie.h                 |  11 ++-
>   s390x/Makefile                  |  29 +++++--
>   s390x/mvpg-sie.c                | 149 ++++++++++++++++++++++++++++++++
>   s390x/snippets/c/cstart.S       |  16 ++++
>   s390x/snippets/c/flat.lds       |  51 +++++++++++
>   s390x/snippets/c/mvpg-snippet.c |  33 +++++++
>   s390x/unittests.cfg             |   3 +
>   10 files changed, 308 insertions(+), 32 deletions(-)
>   create mode 100644 s390x/mvpg-sie.c
>   create mode 100644 s390x/snippets/c/cstart.S
>   create mode 100644 s390x/snippets/c/flat.lds
>   create mode 100644 s390x/snippets/c/mvpg-snippet.c
> 

Merged, thanks!

Paolo


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

end of thread, other threads:[~2021-07-07 17:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 1/8] s390x: snippets: Add gitignore as well as linker script and start assembly Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 2/8] s390x: snippets: Add snippet compilation Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 3/8] s390x: mvpg: Add SIE mvpg test Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 4/8] s390x: sie: Add missing includes Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 5/8] s390x: sie: Fix sie.h integer types Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 6/8] lib: s390x: uv: Add offset comments to uv_query and extend it Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 7/8] lib: s390x: Print if a pgm happened while in SIE Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 8/8] lib: s390x: Remove left behing PGM report Janosch Frank
2021-07-07 17:33 ` [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Paolo Bonzini

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