|
From: | Philippe Mathieu-Daudé |
Subject: | Re: [PATCH 1/2] gdbstub: Set current_cpu for memory read write |
Date: | Tue, 22 Mar 2022 19:59:13 +0100 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 |
+Thomas On 22/3/22 16:56, Peter Maydell wrote:
On Tue, 22 Mar 2022 at 15:43, Bin Meng <bmeng.cn@gmail.com> wrote:When accessing the per-CPU register bank of some devices (e.g.: GIC) from the GDB stub context, a segfault occurs. This is due to current_cpu is not set, as the contect is not a guest CPU. Let's set current_cpu before doing the acutal memory read write. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/124 Signed-off-by: Bin Meng <bmeng.cn@gmail.com> ---This works, but I worry a bit that it might have unexpected side effects, and setting globals (even if thread-local) to cause side-effects elsewhere isn't ideal...
Yeah, gdbstub is like a JTAG probe, CPU accessors/views shouldn't be involved. Having current_cpu==NULL seems the correct behavior. There was a thread few years ago about an issue similar to this one. IIRC it was about how to have qtest commands select a different address space instead of the 'current cpu' one. I wonder why target_memory_rw_debug() involves CPU at all. Maybe it is simply not using the correct API?
[Prev in Thread] | Current Thread | [Next in Thread] |