:p
atchew
Login
UBSAN complains: runtime error: addition of unsigned offset to 0x7bc06e1f5000 overflowed to 0x7bc02e1f5000 Cast the pointer to unsigned integer to perform the arithmetic and silence the error. Signed-off-by: Fabiano Rosas <farosas@suse.de> --- tcg/region.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tcg/region.c b/tcg/region.c index XXXXXXX..XXXXXXX 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -XXX,XX +XXX,XX @@ const void *tcg_splitwx_to_rx(void *rw) /* Pass NULL pointers unchanged. */ if (rw) { g_assert(in_code_gen_buffer(rw)); - rw += tcg_splitwx_diff; + rw = (void *)((uintptr_t)rw + tcg_splitwx_diff); } return rw; } @@ -XXX,XX +XXX,XX @@ void *tcg_splitwx_to_rw(const void *rx) { /* Pass NULL pointers unchanged. */ if (rx) { - rx -= tcg_splitwx_diff; + rx = (void *)((uintptr_t)rx - tcg_splitwx_diff); /* Assert that we end with a pointer in the rw region. */ g_assert(in_code_gen_buffer(rx)); } @@ -XXX,XX +XXX,XX @@ static struct tcg_region_tree *tc_ptr_to_region_tree(const void *p) * a signal handler over which the caller has no control. */ if (!in_code_gen_buffer(p)) { - p -= tcg_splitwx_diff; + p = (void *)((uintptr_t)p - tcg_splitwx_diff); if (!in_code_gen_buffer(p)) { return NULL; } @@ -XXX,XX +XXX,XX @@ void tcg_region_init(size_t tb_size, int splitwx, unsigned max_threads) /* Request large pages for the buffer and the splitwx. */ qemu_madvise(region.start_aligned, region.total_size, QEMU_MADV_HUGEPAGE); if (tcg_splitwx_diff) { - qemu_madvise(region.start_aligned + tcg_splitwx_diff, - region.total_size, QEMU_MADV_HUGEPAGE); + uintptr_t buf_rx = (uintptr_t)region.start_aligned + tcg_splitwx_diff; + + qemu_madvise((void *)buf_rx, region.total_size, QEMU_MADV_HUGEPAGE); } /* -- 2.53.0
UBSAN complains: runtime error: addition of unsigned offset to 0x7bc06e1f5000 overflowed to 0x7bc02e1f5000 Change tcg_splitwx_diff to ptrdiff_t and silence the error. Signed-off-by: Fabiano Rosas <farosas@suse.de> --- include/tcg/tcg.h | 2 +- tcg/tcg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index XXXXXXX..XXXXXXX 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -XXX,XX +XXX,XX @@ static inline bool temp_readonly(TCGTemp *ts) extern __thread TCGContext *tcg_ctx; extern const void *tcg_code_gen_epilogue; -extern uintptr_t tcg_splitwx_diff; +extern ptrdiff_t tcg_splitwx_diff; extern TCGv_env tcg_env; bool in_code_gen_buffer(const void *p); diff --git a/tcg/tcg.c b/tcg/tcg.c index XXXXXXX..XXXXXXX 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -XXX,XX +XXX,XX @@ unsigned int tcg_cur_ctxs; unsigned int tcg_max_ctxs; TCGv_env tcg_env; const void *tcg_code_gen_epilogue; -uintptr_t tcg_splitwx_diff; +ptrdiff_t tcg_splitwx_diff; #ifndef CONFIG_TCG_INTERPRETER tcg_prologue_fn *tcg_qemu_tb_exec; -- 2.53.0