From 13fd3a0d31a0cef60364e44fa2b3d0673747a888 Mon Sep 17 00:00:00 2001 From: shay margolis Date: Tue, 16 Jul 2024 21:47:13 +0300 Subject: [PATCH 1/4] main_main, common: Enable tilegx lifting --- common.mk | 8 ++++++++ priv/main_main.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 9085aeff9..b90217cb3 100644 --- a/common.mk +++ b/common.mk @@ -14,6 +14,7 @@ PUB_HEADERS = \ pub/libvex_trc_values.h \ pub/libvex_emnote.h \ pub/libvex_guest_x86.h \ + pub/libvex_guest_tilegx.h \ pub/libvex_guest_amd64.h \ pub/libvex_guest_arm.h \ pub/libvex_guest_ppc32.h \ @@ -27,6 +28,7 @@ PUB_HEADERS = \ # when any of them change PRIV_HEADERS = \ priv/host_x86_defs.h \ + priv/host_tilegx_defs.h \ priv/host_amd64_defs.h \ priv/host_arm_defs.h \ priv/host_ppc_defs.h \ @@ -43,6 +45,7 @@ PRIV_HEADERS = \ priv/guest_generic_x87.h \ priv/guest_generic_bb_to_IR.h \ priv/guest_x86_defs.h \ + priv/guest_tilegx_defs.h \ priv/guest_amd64_defs.h \ priv/guest_arm_defs.h \ priv/guest_ppc_defs.h \ @@ -61,7 +64,9 @@ NORMAL_OBJS = \ priv/main_globals.o \ priv/main_util.o \ priv/s390_disasm.o \ + priv/tilegx_disasm.o \ priv/host_x86_defs.o \ + priv/host_tilegx_defs.o \ priv/host_amd64_defs.o \ priv/host_arm_defs.o \ priv/host_arm64_defs.o \ @@ -70,6 +75,7 @@ NORMAL_OBJS = \ priv/host_s390_defs.o \ priv/host_mips_defs.o \ priv/host_x86_isel.o \ + priv/host_tilegx_isel.o \ priv/host_amd64_isel.o \ priv/host_arm_isel.o \ priv/host_arm64_isel.o \ @@ -87,6 +93,7 @@ NORMAL_OBJS = \ priv/guest_generic_x87.o \ priv/guest_generic_bb_to_IR.o \ priv/guest_x86_helpers.o \ + priv/guest_tilegx_helpers.o \ priv/guest_amd64_helpers.o \ priv/guest_arm_helpers.o \ priv/guest_arm64_helpers.o \ @@ -95,6 +102,7 @@ NORMAL_OBJS = \ priv/guest_s390_helpers.o \ priv/guest_mips_helpers.o \ priv/guest_x86_toIR.o \ + priv/guest_tilegx_toIR.o \ priv/guest_amd64_toIR.o \ priv/guest_arm_toIR.o \ priv/guest_arm64_toIR.o \ diff --git a/priv/main_main.c b/priv/main_main.c index a69cac66b..7955927b5 100644 --- a/priv/main_main.c +++ b/priv/main_main.c @@ -161,7 +161,7 @@ #define MIPS64ST(f) vassert(0) #endif -#if defined(VGA_tilegx) //|| defined(VEXMULTIARCH) +#if defined(VGA_tilegx) || defined(VEXMULTIARCH) #define TILEGXFN(f) f #define TILEGXST(f) f #else From 9ead0ddce33dafe1bcb45cb4e345090b8ea051d0 Mon Sep 17 00:00:00 2001 From: shay margolis Date: Tue, 16 Jul 2024 23:22:38 +0300 Subject: [PATCH 2/4] wip: priv: guest_tilegx_to_IR: Fix strange stack overwrite bug --- priv/guest_tilegx_toIR.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/guest_tilegx_toIR.c b/priv/guest_tilegx_toIR.c index 139cc1c11..a8ba578ad 100644 --- a/priv/guest_tilegx_toIR.c +++ b/priv/guest_tilegx_toIR.c @@ -296,7 +296,7 @@ static DisResult disInstr_TILEGX_WRK ( Bool(*resteerOkFn) (void *, Addr), Bool sigill_diag ) { struct tilegx_decoded_instruction - decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE]; + decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE + 1]; ULong cins, opcode = -1, rd, ra, rb, imm = 0; ULong opd[4]; ULong opd_src_map, opd_dst_map, opd_imm_map; From 4e68890f2cb90bc68c3fc52cbf484c29b65cd3e5 Mon Sep 17 00:00:00 2001 From: shay margolis Date: Tue, 16 Jul 2024 23:23:15 +0300 Subject: [PATCH 3/4] wip: priv: guest_tilegx_to_IR: Fix bad rel-pc calculations bug --- priv/guest_tilegx_toIR.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/guest_tilegx_toIR.c b/priv/guest_tilegx_toIR.c index a8ba578ad..5c184e1d1 100644 --- a/priv/guest_tilegx_toIR.c +++ b/priv/guest_tilegx_toIR.c @@ -414,7 +414,7 @@ static DisResult disInstr_TILEGX_WRK ( Bool(*resteerOkFn) (void *, Addr), /* To decode the given instruction bundle. */ nr_insn = parse_insn_tilegx((tilegx_bundle_bits)cins, - (ULong)(Addr)code, + (ULong)(Addr)(guest_PC_bbstart + delta), decoded); if (vex_traceflags & VEX_TRACE_FE) From 11bcafa70675035d57c2d74e6cd541fa9d66077c Mon Sep 17 00:00:00 2001 From: yshaneh Date: Mon, 9 Feb 2026 00:41:34 +0200 Subject: [PATCH 4/4] priv: guest_tilegx_to_IR: Fix bad guest_PC_bbstart calculation bug --- priv/guest_tilegx_toIR.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/guest_tilegx_toIR.c b/priv/guest_tilegx_toIR.c index 5c184e1d1..e4abb7afb 100644 --- a/priv/guest_tilegx_toIR.c +++ b/priv/guest_tilegx_toIR.c @@ -2570,7 +2570,7 @@ disInstr_TILEGX ( IRSB* irsb_IN, irsb = irsb_IN; host_endness = host_endness_IN; guest_PC_curr_instr = (Addr64) guest_IP; - guest_PC_bbstart = (Addr64) toUInt(guest_IP - delta); + guest_PC_bbstart = guest_PC_curr_instr - delta; dres = disInstr_TILEGX_WRK(resteerOkFn, resteerCisOk, callback_opaque,