diff mbox

tcg/s390: fix branch target change during code retranslation

Message ID 1434431501-9840-1-git-send-email-aurelien@aurel32.net
State New
Headers show

Commit Message

Aurelien Jarno June 16, 2015, 5:11 a.m. UTC
Make sure to not modify the branch target. This ensure that the
branch target is not corrupted during partial retranslation.

Cc: Alexander Graf <agraf@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 tcg/s390/tcg-target.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Alexander Graf June 16, 2015, 4:11 p.m. UTC | #1
On 06/16/15 07:11, Aurelien Jarno wrote:
> Make sure to not modify the branch target. This ensure that the
> branch target is not corrupted during partial retranslation.
>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

This fixes endless loops on s390x for me.

Tested-by: Alexander Graf <agraf@suse.de>


Alex
Richard Henderson June 29, 2015, 3 p.m. UTC | #2
On 06/16/2015 06:11 AM, Aurelien Jarno wrote:
> Make sure to not modify the branch target. This ensure that the
> branch target is not corrupted during partial retranslation.
>
> Cc: Alexander Graf<agraf@suse.de>
> Cc: Richard Henderson<rth@twiddle.net>
> Signed-off-by: Aurelien Jarno<aurelien@aurel32.net>
> ---
>   tcg/s390/tcg-target.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~
Alexander Graf June 30, 2015, 7:27 a.m. UTC | #3
On 29.06.15 17:00, Richard Henderson wrote:
> On 06/16/2015 06:11 AM, Aurelien Jarno wrote:
>> Make sure to not modify the branch target. This ensure that the
>> branch target is not corrupted during partial retranslation.
>>
>> Cc: Alexander Graf<agraf@suse.de>
>> Cc: Richard Henderson<rth@twiddle.net>
>> Signed-off-by: Aurelien Jarno<aurelien@aurel32.net>
>> ---
>>   tcg/s390/tcg-target.c | 12 ++++++++----
>>   1 file changed, 8 insertions(+), 4 deletions(-)
> 
> Reviewed-by: Richard Henderson <rth@twiddle.net>

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


Alex
Richard Henderson June 30, 2015, 7:36 a.m. UTC | #4
On 06/30/2015 08:27 AM, Alexander Graf wrote:
>
>
> On 29.06.15 17:00, Richard Henderson wrote:
>> On 06/16/2015 06:11 AM, Aurelien Jarno wrote:
>>> Make sure to not modify the branch target. This ensure that the
>>> branch target is not corrupted during partial retranslation.
>>>
>>> Cc: Alexander Graf<agraf@suse.de>
>>> Cc: Richard Henderson<rth@twiddle.net>
>>> Signed-off-by: Aurelien Jarno<aurelien@aurel32.net>
>>> ---
>>>    tcg/s390/tcg-target.c | 12 ++++++++----
>>>    1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> Reviewed-by: Richard Henderson <rth@twiddle.net>
>
> 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~
Alexander Graf June 30, 2015, 7:37 a.m. UTC | #5
On 30.06.15 09:36, Richard Henderson wrote:
> On 06/30/2015 08:27 AM, Alexander Graf wrote:
>>
>>
>> On 29.06.15 17:00, Richard Henderson wrote:
>>> On 06/16/2015 06:11 AM, Aurelien Jarno wrote:
>>>> Make sure to not modify the branch target. This ensure that the
>>>> branch target is not corrupted during partial retranslation.
>>>>
>>>> Cc: Alexander Graf<agraf@suse.de>
>>>> Cc: Richard Henderson<rth@twiddle.net>
>>>> Signed-off-by: Aurelien Jarno<aurelien@aurel32.net>
>>>> ---
>>>>    tcg/s390/tcg-target.c | 12 ++++++++----
>>>>    1 file changed, 8 insertions(+), 4 deletions(-)
>>>
>>> Reviewed-by: Richard Henderson <rth@twiddle.net>
>>
>> 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
diff mbox

Patch

diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c
index 669fafe..921991e 100644
--- a/tcg/s390/tcg-target.c
+++ b/tcg/s390/tcg-target.c
@@ -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);