x86/debug: fix page-overflow bug in dbg_rw_guest_mem
authorTamas K Lengyel <tamas@tklengyel.com>
Fri, 5 Mar 2021 14:29:31 +0000 (15:29 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 5 Mar 2021 14:29:31 +0000 (15:29 +0100)
commitec003beb5c94fc9918ac1cc87fcccf3892c237e2
tree08862caf1eeea5179de777522b989e55f94487c7
parent3d09a43f75a7ad0d24b460d9ba6130da637ffeed
x86/debug: fix page-overflow bug in dbg_rw_guest_mem

When using gdbsx dbg_rw_guest_mem is used to read/write guest memory. When the
buffer being accessed is on a page-boundary, the next page needs to be grabbed
to access the correct memory for the buffer's overflown parts. While
dbg_rw_guest_mem has logic to handle that, it broke with 229492e210a. Instead
of grabbing the next page the code right now is looping back to the
start of the first page. This results in errors like the following while trying
to use gdb with Linux' lx-dmesg:

[    0.114457] PM: hibernation: Registered nosave memory: [mem
0xfdfff000-0xffffffff]
[    0.114460] [mem 0x90000000-0xfbffffff] available for PCI demem 0
[    0.114462] f]f]
Python Exception <class 'ValueError'> embedded null character:
Error occurred in Python: embedded null character

Fixing this bug by taking the variable assignment outside the loop.

Fixes: 229492e210a ("x86/debugger: use copy_to/from_guest() in dbg_rw_guest_mem()")
Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: 9dc687f155a57216b83b17f9cde55dd43e06b0cd
master date: 2021-01-30 03:21:33 +0000
xen/arch/x86/debug.c