From patchwork Thu Jun 11 20:30:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Herv=C3=A9_Poussineau?= X-Patchwork-Id: 483259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 79F5A140273 for ; Fri, 12 Jun 2015 06:35:21 +1000 (AEST) Received: from localhost ([::1]:48548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z39C2-0004IS-OS for incoming@patchwork.ozlabs.org; Thu, 11 Jun 2015 16:35:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z39Bj-0003xE-80 for qemu-devel@nongnu.org; Thu, 11 Jun 2015 16:35:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z39Be-00072d-8b for qemu-devel@nongnu.org; Thu, 11 Jun 2015 16:34:59 -0400 Received: from smtp2-g21.free.fr ([2a01:e0c:1:1599::11]:54539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z39Be-000724-2e for qemu-devel@nongnu.org; Thu, 11 Jun 2015 16:34:54 -0400 Received: from localhost.localdomain (unknown [82.227.227.196]) by smtp2-g21.free.fr (Postfix) with ESMTP id 1A8874B0255; Thu, 11 Jun 2015 22:32:25 +0200 (CEST) From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= To: qemu-devel@nongnu.org Date: Thu, 11 Jun 2015 22:30:31 +0200 Message-Id: <1434054631-32241-1-git-send-email-hpoussin@reactos.org> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::11 Cc: Peter Maydell , Leon Alrae , Aurelien Jarno , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [Qemu-devel] [PATCH] dma/rc4030: do multiple calls to address_space_rw when doing DMA transfers 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 This workarounds a bug in memory management. To reproduce the problem, try to start the Windows NT 4.0/MIPS installer. After loading some files, you should see a screen saying "To set up Windows NT now, press ENTER." However, you're welcomed with an IRQL_NOT_LESS_OR_EQUAL bugcheck or an Unknown Hard Error c0000221. Signed-off-by: Hervé Poussineau --- hw/dma/rc4030.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c index 3efa6de..d265d6c 100644 --- a/hw/dma/rc4030.c +++ b/hw/dma/rc4030.c @@ -681,6 +681,7 @@ static void rc4030_do_dma(void *opaque, int n, uint8_t *buf, int len, int is_wri rc4030State *s = opaque; hwaddr dma_addr; int dev_to_mem; + int i; s->dma_regs[n][DMA_REG_ENABLE] &= ~(DMA_FLAG_TC_INTR | DMA_FLAG_MEM_INTR | DMA_FLAG_ADDR_INTR); @@ -699,8 +700,22 @@ static void rc4030_do_dma(void *opaque, int n, uint8_t *buf, int len, int is_wri dma_addr = s->dma_regs[n][DMA_REG_ADDRESS]; /* Read/write data at right place */ +#if 1 /* workaround for a bug in memory management */ + for (i = 0; i < len; ) { + int ncpy = DMA_PAGESIZE - (dma_addr & (DMA_PAGESIZE - 1)); + if (ncpy > len - i) { + ncpy = len - i; + } + address_space_rw(&s->dma_as, dma_addr, MEMTXATTRS_UNSPECIFIED, + buf + i, ncpy, is_write); + + dma_addr += ncpy; + i += ncpy; + } +#else address_space_rw(&s->dma_as, dma_addr, MEMTXATTRS_UNSPECIFIED, buf, len, is_write); +#endif s->dma_regs[n][DMA_REG_ENABLE] |= DMA_FLAG_TC_INTR; s->dma_regs[n][DMA_REG_COUNT] -= len;