gdbstub: synchronize state for individual 'p' register reads
PATCH 1/1 gdbstub: synchronize state for individual 'p' register reads
'p' does not call cpu_synchronize_state like 'g' does.
Accelerators may keep guest CPU state out of sync with QEMU while a vCPU is running. After a vCPU is stopped, an individual 'p' register read can therefore observe stale state until something updates the state.
---
Notes:
I found this while investigating why LLDB was showing the RIP truncated to 32 bits under WHPX. LLDB appears to use individual p register reads by default, while GDB primarily uses g, which is why I noticed the issue much more consistently with LLDB.
This is my first open-source contribution, so please let me know if I missed anything in the patch or submission process.
gdbstub/gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
gdbstub/gdbstub.c +1 -1
@@ -1246,7 +1246,7 @@ static void handle_get_reg(GArray *params, void *user_ctx)gdb_put_packet ("E14" );return ; } - +cpu_synchronize_state (gdbserver_state.g_cpu); reg_size =gdb_read_register (gdbserver_state.g_cpu, gdbserver_state.mem_buf,gdb_get_cmd_param (params,0 )->val_ull);
Signature · 1 line
2.53.0.windows.1
Quoted 5 lines · Boden Randin
'p' does not call
cpu_synchronize_statelike 'g' does.Accelerators may keep guest CPU state out of sync with QEMU while a vCPU is running. After a vCPU is stopped, an individual 'p' register read can therefore observe stale state until something updates the state.
Yeah, I mentioned that to Alex few months ago and have a similar fix but put my work on hold to avoid clash with Richard series in the same area, waiting his work to be merged:
https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 8 lines
Signed-off-by Boden Randin <[email protected]>---
Notes:
I found this while investigating why LLDB was showing the RIP truncated to 32 bits under WHPX. LLDB appears to use individual p register reads by default, while GDB primarily uses g, which is why I noticed the issue much more consistently with LLDB.This is my first open-source contribution, so please let me know if I missed anything in the patch or submission process.
Well done!
Quoted 9 lines
gdbstub/gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)gdbstub/gdbstub.c +0
-0
gdbstub/gdbstub.c static void handle_get_reg(GArray *params, void *user_ctx) · line 1252
Quoted 8 lines
gdbstub/gdbstub.c +1
-1@@ -1246,7 +1246,7 @@ static void handle_get_reg(GArray *params, void *user_ctx)gdb_put_packet ("E14" );return ; } - +cpu_synchronize_state (gdbserver_state.g_cpu); reg_size =gdb_read_register (gdbserver_state.g_cpu, gdbserver_state.mem_buf,gdb_get_cmd_param (params,0 )->val_ull);