Skip to contentSkip to conversation

tcg/s390: fix branch target change during code retranslation

PATCH In review Aurelien Jarno 3 participants 6 messages Jun 16, 2015 – Jun 30, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcg/s390: fix branch target change during code retranslation

Make sure to not modify the branch target. This ensure that the branch target is not corrupted during partial retranslation.

Cc Alexander Graf <[email protected]>
Cc Richard Henderson <[email protected]>
---
 tcg/s390/tcg-target.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
tcg/s390/tcg-target.c +8 -4
index 669fafe..921991e 100644
@@ -1643,8 +1643,10 @@ static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg,
 
     base_reg = tcg_out_tlb_read(s, addr_reg, opc, mem_index, 1);
 
-    label_ptr = s->code_ptr + 1;
-    tcg_out_insn(s, RI, BRC, S390_CC_NE, 0);
+    /* We need to keep the offset unchanged for retranslation.  */
+    tcg_out16(s, RI_BRC | (S390_CC_NE << 4));
+    label_ptr = s->code_ptr;
+    s->code_ptr += 1;
 
     tcg_out_qemu_ld_direct(s, opc, data_reg, base_reg, TCG_REG_R2, 0);
 
@@ -1669,8 +1671,10 @@ static void tcg_out_qemu_st(TCGContext* s, TCGReg data_reg, TCGReg addr_reg,
 
     base_reg = tcg_out_tlb_read(s, addr_reg, opc, mem_index, 0);
 
-    label_ptr = s->code_ptr + 1;
-    tcg_out_insn(s, RI, BRC, S390_CC_NE, 0);
+    /* We need to keep the offset unchanged for retranslation.  */
+    tcg_out16(s, RI_BRC | (S390_CC_NE << 4));
+    label_ptr = s->code_ptr;
+    s->code_ptr += 1;
 
     tcg_out_qemu_st_direct(s, opc, data_reg, base_reg, TCG_REG_R2, 0);
 
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#2 lore raw
In reply to Aurelien Jarno
Quoted 9 lines · Aurelien Jarno

Make sure to not modify the branch target. This ensure that the branch target is not corrupted during partial retranslation.

Cc Alexander Graf<[email protected]>
Cc Richard Henderson<[email protected]>
---
  tcg/s390/tcg-target.c | 12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)

r~

#3 lore raw
Quoted 4 lines · Richard Henderson
Quoted 3 lines · Aurelien Jarno

Make sure to not modify the branch target. This ensure that the branch target is not corrupted during partial retranslation.

Quoted 8 lines
Quoted 6 lines
Cc Alexander Graf<[email protected]>
Cc Richard Henderson<[email protected]>
---
  tcg/s390/tcg-target.c | 12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)

This is for s390 hosts. Should I still take it via the s390-next tree or do you want to push it?

Alex

#4 lore raw
Quoted 14 lines · Alexander Graf
Quoted 11 lines · Richard Henderson
Quoted 9 lines · Aurelien Jarno

Make sure to not modify the branch target. This ensure that the branch target is not corrupted during partial retranslation.

Cc Alexander Graf<[email protected]>
Cc Richard Henderson<[email protected]>
---
   tcg/s390/tcg-target.c | 12 ++++++++----
   1 file changed, 8 insertions(+), 4 deletions(-)
Quoted 4 lines
Quoted 1 line

This is for s390 hosts. Should I still take it via the s390-next tree or do you want to push it?

I'm travelling at the moment. If you could take it that would be helpful.

r~

#5 lore raw
Quoted 15 lines · Richard Henderson
Quoted 14 lines · Alexander Graf
Quoted 11 lines · Richard Henderson
Quoted 9 lines · Aurelien Jarno

Make sure to not modify the branch target. This ensure that the branch target is not corrupted during partial retranslation.

Cc Alexander Graf<[email protected]>
Cc Richard Henderson<[email protected]>
---
   tcg/s390/tcg-target.c | 12 ++++++++----
   1 file changed, 8 insertions(+), 4 deletions(-)
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

This is for s390 hosts. Should I still take it via the s390-next tree or do you want to push it?

I'm travelling at the moment. If you could take it that would be helpful.

Sure. Thanks, applied to s390-next.

Alex