aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2023-07-04 10:12:33 +0200
committerThomas Huth <thuth@redhat.com>2023-07-10 15:34:24 +0200
commitad85ac6a8f8325b6a15058e99d76203b4cde6044 (patch)
tree3e1cb7dc3a4df82b3eea836dcda6455a7fa04851 /tests
parentf5c2ae7134e388cd543fa0383191a30ea07d272b (diff)
downloadqemu-ad85ac6a8f8325b6a15058e99d76203b4cde6044.zip
qemu-ad85ac6a8f8325b6a15058e99d76203b4cde6044.tar.gz
qemu-ad85ac6a8f8325b6a15058e99d76203b4cde6044.tar.bz2
tests/tcg/s390x: Test LARL with a large offset
Add a small test to prevent regressions. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Acked-by: David Hildenbrand <david@redhat.com> Message-Id: <20230704081506.276055-10-iii@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/tcg/s390x/Makefile.target1
-rw-r--r--tests/tcg/s390x/larl.c21
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 2ef22c8..dbf64c9 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -37,6 +37,7 @@ TESTS+=ex-relative-long
TESTS+=ex-branch
TESTS+=mxdb
TESTS+=epsw
+TESTS+=larl
cdsg: CFLAGS+=-pthread
cdsg: LDFLAGS+=-pthread
diff --git a/tests/tcg/s390x/larl.c b/tests/tcg/s390x/larl.c
new file mode 100644
index 0000000..7c95f89
--- /dev/null
+++ b/tests/tcg/s390x/larl.c
@@ -0,0 +1,21 @@
+/*
+ * Test the LARL instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <stdlib.h>
+
+int main(void)
+{
+ long algfi = (long)main;
+ long larl;
+
+ /*
+ * The compiler may emit larl for the C addition, so compute the expected
+ * value using algfi.
+ */
+ asm("algfi %[r],0xd0000000" : [r] "+r" (algfi) : : "cc");
+ asm("larl %[r],main+0xd0000000" : [r] "=r" (larl));
+
+ return algfi == larl ? EXIT_SUCCESS : EXIT_FAILURE;
+}