Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LeO2U-00051d-T4 for qemu-devel@nongnu.org; Tue, 03 Mar 2009 01:23:39 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LeO2U-000518-4h for qemu-devel@nongnu.org; Tue, 03 Mar 2009 01:23:38 -0500 Received: from [199.232.76.173] (port=33438 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LeO2T-00050y-RQ for qemu-devel@nongnu.org; Tue, 03 Mar 2009 01:23:38 -0500 Received: from hall.aurel32.net ([88.191.82.174]:44138) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LeO2T-0006Jk-Dj for qemu-devel@nongnu.org; Tue, 03 Mar 2009 01:23:37 -0500 Date: Tue, 3 Mar 2009 07:23:31 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH] sh4: r2d fix no ide/net case Message-ID: <20090303062331.GE5159@volta.aurel32.net> References: <200902111545.n1BFjbSp027013@smtp09.dti.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <200902111545.n1BFjbSp027013@smtp09.dti.ne.jp> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Takashi YOSHII Cc: qemu-devel@nongnu.org On Thu, Feb 12, 2009 at 12:45:37AM +0900, takasi-y@ops.dti.ne.jp wrote: > Fix invalid access/crash when there is no IDE device or NET device. > > Signed-off-by: Takashi YOSHII Thanks, applied. > --- > Current code doesn't check if IDE and NIC is present. > When no IDE is enabled, it accesses invalid adddress (drives_table[-1]). > When no NIC is enabled, it accesses NULL pointer and is killed by SEGV. > > SEGV case is easily be seen like below (by -net none) > $ sh4-softmmu/qemu-system-sh4 -M r2d -kernel kernel.kawa -net none > Segmentation fault > > This changes default model of 2nd NIC from ne2k-pci to rtl8139. > 2nd NIC on-board really was rtl8139. > > If you depends on old behavior use -net option, for example > -net nic -net nic,model=ne2k_pci > makes 2nd NIC to be ne2k_pci. > /yoshii > > --- > hw/r2d.c | 10 +++++----- > 1 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/hw/r2d.c b/hw/r2d.c > index 7dcb723..5360b4b 100644 > --- a/hw/r2d.c > +++ b/hw/r2d.c > @@ -224,13 +224,13 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size, > serial_hds[2]); > > /* onboard CF (True IDE mode, Master only). */ > - mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1, > - drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL); > + if ((i = drive_get_index(IF_IDE, 0, 0)) != -1) > + mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1, > + drives_table[i].bdrv, NULL); > > /* NIC: rtl8139 on-board, and 2 slots. */ > - pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139"); > - for (i = 1; i < nb_nics; i++) > - pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci"); > + for (i = 0; i < nb_nics; i++) > + pci_nic_init(pci, &nd_table[i], (i==0)? 2<<3: -1, "rtl8139"); > > /* Todo: register on board registers */ > if (kernel_filename) { > -- > 1.5.6.3 > > > > -- > /yoshii > > > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net