From nobody Tue Feb 10 12:58:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1561916328; cv=none; d=zoho.com; s=zohoarc; b=glnzR+zeQ2q2usfpbbsRe9YNDWzUsfJOjIp9bbzVL4G8jGLNd1xi8T6qu2IxBAQuxdKEDV4X9wxhWWrBvXOgiwd8b8zPbXeYsPoAW/VSsVRM7PdHqv93iC0PG/OrV0asKdW2hOgovxogTbouLDnhwH+BpPLdCYF/cp7xyIWcD/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561916328; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4fyFDv5VRcPTs6q1urf6RW0+fGjmYK9lGMRH/ZmzdGY=; b=VOiL3tkdZFPM0krfUG/eLvbvnZ9bKb91VX2ui6YGDQXsmzZW1kSFtiaaLex2+qdm4mdXahNM9SKuTT9k8KloGUgI+oAs+pI/j4XVVcESQQIU64lySfMDjFS6WZlM1HdZaeKnhBeBT+UpcGJ+AZB8AHA8nCmVUj52/q5zZcyNRlI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561916328444238.05205719751314; Sun, 30 Jun 2019 10:38:48 -0700 (PDT) Received: from localhost ([::1]:45820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhdmn-0004PX-7u for importer@patchew.org; Sun, 30 Jun 2019 13:38:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58363) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhdjZ-0000Sg-Ht for qemu-devel@nongnu.org; Sun, 30 Jun 2019 13:35:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hhdjY-0000ZV-CS for qemu-devel@nongnu.org; Sun, 30 Jun 2019 13:35:25 -0400 Received: from mail.ilande.co.uk ([46.43.2.167]:40196 helo=mail.default.ilande.uk0.bigv.io) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hhdjY-00080J-2g for qemu-devel@nongnu.org; Sun, 30 Jun 2019 13:35:24 -0400 Received: from host109-146-132-17.range109-146.btcentralplus.com ([109.146.132.17] helo=kentang.home) by mail.default.ilande.uk0.bigv.io with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hhdfs-0001xd-D0 for qemu-devel@nongnu.org; Sun, 30 Jun 2019 18:31:36 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org Date: Sun, 30 Jun 2019 18:32:03 +0100 Message-Id: <20190630173203.9620-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190630173203.9620-1-mark.cave-ayland@ilande.co.uk> References: <20190630173203.9620-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.146.132.17 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.uk0.bigv.io) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.43.2.167 Subject: [Qemu-devel] [PATCH 5/5] sunhme: ensure that RX descriptor ring overflow is indicated to client driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" On very busy networks connected via a tap interface, it is possible to over= flow the RX descriptor ring in the time between the client driver enabling the RX MAC and finishing writing the final configuration to the NIC registers. Ensure that we detect this condition and update the status register accordi= ngly to indicate an overflow has occurred (and the incoming packet dropped) in o= rder to prevent the client driver becoming confused. Signed-off-by: Mark Cave-Ayland --- hw/net/sunhme.c | 9 +++++++++ hw/net/trace-events | 1 + 2 files changed, 10 insertions(+) diff --git a/hw/net/sunhme.c b/hw/net/sunhme.c index cd076d642b..8b8603e696 100644 --- a/hw/net/sunhme.c +++ b/hw/net/sunhme.c @@ -44,6 +44,7 @@ #define HME_SEBI_STAT 0x100 #define HME_SEBI_STAT_LINUXBUG 0x108 #define HME_SEB_STAT_RXTOHOST 0x10000 +#define HME_SEB_STAT_NORXD 0x20000 #define HME_SEB_STAT_MIFIRQ 0x800000 #define HME_SEB_STAT_HOSTTOTX 0x1000000 #define HME_SEB_STAT_TXALL 0x2000000 @@ -787,6 +788,14 @@ static ssize_t sunhme_receive(NetClientState *nc, cons= t uint8_t *buf, pci_dma_read(d, rb + cr * HME_DESC_SIZE, &status, 4); pci_dma_read(d, rb + cr * HME_DESC_SIZE + 4, &buffer, 4); =20 + /* If we don't own the current descriptor then indicate overflow error= */ + if (!(status & HME_XD_OWN)) { + s->sebregs[HME_SEBI_STAT >> 2] |=3D HME_SEB_STAT_NORXD; + sunhme_update_irq(s); + trace_sunhme_rx_norxd(); + return -1; + } + rxoffset =3D (s->erxregs[HME_ERXI_CFG >> 2] & HME_ERX_CFG_BYTEOFFSET) = >> HME_ERX_CFG_BYTEOFFSET_SHIFT; =20 diff --git a/hw/net/trace-events b/hw/net/trace-events index d16273c579..58665655cc 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -359,6 +359,7 @@ sunhme_rx_filter_reject(void) "rejecting incoming frame" sunhme_rx_filter_accept(void) "accepting incoming frame" sunhme_rx_desc(uint32_t addr, int offset, uint32_t status, int len, int cr= , int nr) "addr 0x%"PRIx32"(+0x%x) status 0x%"PRIx32 " len %d (ring %d/%d)" sunhme_rx_xsum_calc(uint16_t xsum) "calculated incoming xsum as 0x%x" +sunhme_rx_norxd(void) "no free rx descriptors available" sunhme_update_irq(uint32_t mifmask, uint32_t mif, uint32_t sebmask, uint32= _t seb, int level) "mifmask: 0x%x mif: 0x%x sebmask: 0x%x seb: 0x%x lev= el: %d" =20 # virtio-net.c --=20 2.11.0