tcg: Fix occasional TCG broken problem when ldst optimization enabled
PATCH v3 1/1 tcg: Fix occasional TCG broken problem when ldst optimization enabled
is_tcg_gen_code() checks the upper limit of TCG generated code range wrong, so that TCG could get broken occasionally only when CONFIG_QEMU_LDST_OPTIMIZATION enabled. The reason is code_gen_buffer_max_size does not cover the upper range up to (TCG_MAX_OP_SIZE * OPC_BUF_SIZE), thus code_gen_buffer_max_size should be modified to code_gen_buffer_size.
---
Here's the promised patch with Aurelien Jarno for TCG broken problem, which is supposed to be applied to 1.3.x and 1.4.x releases as well as master. Thanks to Aurelien Jarno and Stefan Weil.
v2: Fix source comment
v3: Inline [email protected] to commit message
translate-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
translate-all.c +2 -2
@@ -1308,11 +1308,11 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,/* check whether the given addr is in TCG generated code buffer or not */ bool is_tcg_gen_code (uintptr_t tc_ptr) { -/* This can be called during code generation, code_gen_buffer_max_size +/* This can be called during code generation, code_gen_buffer_size is used instead of code_gen_ptr for upper boundary checking */ return (tc_ptr >= (uintptr_t )tcg_ctx.code_gen_buffer && tc_ptr < (uintptr_t )(tcg_ctx.code_gen_buffer + - tcg_ctx.code_gen_buffer_max_size)); + tcg_ctx.code_gen_buffer_size)); }#endif
Signature · 1 line
1.7.9.5
Quoted 8 lines · Yeongkyoon Lee
is_tcg_gen_code()checks the upper limit of TCG generated code range wrong, so that TCG could get broken occasionally only whenCONFIG_QEMU_LDST_OPTIMIZATIONenabled. The reason iscode_gen_buffer_max_sizedoes not cover the upper range up to (TCG_MAX_OP_SIZE*OPC_BUF_SIZE), thuscode_gen_buffer_max_sizeshould be modified tocode_gen_buffer_size.Signed-off-by Yeongkyoon Lee <[email protected]>
-- PMM
Quoted 28 lines · Yeongkyoon Lee
is_tcg_gen_code()checks the upper limit of TCG generated code range wrong, so that TCG could get broken occasionally only whenCONFIG_QEMU_LDST_OPTIMIZATIONenabled. The reason iscode_gen_buffer_max_sizedoes not cover the upper range up to (TCG_MAX_OP_SIZE*OPC_BUF_SIZE), thuscode_gen_buffer_max_sizeshould be modified tocode_gen_buffer_size.Signed-off-by Yeongkyoon Lee <[email protected]>---
Here's the promised patch with Aurelien Jarno for TCG broken problem, which is supposed to be applied to 1.3.x and 1.4.x releases as well as master. Thanks to Aurelien Jarno and Stefan Weil.
v2: Fix source comment
v3: Inline [email protected] to commit messagetranslate-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)translate-all.c +0
-0@@ -1308,11 +1308,11 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,/* check whether the given addr is in TCG generated code buffer or not */ bool is_tcg_gen_code (uintptr_t tc_ptr) {
translate-all.c static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, · line 1318
Quoted 10 lines
translate-all.c +2
-2-/* This can be called during code generation, code_gen_buffer_max_size +/* This can be called during code generation, code_gen_buffer_size is used instead of code_gen_ptr for upper boundary checking */ return (tc_ptr >= (uintptr_t )tcg_ctx.code_gen_buffer && tc_ptr < (uintptr_t )(tcg_ctx.code_gen_buffer + - tcg_ctx.code_gen_buffer_max_size)); + tcg_ctx.code_gen_buffer_size)); }#endif
Thanks, applied.
For the stable branch, please fine the corresponding patch below.
Quoted 1 line
From
931ff5988ecd23e2976d20fc6116d2e42ebf6154Mon Sep 17 00:00:00 2001
From: Yeongkyoon Lee <[email protected]>
Date: Fri, 22 Mar 2013 21:50:17 +0900
Subject: [PATCH] tcg: Fix occasional TCG broken problem when ldst
optimization enabled
is_tcg_gen_code() checks the upper limit of TCG generated code range wrong, so that TCG could get broken occasionally only when CONFIG_QEMU_LDST_OPTIMIZATION enabled. The reason is code_gen_buffer_max_size does not cover the upper range up to (TCG_MAX_OP_SIZE * OPC_BUF_SIZE), thus code_gen_buffer_max_size should be modified to code_gen_buffer_size.
Conflicts:
translate-all.c
--- translate-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
translate-all.c +2 -2
@@ -1310,10 +1310,10 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,/* check whether the given addr is in TCG generated code buffer or not */ bool is_tcg_gen_code (uintptr_t tc_ptr) { -/* This can be called during code generation, code_gen_buffer_max_size +/* This can be called during code generation, code_gen_buffer_size is used instead of code_gen_ptr for upper boundary checking */ return (tc_ptr >= (uintptr_t )code_gen_buffer && - tc_ptr < (uintptr_t )(code_gen_buffer + code_gen_buffer_max_size)); + tc_ptr < (uintptr_t )(code_gen_buffer + code_gen_buffer_size)); }#endif
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net