[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.4 15/43] tests/tcg/s390x: Test LCBB
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.4 15/43] tests/tcg/s390x: Test LCBB |
Date: |
Mon, 26 Jun 2023 21:58:33 +0300 |
From: Ilya Leoshkevich <iii@linux.ibm.com>
Add a test to prevent regressions.
Cc: qemu-stable@nongnu.org
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20230526181240.1425579-3-iii@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit 05d000fb4dcac4bc02ffa08fcf14b51683b878f6)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 07fcc6d0ce..24576fda22 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -26,6 +26,7 @@ TESTS+=branch-relative-long
TESTS+=noexec
Z13_TESTS=vistr
+Z13_TESTS+=lcbb
$(Z13_TESTS): CFLAGS+=-march=z13 -O2
TESTS+=$(Z13_TESTS)
diff --git a/tests/tcg/s390x/lcbb.c b/tests/tcg/s390x/lcbb.c
new file mode 100644
index 0000000000..8d368e0998
--- /dev/null
+++ b/tests/tcg/s390x/lcbb.c
@@ -0,0 +1,51 @@
+/*
+ * Test the LCBB instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <stdlib.h>
+
+static inline __attribute__((__always_inline__)) void
+lcbb(long *r1, void *dxb2, int m3, int *cc)
+{
+ asm("lcbb %[r1],%[dxb2],%[m3]\n"
+ "ipm %[cc]"
+ : [r1] "+r" (*r1), [cc] "=r" (*cc)
+ : [dxb2] "R" (*(char *)dxb2), [m3] "i" (m3)
+ : "cc");
+ *cc = (*cc >> 28) & 3;
+}
+
+static char buf[0x1000] __attribute__((aligned(0x1000)));
+
+static inline __attribute__((__always_inline__)) void
+test_lcbb(void *p, int m3, int exp_r1, int exp_cc)
+{
+ long r1 = 0xfedcba9876543210;
+ int cc;
+
+ lcbb(&r1, p, m3, &cc);
+ assert(r1 == (0xfedcba9800000000 | exp_r1));
+ assert(cc == exp_cc);
+}
+
+int main(void)
+{
+ test_lcbb(&buf[0], 0, 16, 0);
+ test_lcbb(&buf[63], 0, 1, 3);
+ test_lcbb(&buf[0], 1, 16, 0);
+ test_lcbb(&buf[127], 1, 1, 3);
+ test_lcbb(&buf[0], 2, 16, 0);
+ test_lcbb(&buf[255], 2, 1, 3);
+ test_lcbb(&buf[0], 3, 16, 0);
+ test_lcbb(&buf[511], 3, 1, 3);
+ test_lcbb(&buf[0], 4, 16, 0);
+ test_lcbb(&buf[1023], 4, 1, 3);
+ test_lcbb(&buf[0], 5, 16, 0);
+ test_lcbb(&buf[2047], 5, 1, 3);
+ test_lcbb(&buf[0], 6, 16, 0);
+ test_lcbb(&buf[4095], 6, 1, 3);
+
+ return EXIT_SUCCESS;
+}
--
2.39.2
- [PATCH 0/6] migration: Test the new "file:" migration, Fabiano Rosas, 2023/06/26
- [PATCH 2/6] tests/qtest: migration: Expose migrate_set_capability, Fabiano Rosas, 2023/06/26
- [PATCH 1/6] migration: Set migration status early in incoming side, Fabiano Rosas, 2023/06/26
- [PATCH 3/6] tests/qtest: migration: Add migrate_incoming_qmp helper, Fabiano Rosas, 2023/06/26
- [PATCH 4/6] tests/qtest: migration: Use migrate_incoming_qmp where appropriate, Fabiano Rosas, 2023/06/26
- [PATCH 5/6] tests/qtest: migration: Add support for negative testing of qmp_migrate, Fabiano Rosas, 2023/06/26
- [PATCH 6/6] tests/qtest: migration-test: Add tests for file-based migration, Fabiano Rosas, 2023/06/26