From patchwork Tue Feb 9 16:37:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 44916 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3B9E8B7CE2 for ; Wed, 10 Feb 2010 03:46:22 +1100 (EST) Received: from localhost ([127.0.0.1]:56741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NetEB-0000Hf-Gw for incoming@patchwork.ozlabs.org; Tue, 09 Feb 2010 11:46:19 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Net5d-0006K3-RD for qemu-devel@nongnu.org; Tue, 09 Feb 2010 11:37:29 -0500 Received: from [199.232.76.173] (port=50207 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Net5c-0006JU-Mk for qemu-devel@nongnu.org; Tue, 09 Feb 2010 11:37:28 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Net5Q-0007Dk-A2 for qemu-devel@nongnu.org; Tue, 09 Feb 2010 11:37:26 -0500 Received: from cantor2.suse.de ([195.135.220.15]:43979 helo=mx2.suse.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Net5N-0007Ca-Vq for qemu-devel@nongnu.org; Tue, 09 Feb 2010 11:37:15 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 311618891E; Tue, 9 Feb 2010 17:37:11 +0100 (CET) From: Alexander Graf To: qemu-devel@nongnu.org Date: Tue, 9 Feb 2010 17:37:07 +0100 Message-Id: <1265733430-9656-8-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1265733430-9656-1-git-send-email-agraf@suse.de> References: <1265733430-9656-1-git-send-email-agraf@suse.de> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: blauwirbel@gmail.com, aurelien@aurel32.net, mst@redhat.com Subject: [Qemu-devel] [PATCH 07/10] PPC: Get rid of segfaults in DBDMA emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org While trying to find the right channel number for the DBDMA emulation I stumbled across segmentation faults that were purely triggered by the guest. The guest should never have the possiblity to segfault us, so let's check all indirect function calls on a channel, so the code even works for channels that have not been reserved. Signed-off-by: Alexander Graf --- hw/mac_dbdma.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c index 8ec3d99..8f94c35 100644 --- a/hw/mac_dbdma.c +++ b/hw/mac_dbdma.c @@ -402,7 +402,9 @@ static void start_output(DBDMA_channel *ch, int key, uint32_t addr, ch->io.dma_end = dbdma_end; ch->io.is_dma_out = 1; ch->processing = 1; - ch->rw(&ch->io); + if (ch->rw) { + ch->rw(&ch->io); + } } static void start_input(DBDMA_channel *ch, int key, uint32_t addr, @@ -425,7 +427,9 @@ static void start_input(DBDMA_channel *ch, int key, uint32_t addr, ch->io.dma_end = dbdma_end; ch->io.is_dma_out = 0; ch->processing = 1; - ch->rw(&ch->io); + if (ch->rw) { + ch->rw(&ch->io); + } } static void load_word(DBDMA_channel *ch, int key, uint32_t addr, @@ -688,7 +692,7 @@ dbdma_control_write(DBDMA_channel *ch) if (status & ACTIVE) qemu_bh_schedule(dbdma_bh); - if (status & FLUSH) + if ((status & FLUSH) && ch->flush) ch->flush(&ch->io); }