aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/s390x
diff options
context:
space:
mode:
authorPavel Zbitskiy <pavel.zbitskiy@gmail.com>2018-08-20 22:51:03 -0400
committerCornelia Huck <cohuck@redhat.com>2018-08-28 17:37:01 +0200
commit3cea09271b3b3a0c4d0ffa3b56ea671bf75d82c3 (patch)
tree0220a87aca578f49c0675a4097749395991803b1 /tests/tcg/s390x
parentad8c851d2e772397e0c35148a16a8fbb559b2a2e (diff)
target/s390x: fix PACK reading 1 byte less and writing 1 byte more
PACK fails on the test from the Principles of Operation: F1F2F3F4 becomes 0000234C instead of 0001234C due to an off-by-one error. Furthermore, it overwrites one extra byte to the left of F1. If len_dest is 0, then we only want to flip the 1st byte and never loop over the rest. Therefore, the loop condition should be > and not >=. If len_src is 1, then we should flip the 1st byte and pack the 2nd. Since len_src is already decremented before the loop, the first condition should be >=, and not >. Likewise for len_src == 2 and the second condition. Signed-off-by: Pavel Zbitskiy <pavel.zbitskiy@gmail.com> Message-Id: <20180821025104.19604-7-pavel.zbitskiy@gmail.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'tests/tcg/s390x')
-rw-r--r--tests/tcg/s390x/Makefile.target1
-rw-r--r--tests/tcg/s390x/pack.c21
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 7de4376f52..151dc075aa 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -5,3 +5,4 @@ TESTS+=csst
TESTS+=ipm
TESTS+=exrl-trt
TESTS+=exrl-trtr
+TESTS+=pack
diff --git a/tests/tcg/s390x/pack.c b/tests/tcg/s390x/pack.c
new file mode 100644
index 0000000000..4be36f29a7
--- /dev/null
+++ b/tests/tcg/s390x/pack.c
@@ -0,0 +1,21 @@
+#include <unistd.h>
+
+int main(void)
+{
+ char data[] = {0xaa, 0xaa, 0xf1, 0xf2, 0xf3, 0xc4, 0xaa, 0xaa};
+ char exp[] = {0xaa, 0xaa, 0x00, 0x01, 0x23, 0x4c, 0xaa, 0xaa};
+ int i;
+
+ asm volatile(
+ " pack 2(4,%[data]),2(4,%[data])\n"
+ :
+ : [data] "r" (&data[0])
+ : "memory");
+ for (i = 0; i < 8; i++) {
+ if (data[i] != exp[i]) {
+ write(1, "bad data\n", 9);
+ return 1;
+ }
+ }
+ return 0;
+}