[PATCH v2] tests/tcg/s390x: Test LOAD and STORE REVERSED

Ilya Leoshkevich posted 1 patch 1 month, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260803123928.1875606-1-iii@linux.ibm.com
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Cornelia Huck <cohuck@redhat.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>
tests/tcg/s390x/Makefile.target       |  1 +
tests/tcg/s390x/load-store-reversed.c | 46 +++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
create mode 100644 tests/tcg/s390x/load-store-reversed.c
[PATCH v2] tests/tcg/s390x: Test LOAD and STORE REVERSED
Posted by Ilya Leoshkevich 1 month, 3 weeks ago
Add a small test to prevent regressions.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---

v1 -> v2: CC: qemu-devel@nongnu.org.
          Check that upper bytes are not modified.

 tests/tcg/s390x/Makefile.target       |  1 +
 tests/tcg/s390x/load-store-reversed.c | 46 +++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 tests/tcg/s390x/load-store-reversed.c

diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 0ca030ded01..fe1fba3de2f 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -50,6 +50,7 @@ TESTS+=cvb
 TESTS+=ts
 TESTS+=ex-smc
 TESTS+=divide-to-integer
+TESTS+=load-store-reversed
 
 cdsg: CFLAGS+=-pthread
 cdsg: LDFLAGS+=-pthread
diff --git a/tests/tcg/s390x/load-store-reversed.c b/tests/tcg/s390x/load-store-reversed.c
new file mode 100644
index 00000000000..bcc6b98dd3b
--- /dev/null
+++ b/tests/tcg/s390x/load-store-reversed.c
@@ -0,0 +1,46 @@
+/*
+ * Test the LOAD REVERSED and STORE REVERSED instructions.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <stdlib.h>
+
+int main(void)
+{
+    long i = 0x123456789abcdefULL, o;
+
+    o = i;
+    asm("lrvr %0,%1" : "+r" (o) : "r" (i));
+    assert(o == 0x1234567efcdab89ULL);
+
+    o = i;
+    asm("lrvgr %0,%1" : "+r" (o) : "r" (i));
+    assert(o == 0xefcdab8967452301ULL);
+
+    o = i;
+    asm("lrvh %0,%1" : "=r" (o) : "T" (i));
+    assert(o == 0x123456789ab2301ULL);
+
+    o = i;
+    asm("lrv %0,%1" : "=r" (o) : "T" (i));
+    assert(o == 0x123456767452301ULL);
+
+    o = i;
+    asm("lrvg %0,%1" : "=r" (o) : "T" (i));
+    assert(o == 0xefcdab8967452301ULL);
+
+    o = i;
+    asm("strvh %1,%0" : "=T" (o) : "r" (i));
+    assert(o == 0xefcd456789abcdefULL);
+
+    o = i;
+    asm("strv %1,%0" : "=T" (o) : "r" (i));
+    assert(o == 0xefcdab8989abcdefULL);
+
+    o = i;
+    asm("strvg %1,%0" : "=T" (o) : "r" (i));
+    assert(o == 0xefcdab8967452301ULL);
+
+    return EXIT_SUCCESS;
+}
-- 
2.55.0
Re: [PATCH v2] tests/tcg/s390x: Test LOAD and STORE REVERSED
Posted by Richard Henderson 1 month, 3 weeks ago
On 8/3/26 05:38, Ilya Leoshkevich wrote:
> Add a small test to prevent regressions.
> 
> Signed-off-by: Ilya Leoshkevich<iii@linux.ibm.com>
> ---
> 
> v1 -> v2: CC:qemu-devel@nongnu.org.
>            Check that upper bytes are not modified.
> 
>   tests/tcg/s390x/Makefile.target       |  1 +
>   tests/tcg/s390x/load-store-reversed.c | 46 +++++++++++++++++++++++++++
>   2 files changed, 47 insertions(+)
>   create mode 100644 tests/tcg/s390x/load-store-reversed.c

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~