From patchwork Sat Jun 9 08:47:39 2018 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: 10455469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 836AC60234 for ; Sat, 9 Jun 2018 08:50:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75C022018E for ; Sat, 9 Jun 2018 08:50:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 693C7201A4; Sat, 9 Jun 2018 08:50:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1B5A92018F for ; Sat, 9 Jun 2018 08:50:09 +0000 (UTC) Received: from localhost ([::1]:39466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRZZW-0005Pf-Qr for patchwork-qemu-devel@patchwork.kernel.org; Sat, 09 Jun 2018 04:50:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRZXZ-0004Ya-SN for qemu-devel@nongnu.org; Sat, 09 Jun 2018 04:48:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRZXY-0003q8-Tv for qemu-devel@nongnu.org; Sat, 09 Jun 2018 04:48:05 -0400 Received: from iserv.reactos.org ([2a01:4f8:221:4c5::3]:36027) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fRZXT-0003c1-Lg; Sat, 09 Jun 2018 04:48:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=reactos.org ; s=25047; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version: Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=fFAgtUOs2myN+c6bMNOl4Iu7yG9boxVO1LyzGzbMxwg=; b=fQrgP6J9l75Uy5B9rJtXwkG8WK WqxUPfaf9tE1S4tbbKQxp/slQqsfN5eZZvONqZFEgQ42SrdlKCy3cZRpvs2bns6+0xfvx1/iuynv3 /sCCvKtH/J09hg9ScfYqimNS3U728b7XpyTQqsXgSVix0kYhVefK6Juwpf2WhMkRVrpA=; Received: from rob92-5-82-227-227-196.fbx.proxad.net ([82.227.227.196] helo=[192.168.0.35]) by iserv.reactos.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1fRZXE-0008M9-Pt; Sat, 09 Jun 2018 08:47:45 +0000 To: Laurent Vivier , qemu-devel@nongnu.org References: <20180608200558.386-1-laurent@vivier.eu> <20180608200558.386-11-laurent@vivier.eu> From: =?UTF-8?Q?Herv=c3=a9_Poussineau?= Message-ID: <3d55a7ff-93b1-06d6-252a-0df31aa8d084@reactos.org> Date: Sat, 9 Jun 2018 10:47:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180608200558.386-11-laurent@vivier.eu> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:4f8:221:4c5::3 Subject: Re: [Qemu-devel] [RFC 10/13] dp8393x: fix dp8393x_receive X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" , Max Reitz , Gerd Hoffmann , Paolo Bonzini , Yongbok Kim , =?UTF-8?Q?Andreas_F=c3=a4rber?= , Aurelien Jarno Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Le 08/06/2018 à 22:05, Laurent Vivier a écrit : > address_space_rw() access size must be multiplied by width. > dp8393x_receive() must return the number of bytes read, not the length > of the last memory access. > > Signed-off-by: Laurent Vivier > --- > hw/net/dp8393x.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c > index f2d2ce344c..ef5f1eb94f 100644 > --- a/hw/net/dp8393x.c > +++ b/hw/net/dp8393x.c > @@ -808,9 +808,11 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, > /* EOL detected */ > s->regs[SONIC_ISR] |= SONIC_ISR_RDE; > } else { > + size = sizeof(uint16_t) * width; > data[0 * width] = 0; /* in_use */ > - address_space_rw(&s->as, dp8393x_crda(s) + sizeof(uint16_t) * 6 * width, > - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, sizeof(uint16_t), 1); > + address_space_rw(&s->as, > + dp8393x_crda(s) + sizeof(uint16_t) * 6 * width, > + MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size, 1); > s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA]; > s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX; > s->regs[SONIC_RSC] = (s->regs[SONIC_RSC] & 0xff00) | (((s->regs[SONIC_RSC] & 0x00ff) + 1) & 0x00ff); > @@ -824,7 +826,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, > /* Done */ > dp8393x_update_irq(s); > > - return size; > + return rx_len; > } > > static void dp8393x_reset(DeviceState *dev) > NACK. This breaks NetBSD 5.1/arc networking. This seems to revert the following commit and change the function return value. commit 409b52bfe199d8106dadf7c5ff3d88d2228e89b5 Author: Hervé Poussineau Date: Wed Jun 3 22:45:48 2015 +0200 net/dp8393x: correctly reset in_use field Don't write more than the field width, which is always 16 bit. Fixes network in NetBSD 5.1/arc Signed-off-by: Hervé Poussineau Reviewed-by: Aurelien Jarno Signed-off-by: Leon Alrae diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 4184045145..ff633f76a0 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -764,7 +764,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, data[0 * width] = 0; /* in_use */ address_space_rw(&s->as, ((s->regs[SONIC_URDA] << 16) | s->regs[SONIC_CRDA]) + sizeof(uint16_t) * 6 * width, - MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size, 1); + MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, sizeof(uint16_t), 1); s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA]; s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX; s->regs[SONIC_RSC] = (s->regs[SONIC_RSC] & 0xff00) | (((s->regs[SONIC_RSC] & 0x00ff) + 1) & 0x00ff);