From patchwork Fri Nov 13 09:45:22 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: 544133 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 856AD141402 for ; Fri, 13 Nov 2015 20:46:05 +1100 (AEDT) Received: from localhost ([::1]:51930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxAvj-0005Zw-Hf for incoming@patchwork.ozlabs.org; Fri, 13 Nov 2015 04:46:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxAvB-0004y7-Sq for qemu-devel@nongnu.org; Fri, 13 Nov 2015 04:45:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxAv8-0002CY-MR for qemu-devel@nongnu.org; Fri, 13 Nov 2015 04:45:29 -0500 Received: from smtp2-g21.free.fr ([2a01:e0c:1:1599::11]:14765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxAv8-0002CG-6m; Fri, 13 Nov 2015 04:45:26 -0500 Received: from [192.168.0.43] (unknown [82.227.227.196]) by smtp2-g21.free.fr (Postfix) with ESMTP id 9C88E4B00B9; Fri, 13 Nov 2015 10:45:22 +0100 (CET) Message-ID: <5645B132.2070404@reactos.org> Date: Fri, 13 Nov 2015 10:45:22 +0100 From: =?windows-1252?Q?Herv=E9_Poussineau?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Programmingkid , qemu-devel qemu-devel References: <11643EA3-BD07-4DD1-8599-1DD91D1CDE4D@gmail.com> In-Reply-To: <11643EA3-BD07-4DD1-8599-1DD91D1CDE4D@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::11 Cc: "qemu-ppc@nongnu.org list:PowerPC" Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH for-2.5] mac_dbdma: always initialize channel field in DBDMA_channel 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 Le 13/11/2015 05:09, Programmingkid a écrit : > > On Nov 12, 2015, at 11:04 PM, qemu-ppc-request@nongnu.org wrote: > >> Message: 3 >> Date: Thu, 12 Nov 2015 22:24:08 +0100 >> From: Herv? Poussineau >> To: qemu-devel@nongnu.org >> Cc: "open list:Old World" , Herv? Poussineau >> >> Subject: [Qemu-ppc] [PATCH for-2.5] mac_dbdma: always initialize >> channel field in DBDMA_channel >> Message-ID: <1447363448-20405-1-git-send-email-hpoussin@reactos.org> >> Content-Type: text/plain; charset=UTF-8 >> >> dbdma_from_ch() uses channel field to return the right DBDMA object. >> Previous code was working if guest OS was only using registered DMA channels. >> However, it lead to QEMU crashes if guest OS was using unregistered DMA channels. >> >> Signed-off-by: Herv? Poussineau >> --- >> hw/misc/macio/mac_dbdma.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c >> index 779683c..5ee8f02 100644 >> --- a/hw/misc/macio/mac_dbdma.c >> +++ b/hw/misc/macio/mac_dbdma.c >> @@ -557,7 +557,6 @@ void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq, >> DBDMA_DPRINTF("DBDMA_register_channel 0x%x\n", nchan); >> >> ch->irq = irq; >> - ch->channel = nchan; >> ch->rw = rw; >> ch->flush = flush; >> ch->io.opaque = opaque; >> @@ -753,6 +752,7 @@ void* DBDMA_init (MemoryRegion **dbdma_mem) >> for (i = 0; i < DBDMA_CHANNELS; i++) { >> DBDMA_io *io = &s->channels[i].io; >> qemu_iovec_init(&io->iov, 1); >> + s->channels[i].channel = i; >> } >> >> memory_region_init_io(&s->mem, NULL, &dbdma_ops, s, "dbdma", 0x1000); >> -- >> 2.1.4 > > What operating system(s) did you use to test this patch out? > It was during some custom tests with OpenBIOS, where i miswrote the IDE DMA channel. However, you can see the problem by using this "patch": And starting whatever operating system. As soon as DMA is used to read the disk/cdrom, QEMU will crash. Regards, Hervé diff --git a/hw/ide/macio.c b/hw/ide/macio.c index 3ee962f..73dfec0 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -629,7 +629,7 @@ void macio_ide_init_drives(MACIOIDEState *s, DriveInfo **hd_table) void macio_ide_register_dma(MACIOIDEState *s, void *dbdma, int channel) { s->dbdma = dbdma; - DBDMA_register_channel(dbdma, channel, s->dma_irq, + DBDMA_register_channel(dbdma, channel + 1, s->dma_irq, pmac_ide_transfer, pmac_ide_flush, s); }