[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/47] tcg/i386: Support split-wx code generation
From: |
Richard Henderson |
Subject: |
[PULL 25/47] tcg/i386: Support split-wx code generation |
Date: |
Thu, 7 Jan 2021 10:14:26 -1000 |
Reviewed-by: Joelle van Dyne <j@getutm.app>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/i386/tcg-target.h | 2 +-
tcg/i386/tcg-target.c.inc | 20 +++++++++++---------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h
index 73aa45a665..cb1b138b66 100644
--- a/tcg/i386/tcg-target.h
+++ b/tcg/i386/tcg-target.h
@@ -235,6 +235,6 @@ static inline void tb_target_set_jmp_target(uintptr_t
tc_ptr, uintptr_t jmp_rx,
#define TCG_TARGET_NEED_LDST_LABELS
#endif
#define TCG_TARGET_NEED_POOL_LABELS
-#define TCG_TARGET_SUPPORT_MIRROR 0
+#define TCG_TARGET_SUPPORT_MIRROR 1
#endif
diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc
index d272975ff1..34bf0b9a35 100644
--- a/tcg/i386/tcg-target.c.inc
+++ b/tcg/i386/tcg-target.c.inc
@@ -164,7 +164,7 @@ static bool have_lzcnt;
# define have_lzcnt 0
#endif
-static tcg_insn_unit *tb_ret_addr;
+static const tcg_insn_unit *tb_ret_addr;
static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
intptr_t value, intptr_t addend)
@@ -172,7 +172,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
value += addend;
switch(type) {
case R_386_PC32:
- value -= (uintptr_t)code_ptr;
+ value -= (uintptr_t)tcg_splitwx_to_rx(code_ptr);
if (value != (int32_t)value) {
return false;
}
@@ -181,7 +181,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
tcg_patch32(code_ptr, value);
break;
case R_386_PC8:
- value -= (uintptr_t)code_ptr;
+ value -= (uintptr_t)tcg_splitwx_to_rx(code_ptr);
if (value != (int8_t)value) {
return false;
}
@@ -1015,7 +1015,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type,
}
/* Try a 7 byte pc-relative lea before the 10 byte movq. */
- diff = arg - ((uintptr_t)s->code_ptr + 7);
+ diff = tcg_pcrel_diff(s, (const void *)arg) - 7;
if (diff == (int32_t)diff) {
tcg_out_opc(s, OPC_LEA | P_REXW, ret, 0, 0);
tcg_out8(s, (LOWREGMASK(ret) << 3) | 5);
@@ -1624,7 +1624,7 @@ static inline void tcg_out_call(TCGContext *s, const
tcg_insn_unit *dest)
tcg_out_branch(s, 1, dest);
}
-static void tcg_out_jmp(TCGContext *s, tcg_insn_unit *dest)
+static void tcg_out_jmp(TCGContext *s, const tcg_insn_unit *dest)
{
tcg_out_branch(s, 0, dest);
}
@@ -1795,7 +1795,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool
is_ld, bool is_64,
label->datahi_reg = datahi;
label->addrlo_reg = addrlo;
label->addrhi_reg = addrhi;
- label->raddr = raddr;
+ /* TODO: Cast goes away when all hosts converted */
+ label->raddr = (void *)tcg_splitwx_to_rx(raddr);
label->label_ptr[0] = label_ptr[0];
if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) {
label->label_ptr[1] = label_ptr[1];
@@ -2253,7 +2254,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode
opc,
/* jump displacement must be aligned for atomic patching;
* see if we need to add extra nops before jump
*/
- gap = tcg_pcrel_diff(s, QEMU_ALIGN_PTR_UP(s->code_ptr + 1, 4));
+ gap = QEMU_ALIGN_PTR_UP(s->code_ptr + 1, 4) - s->code_ptr;
if (gap != 1) {
tcg_out_nopn(s, gap - 1);
}
@@ -3803,11 +3804,12 @@ static void tcg_target_qemu_prologue(TCGContext *s)
* Return path for goto_ptr. Set return value to 0, a-la exit_tb,
* and fall through to the rest of the epilogue.
*/
- tcg_code_gen_epilogue = s->code_ptr;
+ /* TODO: Cast goes away when all hosts converted */
+ tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr);
tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0);
/* TB epilogue */
- tb_ret_addr = s->code_ptr;
+ tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr);
tcg_out_addi(s, TCG_REG_CALL_STACK, stack_addend);
--
2.25.1
- [PULL 10/47] tcg: Move tcg epilogue pointer out of TCGContext, (continued)
- [PULL 10/47] tcg: Move tcg epilogue pointer out of TCGContext, Richard Henderson, 2021/01/07
- [PULL 12/47] tcg: Introduce tcg_splitwx_to_{rx,rw}, Richard Henderson, 2021/01/07
- [PULL 14/47] tcg: Adjust tcg_out_call for const, Richard Henderson, 2021/01/07
- [PULL 13/47] tcg: Adjust TCGLabel for const, Richard Henderson, 2021/01/07
- [PULL 11/47] tcg: Add in_code_gen_buffer, Richard Henderson, 2021/01/07
- [PULL 15/47] tcg: Adjust tcg_out_label for const, Richard Henderson, 2021/01/07
- [PULL 16/47] tcg: Adjust tcg_register_jit for const, Richard Henderson, 2021/01/07
- [PULL 17/47] tcg: Adjust tb_target_set_jmp_target for split-wx, Richard Henderson, 2021/01/07
- [PULL 19/47] tcg: Make tb arg to synchronize_from_tb const, Richard Henderson, 2021/01/07
- [PULL 18/47] tcg: Make DisasContextBase.tb const, Richard Henderson, 2021/01/07
- [PULL 25/47] tcg/i386: Support split-wx code generation,
Richard Henderson <=
- [PULL 23/47] accel/tcg: Support split-wx for darwin/iOS with vm_remap, Richard Henderson, 2021/01/07
- [PULL 24/47] tcg: Return the TB pointer from the rx region from exit_tb, Richard Henderson, 2021/01/07
- [PULL 21/47] tcg: Add --accel tcg,split-wx property, Richard Henderson, 2021/01/07
- [PULL 22/47] accel/tcg: Support split-wx for linux with memfd, Richard Henderson, 2021/01/07
- [PULL 27/47] tcg/aarch64: Support split-wx code generation, Richard Henderson, 2021/01/07
- [PULL 29/47] tcg/tci: Push const down through bytecode reading, Richard Henderson, 2021/01/07
- [PULL 32/47] tcg/ppc: Use tcg_out_mem_long to reset TCG_REG_TB, Richard Henderson, 2021/01/07
- [PULL 36/47] tcg/s390: Use tcg_tbrel_diff, Richard Henderson, 2021/01/07
- [PULL 20/47] tcg: Use Error with alloc_code_gen_buffer, Richard Henderson, 2021/01/07
- [PULL 33/47] tcg/ppc: Support split-wx code generation, Richard Henderson, 2021/01/07