From patchwork Sat Jan 30 01:59:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 12056721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B066C433E0 for ; Sat, 30 Jan 2021 02:00:13 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0098B64DDF for ; Sat, 30 Jan 2021 02:00:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0098B64DDF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=tklengyel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-Virus-Scanned: ClamAV using ClamSMTP 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 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 *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;