Skip to contentSkip to conversation

tcg/i386: Fix %r12 guest_base initialization

PATCH In review Richard Henderson 2 participants 2 messages Apr 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcg/i386: Fix %r12 guest_base initialization

When %gs cannot be used, we use register offset addressing. This path is almost never used, so it was clearly not tested.

---
 tcg/i386/tcg-target.inc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tcg/i386/tcg-target.inc.c +1 -1
index 7f61eeedd0..ec083bddcf 100644
@@ -3737,7 +3737,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
         } else {
             /* Choose R12 because, as a base, it requires a SIB byte. */
             x86_guest_base_index = TCG_REG_R12;
-            tcg_out_mov(s, TCG_TYPE_PTR, x86_guest_base_index, guest_base);
+            tcg_out_movi(s, TCG_TYPE_PTR, x86_guest_base_index, guest_base);
             tcg_regset_set_reg(s->reserved_regs, x86_guest_base_index);
         }
     }
Signature · 1 line
2.20.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 4 lines · Richard Henderson

When %gs cannot be used, we use register offset addressing. This path is almost never used, so it was clearly not tested.

Quoted 17 lines
---
 tcg/i386/tcg-target.inc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tcg/i386/tcg-target.inc.c +1 -1
index 7f61eeedd0..ec083bddcf 100644
@@ -3737,7 +3737,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
         } else {
             /* Choose R12 because, as a base, it requires a SIB byte. */
             x86_guest_base_index = TCG_REG_R12;
-            tcg_out_mov(s, TCG_TYPE_PTR, x86_guest_base_index, guest_base);
+            tcg_out_movi(s, TCG_TYPE_PTR, x86_guest_base_index, guest_base);
             tcg_regset_set_reg(s->reserved_regs, x86_guest_base_index);
         }
     }
Signature · 1 line
Alex Bennée