[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 09/20] accel/tcg: Unlock mmap_lock after longjmp
From: |
Richard Henderson |
Subject: |
[PULL v3 09/20] accel/tcg: Unlock mmap_lock after longjmp |
Date: |
Tue, 6 Sep 2022 09:38:04 +0100 |
The mmap_lock is held around tb_gen_code. While the comment
is correct that the lock is dropped when tb_gen_code runs out
of memory, the lock is *not* dropped when an exception is
raised reading code for translation.
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/cpu-exec.c | 12 ++++++------
accel/tcg/user-exec.c | 3 ---
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index a565a3f8ec..d18081ca6f 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -462,13 +462,11 @@ void cpu_exec_step_atomic(CPUState *cpu)
cpu_tb_exec(cpu, tb, &tb_exit);
cpu_exec_exit(cpu);
} else {
- /*
- * The mmap_lock is dropped by tb_gen_code if it runs out of
- * memory.
- */
#ifndef CONFIG_SOFTMMU
clear_helper_retaddr();
- tcg_debug_assert(!have_mmap_lock());
+ if (have_mmap_lock()) {
+ mmap_unlock();
+ }
#endif
if (qemu_mutex_iothread_locked()) {
qemu_mutex_unlock_iothread();
@@ -936,7 +934,9 @@ int cpu_exec(CPUState *cpu)
#ifndef CONFIG_SOFTMMU
clear_helper_retaddr();
- tcg_debug_assert(!have_mmap_lock());
+ if (have_mmap_lock()) {
+ mmap_unlock();
+ }
#endif
if (qemu_mutex_iothread_locked()) {
qemu_mutex_unlock_iothread();
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 2bc4394b80..521aa8b61e 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -80,10 +80,7 @@ MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write)
* (and if the translator doesn't handle page boundaries correctly
* there's little we can do about that here). Therefore, do not
* trigger the unwinder.
- *
- * Like tb_gen_code, release the memory lock before cpu_loop_exit.
*/
- mmap_unlock();
*pc = 0;
return MMU_INST_FETCH;
}
--
2.34.1
- [PULL v3 00/20] tcg patch queue, Richard Henderson, 2022/09/06
- [PULL v3 03/20] linux-user/x86_64: Allocate vsyscall page as a commpage, Richard Henderson, 2022/09/06
- [PULL v3 02/20] linux-user/hppa: Allocate page zero as a commpage, Richard Henderson, 2022/09/06
- [PULL v3 05/20] linux-user: Clear translations on mprotect(), Richard Henderson, 2022/09/06
- [PULL v3 06/20] tests/tcg/i386: Move smc_code2 to an executable section, Richard Henderson, 2022/09/06
- [PULL v3 08/20] accel/tcg: Properly implement get_page_addr_code for user-only, Richard Henderson, 2022/09/06
- [PULL v3 04/20] linux-user: Honor PT_GNU_STACK, Richard Henderson, 2022/09/06
- [PULL v3 01/20] linux-user/arm: Mark the commpage executable, Richard Henderson, 2022/09/06
- [PULL v3 09/20] accel/tcg: Unlock mmap_lock after longjmp,
Richard Henderson <=
- [PULL v3 07/20] accel/tcg: Introduce is_same_page(), Richard Henderson, 2022/09/06
- [PULL v3 11/20] accel/tcg: Move qemu_ram_addr_from_host_nofail to physmem.c, Richard Henderson, 2022/09/06
- [PULL v3 10/20] accel/tcg: Make tb_htable_lookup static, Richard Henderson, 2022/09/06
- [PULL v3 12/20] accel/tcg: Use probe_access_internal for softmmu get_page_addr_code_hostp, Richard Henderson, 2022/09/06
- [PULL v3 13/20] accel/tcg: Document the faulting lookup in tb_lookup_cmp, Richard Henderson, 2022/09/06
- [PULL v3 14/20] accel/tcg: Remove translator_ldsw, Richard Henderson, 2022/09/06
- [PULL v3 16/20] accel/tcg: Add fast path for translator_ld*, Richard Henderson, 2022/09/06
- [PULL v3 15/20] accel/tcg: Add pc and host_pc params to gen_intermediate_code, Richard Henderson, 2022/09/06
- [PULL v3 17/20] target/s390x: Make translator stop before the end of a page, Richard Henderson, 2022/09/06
- [PULL v3 19/20] target/riscv: Add MAX_INSN_LEN and insn_len, Richard Henderson, 2022/09/06