[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.1.3 52/55] tests/tcg/s390x: Test CLC with inaccessible second
From: |
Michael Tokarev |
Subject: |
[Stable-8.1.3 52/55] tests/tcg/s390x: Test CLC with inaccessible second operand |
Date: |
Thu, 9 Nov 2023 16:42:56 +0300 |
From: Ilya Leoshkevich <iii@linux.ibm.com>
Add a small test to prevent regressions.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20231106093605.1349201-3-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit 43fecbe7a53fe8e5a6aff0d6471b1cc624e26b51)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 1fc9809907..3ddbde1a9d 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -41,6 +41,7 @@ TESTS+=larl
TESTS+=mdeb
TESTS+=cgebra
TESTS+=clgebr
+TESTS+=clc
cdsg: CFLAGS+=-pthread
cdsg: LDFLAGS+=-pthread
diff --git a/tests/tcg/s390x/clc.c b/tests/tcg/s390x/clc.c
new file mode 100644
index 0000000000..e14189bd75
--- /dev/null
+++ b/tests/tcg/s390x/clc.c
@@ -0,0 +1,48 @@
+/*
+ * Test the CLC instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static void handle_sigsegv(int sig, siginfo_t *info, void *ucontext)
+{
+ mcontext_t *mcontext = &((ucontext_t *)ucontext)->uc_mcontext;
+ if (mcontext->gregs[0] != 600) {
+ write(STDERR_FILENO, "bad r0\n", 7);
+ _exit(EXIT_FAILURE);
+ }
+ if (((mcontext->psw.mask >> 44) & 3) != 1) {
+ write(STDERR_FILENO, "bad cc\n", 7);
+ _exit(EXIT_FAILURE);
+ }
+ _exit(EXIT_SUCCESS);
+}
+
+int main(void)
+{
+ register unsigned long r0 asm("r0");
+ unsigned long mem = 42, rhs = 500;
+ struct sigaction act;
+ int err;
+
+ memset(&act, 0, sizeof(act));
+ act.sa_sigaction = handle_sigsegv;
+ act.sa_flags = SA_SIGINFO;
+ err = sigaction(SIGSEGV, &act, NULL);
+ assert(err == 0);
+
+ r0 = 100;
+ asm("algr %[r0],%[rhs]\n"
+ "clc 0(8,%[mem]),0(0)\n" /* The 2nd operand will cause a SEGV. */
+ : [r0] "+r" (r0)
+ : [mem] "r" (&mem)
+ , [rhs] "r" (rhs)
+ : "cc", "memory");
+
+ return EXIT_FAILURE;
+}
--
2.39.2
- [Stable-8.1.3 40/55] qcow2: keep reference on zeroize with discard-no-unref enabled, (continued)
- [Stable-8.1.3 40/55] qcow2: keep reference on zeroize with discard-no-unref enabled, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 42/55] file-posix: fix over-writing of returning zone_append offset, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 43/55] ati-vga: Implement fallback for pixman routines, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 44/55] ui/gtk: force realization of drawing area, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 46/55] ui/gtk-egl: Check EGLSurface before doing scanout, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 47/55] target/mips: Fix MSA BZ/BNZ opcodes displacement, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 48/55] target/mips: Fix TX79 LQ/SQ opcodes, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 49/55] hw/ide: reset: cancel async DMA operation before resetting state, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 50/55] tests/qtest: ahci-test: add test exposing reset issue with pending callback, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 51/55] target/s390x: Fix CLC corrupting cc_src, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 52/55] tests/tcg/s390x: Test CLC with inaccessible second operand,
Michael Tokarev <=
- [Stable-8.1.3 54/55] tests/tcg/s390x: Test LAALG with negative cc_src, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 53/55] target/s390x: Fix LAALG not updating cc_src, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 55/55] hw/ide/ahci: trigger either error IRQ or regular IRQ, not both, Michael Tokarev, 2023/11/09
- Re: [Stable-8.1.3 00/55] Patch Round-up for stable 8.1.3, freeze on 2023-11-19, Daniel Henrique Barboza, 2023/11/13