Skip to contentSkip to conversation

target-xtensa: fix CCOUNT for conditional branches

PATCH Applied Max Filippov 2 participants 2 messages May 27, 2012 – Jun 9, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-xtensa: fix CCOUNT for conditional branches

Taken conditional branches fail to update CCOUNT register because accumulated ccount_delta is reset during translation of non-taken branch. To fix it only update CCOUNT once per conditional branch instruction translation.

This fixes guest linux freeze on LTP waitpid06 test.

---
 target-xtensa/translate.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
target-xtensa/translate.c +2 -0
index 521c0e6..a542a31 100644
@@ -388,6 +388,7 @@ static bool gen_check_loop_end(DisasContext *dc, int slot)
             dc->next_pc == dc->lend) {
         int label = gen_new_label();
 
+        gen_advance_ccount(dc);
         tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, label);
         tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1);
         gen_jumpi(dc, dc->lbeg, slot);
@@ -410,6 +411,7 @@ static void gen_brcond(DisasContext *dc, TCGCond cond,
 {
     int label = gen_new_label();
 
+    gen_advance_ccount(dc);
     tcg_gen_brcond_i32(cond, t0, t1, label);
     gen_jumpi_check_loop_end(dc, 0);
     gen_set_label(label);
Signature · 1 line
1.7.7.6
Applied
#1 lore raw

Thanks, applied.

Quoted 35 lines · Max Filippov

Taken conditional branches fail to update CCOUNT register because accumulated ccount_delta is reset during translation of non-taken branch. To fix it only update CCOUNT once per conditional branch instruction translation.

This fixes guest linux freeze on LTP waitpid06 test.

---
 target-xtensa/translate.c |    2 ++

 1 files changed, 2 insertions(+), 0 deletions(-)
target-xtensa/translate.c +2 -1
index 521c0e6..a542a31 100644
@@ -388,6 +388,7 @@ static bool gen_check_loop_end(DisasContext *dc, int slot)
             dc->next_pc == dc->lend) {
         int label = gen_new_label();
 
+        gen_advance_ccount(dc);
         tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, label);
         tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1);
         gen_jumpi(dc, dc->lbeg, slot);
@@ -410,6 +411,7 @@ static void gen_brcond(DisasContext *dc, TCGCond cond,
  {
     int label = gen_new_label();
 
+    gen_advance_ccount(dc);
     tcg_gen_brcond_i32(cond, t0, t1, label);
     gen_jumpi_check_loop_end(dc, 0);
     gen_set_label(label);
--

1.7.7.6