From nobody Sat May 4 09:09:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1611972019; cv=none; d=zohomail.com; s=zohoarc; b=SKSVE6YvwEB+mn72XASGxAx6pxbIhs0q/mJnAAQWaBTITM18FBiR8qO28C2pz/v80wgI6qP5SFFZVnz7k7p80SO+qAgMLbVZ5KS9Rta6nZ+9Z9NT8wyzTQDtx8jtgodmnGzvGv3vzyYhjamJjt8rCewlFWHbTqQmqRz4oZ+NXXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611972019; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=iT5MXFBsXMCH6cBRd3G5guiffb30YZTX4JWm9SHxL5E=; b=HJJRZjMnKIfWwU9II8yGGYQE5+azhxRGDmGnG7v09HBWD4kS/LG4b0eHJhyLlkJfDsuVq7i9VNOMWXmc71g7DiIDAwmDD7TTsR7V2viBLGBXD5aEc4+fuyGCj7HzwwsvIkwpoSpKhRJdBN5fcadTxANgD/pM9qEpY6+/gRr76xk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1611972019459634.8749338203764; Fri, 29 Jan 2021 18:00:19 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.78622.143102 (Exim 4.92) (envelope-from ) id 1l5fYN-0002VL-Hh; Sat, 30 Jan 2021 01:59:59 +0000 Received: by outflank-mailman (output) from mailman id 78622.143102; Sat, 30 Jan 2021 01:59:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l5fYN-0002VE-Ej; Sat, 30 Jan 2021 01:59:59 +0000 Received: by outflank-mailman (input) for mailman id 78622; Sat, 30 Jan 2021 01:59:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l5fYM-0002V6-3r for xen-devel@lists.xenproject.org; Sat, 30 Jan 2021 01:59:58 +0000 Received: from MTA-13-3.privateemail.com (unknown [198.54.118.204]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 57e428bb-bf56-472e-a33c-955c6c65ff45; Sat, 30 Jan 2021 01:59:57 +0000 (UTC) Received: from mta-13.privateemail.com (localhost [127.0.0.1]) by mta-13.privateemail.com (Postfix) with ESMTP id 67F72800E2; Fri, 29 Jan 2021 20:59:56 -0500 (EST) Received: from drt-xps-ubuntu.lan (unknown [10.20.151.217]) by mta-13.privateemail.com (Postfix) with ESMTPA id 63B58800DC; Sat, 30 Jan 2021 01:59:55 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 57e428bb-bf56-472e-a33c-955c6c65ff45 From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Cc: Tamas K Lengyel , Elena Ufimtseva , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH] x86/debug: fix page-overflow bug in dbg_rw_guest_mem Date: Fri, 29 Jan 2021 20:59:53 -0500 Message-Id: X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: ClamAV using ClamSMTP Content-Type: text/plain; charset="utf-8" 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 grab= bed 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. Inste= ad 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 tr= ying 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 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 Reviewed-by: Andrew Cooper --- 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 *d= p, void * __user gaddr, void * __user buf, unsigned int len, bool toaddr, uint64_t pgd3) { + unsigned long addr =3D (unsigned long)gaddr; + while ( len > 0 ) { char *va; - unsigned long addr =3D (unsigned long)gaddr; mfn_t mfn; gfn_t gfn =3D INVALID_GFN; unsigned long pagecnt; --=20 2.27.0