From nobody Sun Feb 8 15:06:55 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1657079396; cv=none; d=zohomail.com; s=zohoarc; b=gPb4Zx6iHvpYTUV1p+qXQQVcQXdJwKDxiGQbWDLbh5zKlFTvyCyZXAO9Vz7/eWhHlILhVK0j+f/su1ZsneFHciqCAUzZEQt4o2kHN0cnE3rboUw0tYaTlnqywVgM46+tn3WwzrZCyMaUmWDcTvLpKFt05FsSmnuTmblDJ2kG1dU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657079396; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y2n2CBcM3fzTKojxV+5JCWF8I/8wnU4OV33bE/oQm54=; b=ByhRbFstfRtRm9vqxMowecHTWNWLKq0SI7UI2NKzELJyD9VTZ/jynbN+KsFrT/WS61R60zzwOiaTSjcCk6FGExACDX/p48UWQ5flvrOPRxGbZ4Je/ut7nXZugn2a+zZK1dImVHcwyj4ufvj+BRFLdDUls9L6IqxlCxqseyB2Dno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657079396820599.7718706261006; Tue, 5 Jul 2022 20:49:56 -0700 (PDT) Received: from localhost ([::1]:56488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8w31-0000Ew-Ns for importer@patchew.org; Tue, 05 Jul 2022 23:49:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8w0a-0007DE-QF for qemu-devel@nongnu.org; Tue, 05 Jul 2022 23:47:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53315) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8w0X-0002d9-TE for qemu-devel@nongnu.org; Tue, 05 Jul 2022 23:47:24 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-567-ItBFd2qHP0yppyYhzMtYHw-1; Tue, 05 Jul 2022 23:47:17 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46C8F1C051A7; Wed, 6 Jul 2022 03:47:17 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-233.pek2.redhat.com [10.72.12.233]) by smtp.corp.redhat.com (Postfix) with ESMTP id C752A140EBE4; Wed, 6 Jul 2022 03:47:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657079240; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y2n2CBcM3fzTKojxV+5JCWF8I/8wnU4OV33bE/oQm54=; b=b+0kRUV2cQBWbH1KZEoWUVIfq4Lx59Ah5g3HRmFgbX1BFvDISrd86CasgK5/HzwK2bP/30 htAnvZVioazNmc9JhagY1Pb/9C8Lz5SSvBqFC9ptICf60TgKwRo2BR8vnvzs3wSSUn5xJn ZASMUm9RXMq9Z6H3l9WvdjndYPlRlT8= X-MC-Unique: ItBFd2qHP0yppyYhzMtYHw-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Ding Hui , Leonid Myravjev , Stefan Hajnoczi , Paolo Bonzini , "Michael S . Tsirkin" , qemu-stable@nongnu.org, Jing Zhang , Frank Lee , Jason Wang Subject: [PULL 1/2] e1000: set RX descriptor status in a separate operation Date: Wed, 6 Jul 2022 11:47:05 +0800 Message-Id: <20220706034706.36620-2-jasowang@redhat.com> In-Reply-To: <20220706034706.36620-1-jasowang@redhat.com> References: <20220706034706.36620-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1657079399051100003 Content-Type: text/plain; charset="utf-8" From: Ding Hui The code of setting RX descriptor status field maybe work fine in previously, however with the update of glibc version, it shows two issues when guest using dpdk receive packets: 1. The dpdk has a certain probability getting wrong buffer_addr this impact may be not obvious, such as lost a packet once in a while 2. The dpdk may consume a packet twice when scan the RX desc queue over again this impact will lead a infinite wait in Qemu, since the RDT (tail pointer) be inscreased to equal to RDH by unexpected, which regard as the RX desc queue is full Write a whole of RX desc with DD flag on is not quite correct, because when the underlying implementation of memcpy using XMM registers to copy e1000_rx_desc (when AVX or something else CPU feature is usable), the bytes order of desc writing to memory is indeterminacy We can use full-scale test case to reproduce the issue-2 by https://github.com/BASM/qemu_dpdk_e1000_test (thanks to Leonid Myravjev) I also write a POC test case at https://github.com/cdkey/e1000_poc which can reproduce both of them, and easy to verify the patch effect. The hw watchpoint also shows that, when Qemu using XMM related instructions writing 16 bytes e1000_rx_desc, concurrent with DPDK using movb writing 1 byte status, the final result of writing to memory will be one of them, if it made by Qemu which DD flag is on, DPDK will consume it again. Setting DD status in a separate operation, can prevent the impact of disorder memory writing by memcpy, also avoid unexpected data when concurrent writing status by qemu and guest dpdk. Links: https://lore.kernel.org/qemu-devel/20200102110504.GG121208@stefanha-= x1.localdomain/T/ Reported-by: Leonid Myravjev Cc: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Michael S. Tsirkin Cc: qemu-stable@nongnu.org Tested-by: Jing Zhang Reviewed-by: Frank Lee Signed-off-by: Ding Hui Signed-off-by: Jason Wang --- hw/net/e1000.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index f5bc812..e26e0a6 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -979,7 +979,7 @@ e1000_receive_iov(NetClientState *nc, const struct iove= c *iov, int iovcnt) base =3D rx_desc_base(s) + sizeof(desc) * s->mac_reg[RDH]; pci_dma_read(d, base, &desc, sizeof(desc)); desc.special =3D vlan_special; - desc.status |=3D (vlan_status | E1000_RXD_STAT_DD); + desc.status &=3D ~E1000_RXD_STAT_DD; if (desc.buffer_addr) { if (desc_offset < size) { size_t iov_copy; @@ -1013,6 +1013,9 @@ e1000_receive_iov(NetClientState *nc, const struct io= vec *iov, int iovcnt) DBGOUT(RX, "Null RX descriptor!!\n"); } pci_dma_write(d, base, &desc, sizeof(desc)); + desc.status |=3D (vlan_status | E1000_RXD_STAT_DD); + pci_dma_write(d, base + offsetof(struct e1000_rx_desc, status), + &desc.status, sizeof(desc.status)); =20 if (++s->mac_reg[RDH] * sizeof(desc) >=3D s->mac_reg[RDLEN]) s->mac_reg[RDH] =3D 0; --=20 2.7.4 From nobody Sun Feb 8 15:06:55 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1657079521; cv=none; d=zohomail.com; s=zohoarc; b=DBCuotReWDhOda4WlDodEArruNDKuZ/wkaq+CuUOm+KWfSvtQ8i8brgpGf1Rnr3O7xLqCzHltQH/hpI1R8tSIuvv+VK4eOoqtTqNts7UYinUEpDmwrmnKHVwq0mLOcmk47YpNeNsp0/XP7kn3y+xtVPWRAEftlaLkvwaiHD44W4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657079521; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fftXIwR07UHjXrAaMyTCQ2mMhpdTiRDERprdXGWGFfc=; b=RnDwwDlD4LKajIhit2R4S4AUfsY1AHx0GW0ly1BFZKiO5dhVfp9fjfpWYOEPzJF6aC/9pfP+p3oasZULIhB1o9LddD7X5XYf/pZ/Ja8UVNuZ2sGF8to08jdWpsmmKwe6QbohHVf84TdBCnEhFlKrTzFJbGjzJhUgJyHbM/7whos= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165707952134368.70531146212602; Tue, 5 Jul 2022 20:52:01 -0700 (PDT) Received: from localhost ([::1]:60664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8w51-0003fQ-Im for importer@patchew.org; Tue, 05 Jul 2022 23:51:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8w0c-0007Eg-6p for qemu-devel@nongnu.org; Tue, 05 Jul 2022 23:47:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8w0a-0002dO-NK for qemu-devel@nongnu.org; Tue, 05 Jul 2022 23:47:25 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-394-ag7L0m1LMzeel-Uw1HTglA-1; Tue, 05 Jul 2022 23:47:20 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 487983C02198; Wed, 6 Jul 2022 03:47:20 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-233.pek2.redhat.com [10.72.12.233]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFEB91415108; Wed, 6 Jul 2022 03:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657079244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fftXIwR07UHjXrAaMyTCQ2mMhpdTiRDERprdXGWGFfc=; b=cA3NLbMZFepjQCurbH0Hdg6fNVINLsdwXZPEJ59CKmXHy33fRal2V+MoMfiwe0ixvRker0 31EoE72izWIhJ4CCQULHA89gDl6ZnfIfyrnLPBuPKGtTeMzp5UaUqL82e+SDzRZHZL9Do0 nDbeQ5BZG1LrWkL0GTwFShCc15dJYJk= X-MC-Unique: ag7L0m1LMzeel-Uw1HTglA-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Haochen Tong , Zhang Chen , Jason Wang Subject: [PULL 2/2] ebpf: replace deprecated bpf_program__set_socket_filter Date: Wed, 6 Jul 2022 11:47:06 +0800 Message-Id: <20220706034706.36620-3-jasowang@redhat.com> In-Reply-To: <20220706034706.36620-1-jasowang@redhat.com> References: <20220706034706.36620-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1657079523366100001 Content-Type: text/plain; charset="utf-8" From: Haochen Tong bpf_program__set_ functions have been deprecated since libbpf 0.8. Replace with the equivalent bpf_program__set_type call to avoid a deprecation warning. Signed-off-by: Haochen Tong Reviewed-by: Zhang Chen Signed-off-by: Jason Wang --- ebpf/ebpf_rss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c index 118c68d..cee658c 100644 --- a/ebpf/ebpf_rss.c +++ b/ebpf/ebpf_rss.c @@ -49,7 +49,7 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx) goto error; } =20 - bpf_program__set_socket_filter(rss_bpf_ctx->progs.tun_rss_steering_pro= g); + bpf_program__set_type(rss_bpf_ctx->progs.tun_rss_steering_prog, BPF_PR= OG_TYPE_SOCKET_FILTER); =20 if (rss_bpf__load(rss_bpf_ctx)) { trace_ebpf_error("eBPF RSS", "can not load RSS program"); --=20 2.7.4