You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While I was emulating an AArch64 program, the SIMD instructions (not sure if this is the right term) is causing problems, after digging around I think I've isolated the issue:
Unicorn calls gen_intermediate_code_internal_a64 to translate the code. The code is translated into a buffer named tcg_ctx->gen_opc_buf and is expected to not fill this buffer for more than OPC_MAX_SIZE elements. However, there is no easy way to check it. The current logic is like the following:
tcg_ctx->gen_opc_ptr = tcg_ctx->gen_opc_buf;
gen_opc_end = tcg_ctx->gen_opc_buf + OPC_MAX_SIZE;
do {
translate_one_a64_instruction(); // inside it fills the buffer and increases tcg_ctx->gen_opc_ptr as needed.
} while (tcg_ctx->gen_opc_ptr < gen_opc_end);
Unfortunately in the sample code the single one instruction LD4 {V12.16B-V15.16B}, [X10] generates more than 0x300 elements in tcg_ctx->gen_opc_buf, causing it go way beyond the expected end of the buffer.
This will later cause the failure in static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, at line 554:
While I was emulating an AArch64 program, the SIMD instructions (not sure if this is the right term) is causing problems, after digging around I think I've isolated the issue:
Here is a sample code:
Unicorn calls
gen_intermediate_code_internal_a64
to translate the code. The code is translated into a buffer named tcg_ctx->gen_opc_buf and is expected to not fill this buffer for more thanOPC_MAX_SIZE
elements. However, there is no easy way to check it. The current logic is like the following:Unfortunately in the sample code the single one instruction
LD4 {V12.16B-V15.16B}, [X10]
generates more than 0x300 elements intcg_ctx->gen_opc_buf
, causing it go way beyond the expected end of the buffer.This will later cause the failure in
static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
at line 554:Here is some debugger output about the size change:
So last instruction causes the
tcg_ctx->gen_opc_ptr
to increase from0x7ffff7b933e6
to0x7ffff7b93778
, that's 0x392 elements in this buffer.The text was updated successfully, but these errors were encountered: