When specification exception interpretation is enabled, specification exceptions need not result in interceptions. However, if the exception is due to an invalid program new PSW, interception must occur. Test this. Also test that interpretation does occur if interpretation is disabled. v2 -> v3 drop patch converting assert to report drop non-ascii symbol use snippet constants v1 -> v2 Add license and test description Use lowcore pointer instead of magic value for program new PSW -> need to get rid of assert in arch_def.h Do not use odd program new PSW, even if irrelevant Use SIE lib Reword messages Fix nits Janis Schoetterl-Glausch (1): s390x: Add specification exception interception test s390x/Makefile | 2 + lib/s390x/sie.h | 1 + s390x/snippets/c/spec_ex.c | 21 ++++++++++ s390x/spec_ex-sie.c | 82 ++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 ++ 5 files changed, 109 insertions(+) create mode 100644 s390x/snippets/c/spec_ex.c create mode 100644 s390x/spec_ex-sie.c Range-diff against v2: 1: f8abbae ! 1: 319eb08 s390x: Add specification exception interception test @@ s390x/Makefile: tests += $(TEST_DIR)/mvpg.elf tests_binary = $(patsubst %.elf,%.bin,$(tests)) ifneq ($(HOST_KEY_DOCUMENT),) -@@ s390x/Makefile: snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o +@@ s390x/Makefile: snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o lib/auxinfo.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 @@ s390x/snippets/c/spec_ex.c (new) @@ +// SPDX-License-Identifier: GPL-2.0-only +/* -+ * <utf-8 (C) symbol> Copyright IBM Corp. 2021 ++ * Copyright IBM Corp. 2021 + * + * Snippet used by specification exception interception test. + */ -+#include <stdint.h> ++#include <libcflat.h> ++#include <bitops.h> +#include <asm/arch_def.h> + +__attribute__((section(".text"))) int main(void) @@ s390x/snippets/c/spec_ex.c (new) + uint64_t bad_psw = 0; + + /* PSW bit 12 has no name or meaning and must be 0 */ -+ lowcore->pgm_new_psw.mask = 1UL << (63 - 12); ++ lowcore->pgm_new_psw.mask = BIT(63 - 12); + lowcore->pgm_new_psw.addr = 0xdeadbeee; + asm volatile ("lpsw %0" :: "Q"(bad_psw)); + return 0; @@ s390x/spec_ex-sie.c (new) @@ +// SPDX-License-Identifier: GPL-2.0-only +/* -+ * <utf-8 (C) symbol> Copyright IBM Corp. 2021 ++ * Copyright IBM Corp. 2021 + * + * Specification exception interception test. + * Checks that specification exception interceptions occur as expected when @@ s390x/spec_ex-sie.c (new) +#include <alloc_page.h> +#include <vm.h> +#include <sie.h> ++#include <snippet.h> + +static struct vm vm; -+extern const char _binary_s390x_snippets_c_spec_ex_gbin_start[]; -+extern const char _binary_s390x_snippets_c_spec_ex_gbin_end[]; ++extern const char SNIPPET_NAME_START(c, spec_ex)[]; ++extern const char SNIPPET_NAME_END(c, spec_ex)[]; + +static void setup_guest(void) +{ + char *guest; -+ int binary_size = ((uintptr_t)_binary_s390x_snippets_c_spec_ex_gbin_end - -+ (uintptr_t)_binary_s390x_snippets_c_spec_ex_gbin_start); ++ int binary_size = SNIPPET_LEN(c, spec_ex); + + setup_vm(); + guest = alloc_pages(8); -+ memcpy(guest, _binary_s390x_snippets_c_spec_ex_gbin_start, binary_size); ++ memcpy(guest, SNIPPET_NAME_START(c, spec_ex), binary_size); + sie_guest_create(&vm, (uint64_t) guest, HPAGE_SIZE); +} + +static void reset_guest(void) +{ -+ vm.sblk->gpsw.addr = PAGE_SIZE * 4; -+ vm.sblk->gpsw.mask = PSW_MASK_64; ++ vm.sblk->gpsw = snippet_psw; + vm.sblk->icptcode = 0; +} + base-commit: 3ac97f8fc847d05d0a5555aefd34e2cac26fdc0c -- 2.31.1