From patchwork Thu May 26 10:44:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 97527 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 51752B6F9D for ; Thu, 26 May 2011 20:45:50 +1000 (EST) Received: from localhost ([::1]:53856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPY4Z-000357-6W for incoming@patchwork.ozlabs.org; Thu, 26 May 2011 06:45:47 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPY3Z-0001Q4-52 for qemu-devel@nongnu.org; Thu, 26 May 2011 06:44:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPY3Y-0000qg-EW for qemu-devel@nongnu.org; Thu, 26 May 2011 06:44:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPY3Y-0000qW-7U for qemu-devel@nongnu.org; Thu, 26 May 2011 06:44:44 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4QAiha6005270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 26 May 2011 06:44:43 -0400 Received: from rincewind.home.kraxel.org (vpn1-4-50.ams2.redhat.com [10.36.4.50]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4QAiXFL027115; Thu, 26 May 2011 06:44:38 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 02CEB441C2; Thu, 26 May 2011 12:44:15 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 26 May 2011 12:44:11 +0200 Message-Id: <1306406654-19351-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1306406654-19351-1-git-send-email-kraxel@redhat.com> References: <1306406654-19351-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 09/12] usb-ehci: fix offset writeback in ehci_buffer_rw X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Two bugs at once: First the mask is backwards, so the it used to keeps the offset and clears the page address, which is not what we need when we update the offset. Second the offset calculation is wrong in case head isn't page aligned. Signed-off-by: Gerd Hoffmann --- hw/usb-ehci.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index 5cbb675..cf10dfc 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -1066,6 +1066,7 @@ static int ehci_buffer_rw(EHCIQueue *q, int bytes, int rw) cpu_physical_memory_rw(head, q->buffer + bufpos, tail - head, rw); bufpos += (tail - head); + offset += (tail - head); bytes -= (tail - head); if (bytes > 0) { @@ -1078,8 +1079,7 @@ static int ehci_buffer_rw(EHCIQueue *q, int bytes, int rw) set_field(&q->qh.token, cpage, QTD_TOKEN_CPAGE); /* save offset into cpage */ - offset = tail - head; - q->qh.bufptr[0] &= ~QTD_BUFPTR_MASK; + q->qh.bufptr[0] &= QTD_BUFPTR_MASK; q->qh.bufptr[0] |= offset; return 0;