From patchwork Sun Oct 16 22:35:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 682749 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 3sxyk94ty5z9s3s for ; Mon, 17 Oct 2016 10:49:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kevin-wolf.de header.i=@kevin-wolf.de header.b=BnUj7bpT; dkim-atps=neutral Received: from localhost ([::1]:58145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvvBa-0001Dv-64 for incoming@patchwork.ozlabs.org; Sun, 16 Oct 2016 19:49:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvu1e-000229-0v for qemu-devel@nongnu.org; Sun, 16 Oct 2016 18:35:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bvu1a-00040X-Uf for qemu-devel@nongnu.org; Sun, 16 Oct 2016 18:35:26 -0400 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::5]:46432) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bvu1a-0003zt-Kp for qemu-devel@nongnu.org; Sun, 16 Oct 2016 18:35:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1476657319; l=2264; s=domk; d=kevin-wolf.de; h=Date:Subject:Cc:To:From; bh=it2szN9zorscMpc+mzi5NnCHl/In9suXY7VvdvjbaxQ=; b=BnUj7bpTRlJXDeC/sxtvKvQXp83ujDz4ED9/YqtLAGZlojrQ9yp30lPFNp3jKEn/joi hjkg48uTCRn+qD8l8l1Jtnpf1J/eS4Ip7COE1f1uzSSaMu343o4oa6def1vdxDiFa2JlU HXUumdz4bqH4Hn3s2+cRiefx3oiblSwFabU= X-RZG-AUTH: :IW0NeWCjfulXIi4BrEKXhgYy2jE0QmIac4DjsXgwMU4hxIZDjW0DYI8H6mBCni0c2A== X-RZG-CLASS-ID: mo00 Received: from silvanus.fritz.box (dslb-188-104-253-155.188.104.pools.vodafone-ip.de [188.104.253.155]) by smtp.strato.de (RZmta 39.5 DYNA|AUTH) with ESMTPSA id 90a89bs9GMZCTz4 (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Mon, 17 Oct 2016 00:35:12 +0200 (CEST) From: Kevin Wolf To: qemu-devel@nongnu.org Date: Mon, 17 Oct 2016 00:35:07 +0200 Message-Id: <1476657307-26165-1-git-send-email-mail@kevin-wolf.de> X-Mailer: git-send-email 2.1.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 2a01:238:20a:202:5300::5 X-Mailman-Approved-At: Sun, 16 Oct 2016 19:48:37 -0400 Subject: [Qemu-devel] [PATCH] e1000e: Don't zero out buffer address in rx descriptor 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: kwolf@redhat.com, dmitry@daynix.com, jasowang@redhat.com, mail@kevin-wolf.de Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The e1000e emulation zeroes out any used rx descriptor and then writes a completely newly constructed value there. By doing this, it doesn't only update the write-back area of the descriptors (as it's supposed to do), but it also clears the buffer address, which real hardware doesn't do. The spec explicitly mentions in chapter 7.1.8 that it is valid for a driver to reuse a descriptor and only update the status field while doing so, i.e. reusing the old buffer address: If software statically allocates buffers, and uses memory read to check for completed descriptors, it simply has to zero the status byte in the descriptor to make it ready for reuse by hardware. This patch fixes the behaviour to leave the buffer address in descriptors unchanged even after the descriptor has been used. Signed-off-by: Kevin Wolf Reviewed-by: Dmitry Fleytman --- hw/net/e1000e_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 9fa4116..a5ca97d 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -1280,11 +1280,10 @@ e1000e_write_lgcy_rx_descr(E1000ECore *core, uint8_t *desc, struct e1000_rx_desc *d = (struct e1000_rx_desc *) desc; - memset(d, 0, sizeof(*d)); - assert(!rss_info->enabled); d->length = cpu_to_le16(length); + d->csum = 0; e1000e_build_rx_metadata(core, pkt, pkt != NULL, rss_info, @@ -1293,6 +1292,7 @@ e1000e_write_lgcy_rx_descr(E1000ECore *core, uint8_t *desc, &d->special); d->errors = (uint8_t) (le32_to_cpu(status_flags) >> 24); d->status = (uint8_t) le32_to_cpu(status_flags); + d->special = 0; } static inline void @@ -1303,7 +1303,7 @@ e1000e_write_ext_rx_descr(E1000ECore *core, uint8_t *desc, { union e1000_rx_desc_extended *d = (union e1000_rx_desc_extended *) desc; - memset(d, 0, sizeof(*d)); + memset(&d->wb, 0, sizeof(d->wb)); d->wb.upper.length = cpu_to_le16(length); @@ -1327,7 +1327,7 @@ e1000e_write_ps_rx_descr(E1000ECore *core, uint8_t *desc, union e1000_rx_desc_packet_split *d = (union e1000_rx_desc_packet_split *) desc; - memset(d, 0, sizeof(*d)); + memset(&d->wb, 0, sizeof(d->wb)); d->wb.middle.length0 = cpu_to_le16((*written)[0]);