diff options
| author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-02-17 11:53:47 +0100 |
|---|---|---|
| committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-03-06 15:46:18 +0100 |
| commit | 964a4f2c2972ec9c7574b87541d6070ef5d22f4f (patch) | |
| tree | f412ecb430cbe171e079eadbc164692c64100c18 | |
| parent | a523b62c8573c09d96472e06486bb58740945215 (diff) | |
| download | focaccia-qemu-964a4f2c2972ec9c7574b87541d6070ef5d22f4f.tar.gz focaccia-qemu-964a4f2c2972ec9c7574b87541d6070ef5d22f4f.zip | |
accel/tcg: Take mmap lock in the whole cpu_memory_rw_debug() function
Simplify user implementation of cpu_memory_rw_debug() by
taking the mmap lock globally. See commit 87ab2704296
("linux-user: Allow gdbstub to ignore page protection")
for why this lock is necessary.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250217130610.18313-4-philmd@linaro.org>
| -rw-r--r-- | cpu-target.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cpu-target.c b/cpu-target.c index 20933bde7d..b5230ce183 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -380,6 +380,8 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, int ret = -1; int fd = -1; + mmap_lock(); + while (len > 0) { page = addr & TARGET_PAGE_MASK; l = (page + TARGET_PAGE_SIZE) - addr; @@ -414,11 +416,9 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, * be under mmap_lock() in order to prevent the creation of * another TranslationBlock in between. */ - mmap_lock(); tb_invalidate_phys_range(addr, addr + l - 1); written = pwrite(fd, buf, l, (off_t)(uintptr_t)g2h_untagged(addr)); - mmap_unlock(); if (written != l) { goto out_close; } @@ -454,6 +454,8 @@ out_close: close(fd); } out: + mmap_unlock(); + return ret; } #endif |