From nobody Fri Apr 26 20:20:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486693254954422.10175814124943; Thu, 9 Feb 2017 18:20:54 -0800 (PST) Received: from localhost ([::1]:41309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc0pR-0004kg-Mz for importer@patchew.org; Thu, 09 Feb 2017 21:20:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cc0oA-00046M-Ou for qemu-devel@nongnu.org; Thu, 09 Feb 2017 21:19:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cc0o7-0001FB-LC for qemu-devel@nongnu.org; Thu, 09 Feb 2017 21:19:34 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:36715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cc0o7-0001F3-DX for qemu-devel@nongnu.org; Thu, 09 Feb 2017 21:19:31 -0500 Received: by mail-wr0-x241.google.com with SMTP id k90so13672784wrc.3 for ; Thu, 09 Feb 2017 18:19:31 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id i29sm287970wrc.25.2017.02.09.18.19.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 18:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=7YFdiWLEebphuKWMoaES0BmalxU77Sr+bWTrPPuoUjQ=; b=KlYC4Pr8otAZrpKZN6yRiRpZ2Al4mIFEEEZ5tl1rfNnLrUEGscVrc8thJ20GGo/GxS DWxKcyOjwtQ2yRMIu1kigi3HYAelxh92N4OltEI3u7qX1PynZywQ2DSM00wmnU73j3OI p0C5qXIAs3v4+9e1IfoszwJ+lZYL7vSEoR3ROA7dBQ851SNMhA7eygSQSFpmLXsKTBuB rBMum0CEPLO+rREzD/Zfb17hGRQTbi1h6UNVyUimghE87QUhzFD247jTTdGixCwdzGcE ofuBCUOD7vVEzCtiPS2Lafw7CsK4y+ZEMwBuPeLESH2RWIeQHJIwz3vg2XkaEIVZMN7J xiIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7YFdiWLEebphuKWMoaES0BmalxU77Sr+bWTrPPuoUjQ=; b=AF03ZNsLgaUFliWHFTkSfUVr2WJ9y9I+JQwxldltIhvJEI2+SpaxBXKCEQ1NTmLsmI TGVCF8I772iGs4yCAutFgX5QU1kQx4C05l/l0aoXB4URNhCKuFTwSa6HSKyNqnXhWhdG rVmG1AA23uxvkQpPcSpmUKFMe0xwP+jULAcS49AF4At3dlE+bPm0VUFgzW8iKCloWMaQ HYvrYh+jgJPYoE/2aAIGGcswinv8g9FHQhxBMuwO8Otiyu4sZ8cdOvPGAwrg6gTjxDWn mL/v1rYNExfA7CwpBZPzBOsRBc5s4mrXMR/jEFCzvFKyDs6wJyic5iRG1bSI0ijXi6wc H3tA== X-Gm-Message-State: AMke39nPPsETad0Basm05jjHXdvE2P3n7HPf48ChPjkq1N58wMk2xseQiYX2ZsxV22CaQw== X-Received: by 10.223.163.75 with SMTP id d11mr5317554wrb.87.1486693170233; Thu, 09 Feb 2017 18:19:30 -0800 (PST) From: Li Qiang X-Google-Original-From: Li Qiang To: dmitry@daynix.com, jasowang@redhat.com, qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 18:19:19 -0800 Message-Id: <1486693159-29029-1-git-send-email-liqiang6-s@360.cn> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH v3] net: e1000e: fix an infinite loop issue 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: Li Qiang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This issue is like the issue in e1000 network card addressed in this commit: e1000: eliminate infinite loops on out-of-bounds transfer start. Signed-off-by: Li Qiang Reviewed-by: Dmitry Fleytman --- Change since v2: fix error in e1000e_ring_empty eliminate unnecessory detect code in loop Changes since v1: make wraparound detect in e1000e_ring_empty hw/net/e1000e_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 2b11499..dc94188 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -806,7 +806,8 @@ typedef struct E1000E_RingInfo_st { static inline bool e1000e_ring_empty(E1000ECore *core, const E1000E_RingInfo *r) { - return core->mac[r->dh] =3D=3D core->mac[r->dt]; + return core->mac[r->dh] =3D=3D core->mac[r->dt] || + core->mac[r->dt] >=3D core->mac[r->dlen] / E1000_RING_DESC= _LEN; } =20 static inline uint64_t @@ -1522,6 +1523,10 @@ e1000e_write_packet_to_guest(E1000ECore *core, struc= t NetRxPkt *pkt, desc_size =3D core->rx_desc_buf_size; } =20 + if (e1000e_ring_empty(core, rxi)) { + return; + } + base =3D e1000e_ring_head_descr(core, rxi); =20 pci_dma_read(d, base, &desc, core->rx_desc_len); --=20 1.8.3.1