[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PATCH 5/6] target/s390x: fix PACK reading 1 byte less and
From: |
Pavel Zbitskiy |
Subject: |
[qemu-s390x] [PATCH 5/6] target/s390x: fix PACK reading 1 byte less and writing 1 byte more |
Date: |
Sun, 5 Aug 2018 14:28:30 -0400 |
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.
Signed-off-by: Pavel Zbitskiy <address@hidden>
---
target/s390x/mem_helper.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c
index 704d0193b5..bacae4f503 100644
--- a/target/s390x/mem_helper.c
+++ b/target/s390x/mem_helper.c
@@ -1019,15 +1019,15 @@ void HELPER(pack)(CPUS390XState *env, uint32_t len,
uint64_t dest, uint64_t src)
len_src--;
/* now pack every value */
- while (len_dest >= 0) {
+ while (len_dest > 0) {
b = 0;
- if (len_src > 0) {
+ if (len_src >= 0) {
b = cpu_ldub_data_ra(env, src, ra) & 0x0f;
src--;
len_src--;
}
- if (len_src > 0) {
+ if (len_src >= 0) {
b |= cpu_ldub_data_ra(env, src, ra) << 4;
src--;
len_src--;
--
2.16.2.windows.1
- [qemu-s390x] [PATCH 5/6] target/s390x: fix PACK reading 1 byte less and writing 1 byte more,
Pavel Zbitskiy <=