Skip to contentSkip to conversation

target/ppc: Fix load endianness for lxvwsx/lxvdsx

PATCH In review Giuseppe Musacchio 3 participants 4 messages May 18, 2021 – May 19, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/ppc: Fix load endianness for lxvwsx/lxvdsx

TARGET_WORDS_BIGENDIAN may not match the machine endianness if that's a runtime-configurable parameter.

Fixes bcb0b7b1a1c05707304f80ca6f523d557816f85c
Fixes afae37d98ae991c0792c867dbd9f32f988044318

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/212

---
 target/ppc/translate/vsx-impl.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/translate/vsx-impl.c.inc +2 -2
index b817d31260..57a7f73bba 100644
@@ -139,7 +139,7 @@ static void gen_lxvwsx(DisasContext *ctx)
     gen_addr_reg_index(ctx, EA);
 
     data = tcg_temp_new_i32();
-    tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, MO_TEUL);
+    tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, DEF_MEMOP(MO_UL));
     tcg_gen_gvec_dup_i32(MO_UL, vsr_full_offset(xT(ctx->opcode)), 16, 16, data);
 
     tcg_temp_free(EA);
@@ -162,7 +162,7 @@ static void gen_lxvdsx(DisasContext *ctx)
     gen_addr_reg_index(ctx, EA);
 
     data = tcg_temp_new_i64();
-    tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, MO_TEQ);
+    tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, DEF_MEMOP(MO_Q));
     tcg_gen_gvec_dup_i64(MO_Q, vsr_full_offset(xT(ctx->opcode)), 16, 16, data);
 
     tcg_temp_free(EA);
Signature · 1 line
2.30.2
Tested-by on v2 1/1
#1 lore raw

Thanks, all! My original patch which addressed this issue for me probably should've been labeled as an RFC. Thanks for your willingness to review it, in spite of its problems. It was a bit of a stab in the dark. I hope it at least helped get to this solution.

Do I need to do anything about the GitLab issue?
https://gitlab.com/qemu-project/qemu/-/issues/212

(I couldn't even figure out how to subscribe to my own issue, or if I already was, or who might have been notified of its existence, or if discussion should happen there or here.)

Quoted 36 lines · Giuseppe Musacchio

TARGET_WORDS_BIGENDIAN may not match the machine endianness if that's a runtime-configurable parameter.

Fixes bcb0b7b1a1c05707304f80ca6f523d557816f85c
Fixes afae37d98ae991c0792c867dbd9f32f988044318

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/212

---
 target/ppc/translate/vsx-impl.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/translate/vsx-impl.c.inc +2 -2
index b817d31260..57a7f73bba 100644
@@ -139,7 +139,7 @@ static void gen_lxvwsx(DisasContext *ctx)
     gen_addr_reg_index(ctx, EA);
 
     data = tcg_temp_new_i32();
-    tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, MO_TEUL);
+    tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, DEF_MEMOP(MO_UL));
     tcg_gen_gvec_dup_i32(MO_UL, vsr_full_offset(xT(ctx->opcode)), 16, 16, data);
 
     tcg_temp_free(EA);
@@ -162,7 +162,7 @@ static void gen_lxvdsx(DisasContext *ctx)
     gen_addr_reg_index(ctx, EA);
 
     data = tcg_temp_new_i64();
-    tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, MO_TEQ);
+    tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, DEF_MEMOP(MO_Q));
     tcg_gen_gvec_dup_i64(MO_Q, vsr_full_offset(xT(ctx->opcode)), 16, 16, data);
 
     tcg_temp_free(EA);
Signature · 1 line
2.30.2

PC

#2 lore raw
Quoted 9 lines · Paul A. Clarke

Thanks, all! My original patch which addressed this issue for me probably should've been labeled as an RFC. Thanks for your willingness to review it, in spite of its problems. It was a bit of a stab in the dark. I hope it at least helped get to this solution.

Do I need to do anything about the GitLab issue?
https://gitlab.com/qemu-project/qemu/-/issues/212

If you could retest and close the issue once the fix is merged, that would be helpful, thanks.

Quoted 43 lines

(I couldn't even figure out how to subscribe to my own issue, or if I already was, or who might have been notified of its existence, or if discussion should happen there or here.)

Quoted 26 lines · Giuseppe Musacchio

TARGET_WORDS_BIGENDIAN may not match the machine endianness if that's a runtime-configurable parameter.

Fixes bcb0b7b1a1c05707304f80ca6f523d557816f85c
Fixes afae37d98ae991c0792c867dbd9f32f988044318

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/212

---
 target/ppc/translate/vsx-impl.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/translate/vsx-impl.c.inc +1 -1
index b817d31260..57a7f73bba 100644
@@ -139,7 +139,7 @@ static void gen_lxvwsx(DisasContext *ctx)
     gen_addr_reg_index(ctx, EA);
 
     data = tcg_temp_new_i32();
-    tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, MO_TEUL);
+    tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, DEF_MEMOP(MO_UL));
     tcg_gen_gvec_dup_i32(MO_UL, vsr_full_offset(xT(ctx->opcode)), 16, 16, data);
 
     tcg_temp_free(EA);

target/ppc/translate/vsx-impl.c.inc static void gen_lxvdsx(DisasContext *ctx) · line 168

Quoted 8 lines
target/ppc/translate/vsx-impl.c.inc +1 -1
@@ -162,7 +162,7 @@ static void gen_lxvdsx(DisasContext *ctx)
     gen_addr_reg_index(ctx, EA);
 
     data = tcg_temp_new_i64();
-    tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, MO_TEQ);
+    tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, DEF_MEMOP(MO_Q));
     tcg_gen_gvec_dup_i64(MO_Q, vsr_full_offset(xT(ctx->opcode)), 16, 16, data);
 
     tcg_temp_free(EA);

PC

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
In reply to Giuseppe Musacchio
Quoted 8 lines · Giuseppe Musacchio

TARGET_WORDS_BIGENDIAN may not match the machine endianness if that's a runtime-configurable parameter.

Fixes bcb0b7b1a1c05707304f80ca6f523d557816f85c
Fixes afae37d98ae991c0792c867dbd9f32f988044318

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/212

That looks more like it. Applied to ppc-for-6.1, thanks.

Quoted 26 lines
---
 target/ppc/translate/vsx-impl.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/translate/vsx-impl.c.inc +2 -2
index b817d31260..57a7f73bba 100644
@@ -139,7 +139,7 @@ static void gen_lxvwsx(DisasContext *ctx)
     gen_addr_reg_index(ctx, EA);
 
     data = tcg_temp_new_i32();
-    tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, MO_TEUL);
+    tcg_gen_qemu_ld_i32(data, EA, ctx->mem_idx, DEF_MEMOP(MO_UL));
     tcg_gen_gvec_dup_i32(MO_UL, vsr_full_offset(xT(ctx->opcode)), 16, 16, data);
 
     tcg_temp_free(EA);
@@ -162,7 +162,7 @@ static void gen_lxvdsx(DisasContext *ctx)
     gen_addr_reg_index(ctx, EA);
 
     data = tcg_temp_new_i64();
-    tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, MO_TEQ);
+    tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, DEF_MEMOP(MO_Q));
     tcg_gen_gvec_dup_i64(MO_Q, vsr_full_offset(xT(ctx->opcode)), 16, 16, data);
 
     tcg_temp_free(EA);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson