From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:37706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RMbh8-0005aa-GH for qemu-devel@nongnu.org; Sat, 05 Nov 2011 04:33:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RMbh7-0003c2-78 for qemu-devel@nongnu.org; Sat, 05 Nov 2011 04:33:42 -0400 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:37456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RMbh7-0003aM-2X for qemu-devel@nongnu.org; Sat, 05 Nov 2011 04:33:41 -0400 Message-ID: <4EB4F4AA.8060404@weilnetz.de> Date: Sat, 05 Nov 2011 09:32:42 +0100 From: Stefan Weil MIME-Version: 1.0 References: <1320041218-30487-1-git-send-email-david@gibson.dropbear.id.au> <1320041218-30487-6-git-send-email-david@gibson.dropbear.id.au> <20111102071634.GA5613@redhat.com> <20111103051634.GQ5379@truffala.fritz.box> <20111103122544.GH18296@redhat.com> In-Reply-To: <20111103122544.GH18296@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 05/14] eepro100: Use PCI DMA stub functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: QEMU Developers , David Gibson On Wed, Nov 02, 2011 at 09:16:34AM +0200, Michael S. Tsirkin wrote: > On Mon, Oct 31, 2011 at 05:06:49PM +1100, David Gibson wrote: >> From: Eduard - Gabriel Munteanu [snip] >> @@ -744,21 +713,26 @@ static void dump_statistics(EEPRO100State * s) >> * values which really matter. >> * Number of data should check configuration!!! >> */ >> - cpu_physical_memory_write(s->statsaddr, &s->statistics, s->stats_size); >> - e100_stl_le_phys(s->statsaddr + 0, s->statistics.tx_good_frames); >> - e100_stl_le_phys(s->statsaddr + 36, s->statistics.rx_good_frames); >> - e100_stl_le_phys(s->statsaddr + 48, s->statistics.rx_resource_errors); >> - e100_stl_le_phys(s->statsaddr + 60, >> s->statistics.rx_short_frame_errors); >> + pci_dma_write(&s->dev, s->statsaddr, >> + (uint8_t *) &s->statistics, s->stats_size); >> + stl_le_pci_dma(&s->dev, s->statsaddr + 0, >> + s->statistics.tx_good_frames); >> + stl_le_pci_dma(&s->dev, s->statsaddr + 36, >> + s->statistics.rx_good_frames); >> + stl_le_pci_dma(&s->dev, s->statsaddr + 48, >> + s->statistics.rx_resource_errors); >> + stl_le_pci_dma(&s->dev, s->statsaddr + 60, >> + s->statistics.rx_short_frame_errors); > > This might introduce a bug: stlXX APIs assume aligned addresses, > an address in statsaddr is user-controlled so I'm not sure > it's always aligned. > > Why isn't the patch simply replacing cpu_physical_memory_read > with pci_XXX ? Any cleanups should be done separately. Hello, I just sent a patch for eepro100.c which enforces aligned addresses for s->statsaddr, so most of David's changes are now safe. Please include the patch in QEMU 1.0. Thanks, Stefan Weil