xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/debug: fix page-overflow bug in dbg_rw_guest_mem
@ 2021-01-30  1:59 Tamas K Lengyel
  2021-01-30  2:59 ` Andrew Cooper
  0 siblings, 1 reply; 6+ messages in thread
From: Tamas K Lengyel @ 2021-01-30  1:59 UTC (permalink / raw)
  To: xen-devel
  Cc: Tamas K Lengyel, Elena Ufimtseva, Jan Beulich, Andrew Cooper,
	Roger Pau Monné,
	Wei Liu

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.

Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
---
 xen/arch/x86/debug.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/debug.c b/xen/arch/x86/debug.c
index 4356039ed2..f32d4b0bcc 100644
--- a/xen/arch/x86/debug.c
+++ b/xen/arch/x86/debug.c
@@ -112,10 +112,11 @@ static unsigned int dbg_rw_guest_mem(struct domain *dp, void * __user gaddr,
                                      void * __user buf, unsigned int len,
                                      bool toaddr, uint64_t pgd3)
 {
+    unsigned long addr = (unsigned long)gaddr;
+
     while ( len > 0 )
     {
         char *va;
-        unsigned long addr = (unsigned long)gaddr;
         mfn_t mfn;
         gfn_t gfn = INVALID_GFN;
         unsigned long pagecnt;
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-01 16:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-30  1:59 [PATCH] x86/debug: fix page-overflow bug in dbg_rw_guest_mem Tamas K Lengyel
2021-01-30  2:59 ` Andrew Cooper
2021-02-01  9:37   ` Jan Beulich
2021-02-01 11:44     ` Andrew Cooper
2021-02-01 12:29       ` Jan Beulich
2021-02-01 16:36         ` Tamas K Lengyel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).