From nobody Thu Dec 18 19:28:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644811634332487.21561899646497; Sun, 13 Feb 2022 20:07:14 -0800 (PST) Received: from localhost ([::1]:41700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJSdu-00085r-Bm for importer@patchew.org; Sun, 13 Feb 2022 23:07:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXV-000648-Cj for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:20625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXS-00007z-2v for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-183-3bB517YPOgaj972VRHvBEw-1; Sun, 13 Feb 2022 23:00:32 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA045802924; Mon, 14 Feb 2022 04:00:30 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-241.pek2.redhat.com [10.72.13.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45B4A610A6; Mon, 14 Feb 2022 04:00:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644811233; 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=s7NMRE3w8ty9ut2y4SuafqvYGwlifTworSCgY/qoCsQ=; b=LTvEbjnnCmYQOlIfqZZT4QrIfco5YOaMKQ0uDlyr0J6VFFbBiTUVAERy9mLvmSc5xXRTUA mTMqV/mDgxD4KKsqroxg3zs3lcG5wKrcKlX4ZjWbs1HOuYJ5AWwHhHMssHRJ1I+QXK3Sij 8/jI3ihOorwY1az9WOWlg8BpKRMDOpE= X-MC-Unique: 3bB517YPOgaj972VRHvBEw-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 1/8] hw/net/vmxnet3: Log guest-triggerable errors using LOG_GUEST_ERROR Date: Mon, 14 Feb 2022 11:59:50 +0800 Message-Id: <20220214035957.71339-2-jasowang@redhat.com> In-Reply-To: <20220214035957.71339-1-jasowang@redhat.com> References: <20220214035957.71339-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=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: , Cc: Dike , Jason Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Duhao <504224090@qq.com> Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644811635829100003 From: Philippe Mathieu-Daud=C3=A9 The "Interrupt Cause" register (VMXNET3_REG_ICR) is read-only. Write accesses are ignored. Log them with as LOG_GUEST_ERROR instead of aborting: [R +0.239743] writeq 0xe0002031 0x46291a5a55460800 ERROR:hw/net/vmxnet3.c:1819:vmxnet3_io_bar1_write: code should not be rea= ched Thread 1 "qemu-system-i38" received signal SIGABRT, Aborted. (gdb) bt #3 0x74c397d3 in __GI_abort () at abort.c:79 #4 0x76d3cd4c in g_assertion_message (domain=3D, file=3D<= optimized out>, line=3D, func=3D, message=3D<= optimized out>) at ../glib/gtestutils.c:3223 #5 0x76d9d45f in g_assertion_message_expr (domain=3D0x0, file=3D0x59fc2e53 "hw/net/vmxnet3.c", line=3D1819, fun= c=3D0x59fc11e0 <__func__.vmxnet3_io_bar1_write> "vmxnet3_io_bar1_write", ex= pr=3D) at ../glib/gtestutils.c:3249 #6 0x57e80a3a in vmxnet3_io_bar1_write (opaque=3D0x62814100, addr=3D56, = val=3D70, size=3D4) at hw/net/vmxnet3.c:1819 #7 0x58c2d894 in memory_region_write_accessor (mr=3D0x62816b90, addr=3D5= 6, value=3D0x7fff9450, size=3D4, shift=3D0, mask=3D4294967295, attrs=3D...)= at softmmu/memory.c:492 #8 0x58c2d1d2 in access_with_adjusted_size (addr=3D56, value=3D0x7fff945= 0, size=3D1, access_size_min=3D4, access_size_max=3D4, access_fn=3D 0x58c2d290 , mr=3D0x62816b90, attrs=3D.= ..) at softmmu/memory.c:554 #9 0x58c2bae7 in memory_region_dispatch_write (mr=3D0x62816b90, addr=3D5= 6, data=3D70, op=3DMO_8, attrs=3D...) at softmmu/memory.c:1504 #10 0x58bfd034 in flatview_write_continue (fv=3D0x606000181700, addr=3D0x= e0002038, attrs=3D..., ptr=3D0x7fffb9e0, len=3D1, addr1=3D56, l=3D1, mr=3D0= x62816b90) at softmmu/physmem.c:2782 #11 0x58beba00 in flatview_write (fv=3D0x606000181700, addr=3D0xe0002031,= attrs=3D..., buf=3D0x7fffb9e0, len=3D8) at softmmu/physmem.c:2822 #12 0x58beb589 in address_space_write (as=3D0x608000015f20, addr=3D0xe000= 2031, attrs=3D..., buf=3D0x7fffb9e0, len=3D8) at softmmu/physmem.c:2914 Reported-by: Dike Reported-by: Duhao <504224090@qq.com> BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=3D2032932 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- hw/net/vmxnet3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index f65af4e..0b7acf7 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1816,7 +1816,9 @@ vmxnet3_io_bar1_write(void *opaque, case VMXNET3_REG_ICR: VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] =3D %" PRIx64 ", size %d", val, size); - g_assert_not_reached(); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: write to read-only register VMXNET3_REG_ICR\n", + TYPE_VMXNET3); break; =20 /* Event Cause Register */ --=20 2.7.4 From nobody Thu Dec 18 19:28:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644811844270855.9212370906907; Sun, 13 Feb 2022 20:10:44 -0800 (PST) Received: from localhost ([::1]:49018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJShH-0004by-3P for importer@patchew.org; Sun, 13 Feb 2022 23:10:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXW-00066s-KK for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42082) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXU-00009C-Lr for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-609-QukqooaGN9mr_GDCSqJOgQ-1; Sun, 13 Feb 2022 23:00:35 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD53480573C; Mon, 14 Feb 2022 04:00:33 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-241.pek2.redhat.com [10.72.13.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 708FF610A6; Mon, 14 Feb 2022 04:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644811236; 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=L7aFwPgUMiLWMwFCD1YpzYkJRLrfE9A03ldYN2xCSj4=; b=hzKpXRnSuSfGtQZGDSAUcZdo2vsvo5yh36QehT9RI9gmS7YAIOQzd3YeB5JMe0OzlpnIvb QVxCAiZhXHVNzpbUcq44CdWS2SceUrucZFnmTzBA+8Cc1JCqCtoewX/7QCiADR6hfOrr+o 6s3ojqDqsrE8IgbybCeKt2mddVSPgd4= X-MC-Unique: QukqooaGN9mr_GDCSqJOgQ-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 2/8] net/tap: Set return code on failure Date: Mon, 14 Feb 2022 11:59:51 +0800 Message-Id: <20220214035957.71339-3-jasowang@redhat.com> In-Reply-To: <20220214035957.71339-1-jasowang@redhat.com> References: <20220214035957.71339-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=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: , Cc: Patrick Venture , Jason Wang , Peter Foley , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644811845278100001 From: Peter Foley Match the other error handling in this function. Fixes: e7b347d0bf6 ("net: detect errors from probing vnet hdr flag for TAP = devices") Reviewed-by: Patrick Venture Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Foley Signed-off-by: Jason Wang --- net/tap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/tap.c b/net/tap.c index f716be3..c5cbeaa 100644 --- a/net/tap.c +++ b/net/tap.c @@ -900,6 +900,7 @@ int net_init_tap(const Netdev *netdev, const char *name, if (i =3D=3D 0) { vnet_hdr =3D tap_probe_vnet_hdr(fd, errp); if (vnet_hdr < 0) { + ret =3D -1; goto free_fail; } } else if (vnet_hdr !=3D tap_probe_vnet_hdr(fd, NULL)) { --=20 2.7.4 From nobody Thu Dec 18 19:28:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644811954174199.5519259297247; Sun, 13 Feb 2022 20:12:34 -0800 (PST) Received: from localhost ([::1]:55082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJSj3-0000Gf-5R for importer@patchew.org; Sun, 13 Feb 2022 23:12:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXd-0006PJ-Bb for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXZ-00009t-SS for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:44 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-583-GwMfxJBUMGe1EmT8fy5Ivw-1; Sun, 13 Feb 2022 23:00:38 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E63512F26; Mon, 14 Feb 2022 04:00:36 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-241.pek2.redhat.com [10.72.13.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58C83610A6; Mon, 14 Feb 2022 04:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644811241; 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=X5GAbeGove+Hlvc9LCxnF1xG66xcz91B8MxnptOPyYY=; b=IGBADzxFjg6GP2a2mdA85ViUjTGiLbCA5xCLsWgWQ/sxxRKydsJiSN9NGmlZy7J/GshHgx Gr5CQOlTa+a7WmwZhVRU0NBZ/SRkadX4xQb7jFramzsZ+V8FoCWkf3UhhgwPriXC60NwY0 3orUS+wVR7UhkJNIauR2Z/BsaIY7/RI= X-MC-Unique: GwMfxJBUMGe1EmT8fy5Ivw-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 3/8] net: Fix uninitialized data usage Date: Mon, 14 Feb 2022 11:59:52 +0800 Message-Id: <20220214035957.71339-4-jasowang@redhat.com> In-Reply-To: <20220214035957.71339-1-jasowang@redhat.com> References: <20220214035957.71339-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=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: , Cc: Patrick Venture , Jason Wang , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Hao Wu , Peter Foley Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644811956085100003 From: Peter Foley e.g. 1109 15:16:20.151506 Uninitialized bytes in ioctl_common_pre at offset 0 in= side [0x7ffc516af9b8, 4) 1109 15:16:20.151659 =3D=3D588974=3D=3DWARNING: MemorySanitizer: use-of-un= initialized-value 1109 15:16:20.312923 #0 0x5639b88acb21 in tap_probe_vnet_hdr_len third= _party/qemu/net/tap-linux.c:183:9 1109 15:16:20.312952 #1 0x5639b88afd66 in net_tap_fd_init third_party/= qemu/net/tap.c:409:9 1109 15:16:20.312954 #2 0x5639b88b2d1b in net_init_tap_one third_party= /qemu/net/tap.c:681:19 1109 15:16:20.312956 #3 0x5639b88b16a8 in net_init_tap third_party/qem= u/net/tap.c:912:13 1109 15:16:20.312957 #4 0x5639b8890175 in net_client_init1 third_party= /qemu/net/net.c:1110:9 1109 15:16:20.312958 #5 0x5639b888f912 in net_client_init third_party/= qemu/net/net.c:1208:15 1109 15:16:20.312960 #6 0x5639b8894aa5 in net_param_nic third_party/qe= mu/net/net.c:1588:11 1109 15:16:20.312961 #7 0x5639b900cd18 in qemu_opts_foreach third_part= y/qemu/util/qemu-option.c:1135:14 1109 15:16:20.312962 #8 0x5639b889393c in net_init_clients third_party= /qemu/net/net.c:1612:9 1109 15:16:20.312964 #9 0x5639b717aaf3 in qemu_create_late_backends th= ird_party/qemu/softmmu/vl.c:1962:5 1109 15:16:20.312965 #10 0x5639b717aaf3 in qemu_init third_party/qemu/= softmmu/vl.c:3694:5 1109 15:16:20.312967 #11 0x5639b71083b8 in main third_party/qemu/softm= mu/main.c:49:5 1109 15:16:20.312968 #12 0x7f464de1d8d2 in __libc_start_main (/usr/grt= e/v5/lib64/libc.so.6+0x628d2) 1109 15:16:20.312969 #13 0x5639b6bbd389 in _start /usr/grte/v5/debug-s= rc/src/csu/../sysdeps/x86_64/start.S:120 1109 15:16:20.312970 1109 15:16:20.312975 Uninitialized value was stored to memory at 1109 15:16:20.313393 #0 0x5639b88acbee in tap_probe_vnet_hdr_len third= _party/qemu/net/tap-linux.c 1109 15:16:20.313396 #1 0x5639b88afd66 in net_tap_fd_init third_party/= qemu/net/tap.c:409:9 1109 15:16:20.313398 #2 0x5639b88b2d1b in net_init_tap_one third_party= /qemu/net/tap.c:681:19 1109 15:16:20.313399 #3 0x5639b88b16a8 in net_init_tap third_party/qem= u/net/tap.c:912:13 1109 15:16:20.313400 #4 0x5639b8890175 in net_client_init1 third_party= /qemu/net/net.c:1110:9 1109 15:16:20.313401 #5 0x5639b888f912 in net_client_init third_party/= qemu/net/net.c:1208:15 1109 15:16:20.313403 #6 0x5639b8894aa5 in net_param_nic third_party/qe= mu/net/net.c:1588:11 1109 15:16:20.313404 #7 0x5639b900cd18 in qemu_opts_foreach third_part= y/qemu/util/qemu-option.c:1135:14 1109 15:16:20.313405 #8 0x5639b889393c in net_init_clients third_party= /qemu/net/net.c:1612:9 1109 15:16:20.313407 #9 0x5639b717aaf3 in qemu_create_late_backends th= ird_party/qemu/softmmu/vl.c:1962:5 1109 15:16:20.313408 #10 0x5639b717aaf3 in qemu_init third_party/qemu/= softmmu/vl.c:3694:5 1109 15:16:20.313409 #11 0x5639b71083b8 in main third_party/qemu/softm= mu/main.c:49:5 1109 15:16:20.313410 #12 0x7f464de1d8d2 in __libc_start_main (/usr/grt= e/v5/lib64/libc.so.6+0x628d2) 1109 15:16:20.313412 #13 0x5639b6bbd389 in _start /usr/grte/v5/debug-s= rc/src/csu/../sysdeps/x86_64/start.S:120 1109 15:16:20.313413 1109 15:16:20.313417 Uninitialized value was stored to memory at 1109 15:16:20.313791 #0 0x5639b88affbd in net_tap_fd_init third_party/= qemu/net/tap.c:400:26 1109 15:16:20.313826 #1 0x5639b88b2d1b in net_init_tap_one third_party= /qemu/net/tap.c:681:19 1109 15:16:20.313829 #2 0x5639b88b16a8 in net_init_tap third_party/qem= u/net/tap.c:912:13 1109 15:16:20.313831 #3 0x5639b8890175 in net_client_init1 third_party= /qemu/net/net.c:1110:9 1109 15:16:20.313836 #4 0x5639b888f912 in net_client_init third_party/= qemu/net/net.c:1208:15 1109 15:16:20.313838 #5 0x5639b8894aa5 in net_param_nic third_party/qe= mu/net/net.c:1588:11 1109 15:16:20.313839 #6 0x5639b900cd18 in qemu_opts_foreach third_part= y/qemu/util/qemu-option.c:1135:14 1109 15:16:20.313841 #7 0x5639b889393c in net_init_clients third_party= /qemu/net/net.c:1612:9 1109 15:16:20.313843 #8 0x5639b717aaf3 in qemu_create_late_backends th= ird_party/qemu/softmmu/vl.c:1962:5 1109 15:16:20.313844 #9 0x5639b717aaf3 in qemu_init third_party/qemu/s= oftmmu/vl.c:3694:5 1109 15:16:20.313845 #10 0x5639b71083b8 in main third_party/qemu/softm= mu/main.c:49:5 1109 15:16:20.313846 #11 0x7f464de1d8d2 in __libc_start_main (/usr/grt= e/v5/lib64/libc.so.6+0x628d2) 1109 15:16:20.313847 #12 0x5639b6bbd389 in _start /usr/grte/v5/debug-s= rc/src/csu/../sysdeps/x86_64/start.S:120 1109 15:16:20.313849 1109 15:16:20.313851 Uninitialized value was created by an allocation of= 'ifr' in the stack frame of function 'tap_probe_vnet_hdr' 1109 15:16:20.313855 #0 0x5639b88ac680 in tap_probe_vnet_hdr third_par= ty/qemu/net/tap-linux.c:151 1109 15:16:20.313856 1109 15:16:20.313878 SUMMARY: MemorySanitizer: use-of-uninitialized-value = third_party/qemu/net/tap-linux.c:183:9 in tap_probe_vnet_hdr_len Fixes: dc69004c7d8 ("net: move tap_probe_vnet_hdr() to tap-linux.c") Reviewed-by: Hao Wu Reviewed-by: Patrick Venture Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Foley Signed-off-by: Jason Wang --- net/tap-linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/tap-linux.c b/net/tap-linux.c index 9584769..5e70b93 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -150,6 +150,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap= , Error **errp) int tap_probe_vnet_hdr(int fd, Error **errp) { struct ifreq ifr; + memset(&ifr, 0, sizeof(ifr)); =20 if (ioctl(fd, TUNGETIFF, &ifr) !=3D 0) { /* TUNGETIFF is available since kernel v2.6.27 */ --=20 2.7.4 From nobody Thu Dec 18 19:28:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644811842853660.0685917970403; Sun, 13 Feb 2022 20:10:42 -0800 (PST) Received: from localhost ([::1]:48966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJShG-0004Zd-NS for importer@patchew.org; Sun, 13 Feb 2022 23:10:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXj-0006ce-Fh for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXh-0000Aj-2q for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:51 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-c6gkVqjhPTa53lyU_4hQOA-1; Sun, 13 Feb 2022 23:00:40 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39A591006AA5; Mon, 14 Feb 2022 04:00:39 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-241.pek2.redhat.com [10.72.13.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6556F610A8; Mon, 14 Feb 2022 04:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644811248; 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=jhZsgv4sPQaXFtzY16yWsVIvtj+86X5z7l4XzOuYVZs=; b=QxlFSaW0nParpm4XqaYYWNC2TFJ3InCDjn08657sr4QxqCTMcF1Txel/+8xhbRj3f/fvwD B33vnUyXWX2dteoP32pqZuT5L3Bh9Cs8mnPrJ2Mq1Awc8mS0jNMmf4CfR8oGZVk1Z66VtX mBRImDYCvojQtvYm0LD1sjY4N4kwSL0= X-MC-Unique: c6gkVqjhPTa53lyU_4hQOA-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 4/8] net/colo-compare.c: Optimize compare order for performance Date: Mon, 14 Feb 2022 11:59:53 +0800 Message-Id: <20220214035957.71339-5-jasowang@redhat.com> In-Reply-To: <20220214035957.71339-1-jasowang@redhat.com> References: <20220214035957.71339-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -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=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: , Cc: Jason Wang , Zhang Chen , leirao , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644811845284100002 Content-Type: text/plain; charset="utf-8" From: Zhang Chen COLO-compare use the glib function g_queue_find_custom to dump another VM's networking packet to compare. But this function always start find from the queue->head(here is the newest packet), It will reduce the success rate of comparison. So this patch reversed the order of the queues for performance. Signed-off-by: Zhang Chen Reported-by: leirao Signed-off-by: Jason Wang --- net/colo-compare.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index b966e7e..216de5a 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -197,7 +197,7 @@ static void colo_compare_inconsistency_notify(CompareSt= ate *s) /* Use restricted to colo_insert_packet() */ static gint seq_sorter(Packet *a, Packet *b, gpointer data) { - return a->tcp_seq - b->tcp_seq; + return b->tcp_seq - a->tcp_seq; } =20 static void fill_pkt_tcp_info(void *data, uint32_t *max_ack) @@ -421,13 +421,13 @@ pri: if (g_queue_is_empty(&conn->primary_list)) { return; } - ppkt =3D g_queue_pop_head(&conn->primary_list); + ppkt =3D g_queue_pop_tail(&conn->primary_list); sec: if (g_queue_is_empty(&conn->secondary_list)) { - g_queue_push_head(&conn->primary_list, ppkt); + g_queue_push_tail(&conn->primary_list, ppkt); return; } - spkt =3D g_queue_pop_head(&conn->secondary_list); + spkt =3D g_queue_pop_tail(&conn->secondary_list); =20 if (ppkt->tcp_seq =3D=3D ppkt->seq_end) { colo_release_primary_pkt(s, ppkt); @@ -458,7 +458,7 @@ sec: } } if (!ppkt) { - g_queue_push_head(&conn->secondary_list, spkt); + g_queue_push_tail(&conn->secondary_list, spkt); goto pri; } } @@ -477,7 +477,7 @@ sec: if (mark =3D=3D COLO_COMPARE_FREE_PRIMARY) { conn->compare_seq =3D ppkt->seq_end; colo_release_primary_pkt(s, ppkt); - g_queue_push_head(&conn->secondary_list, spkt); + g_queue_push_tail(&conn->secondary_list, spkt); goto pri; } else if (mark =3D=3D COLO_COMPARE_FREE_SECONDARY) { conn->compare_seq =3D spkt->seq_end; @@ -490,8 +490,8 @@ sec: goto pri; } } else { - g_queue_push_head(&conn->primary_list, ppkt); - g_queue_push_head(&conn->secondary_list, spkt); + g_queue_push_tail(&conn->primary_list, ppkt); + g_queue_push_tail(&conn->secondary_list, spkt); =20 #ifdef DEBUG_COLO_PACKETS qemu_hexdump(stderr, "colo-compare ppkt", ppkt->data, ppkt->size); @@ -673,7 +673,7 @@ static void colo_compare_packet(CompareState *s, Connec= tion *conn, =20 while (!g_queue_is_empty(&conn->primary_list) && !g_queue_is_empty(&conn->secondary_list)) { - pkt =3D g_queue_pop_head(&conn->primary_list); + pkt =3D g_queue_pop_tail(&conn->primary_list); result =3D g_queue_find_custom(&conn->secondary_list, pkt, (GCompareFunc)HandlePacket); =20 @@ -689,7 +689,7 @@ static void colo_compare_packet(CompareState *s, Connec= tion *conn, * timeout, it will trigger a checkpoint request. */ trace_colo_compare_main("packet different"); - g_queue_push_head(&conn->primary_list, pkt); + g_queue_push_tail(&conn->primary_list, pkt); =20 colo_compare_inconsistency_notify(s); break; @@ -819,7 +819,7 @@ static int compare_chr_send(CompareState *s, entry->buf =3D g_malloc(size); memcpy(entry->buf, buf, size); } - g_queue_push_head(&sendco->send_list, entry); + g_queue_push_tail(&sendco->send_list, entry); =20 if (sendco->done) { sendco->co =3D qemu_coroutine_create(_compare_chr_send, sendco); @@ -1347,7 +1347,7 @@ static void colo_flush_packets(void *opaque, void *us= er_data) Packet *pkt =3D NULL; =20 while (!g_queue_is_empty(&conn->primary_list)) { - pkt =3D g_queue_pop_head(&conn->primary_list); + pkt =3D g_queue_pop_tail(&conn->primary_list); compare_chr_send(s, pkt->data, pkt->size, @@ -1357,7 +1357,7 @@ static void colo_flush_packets(void *opaque, void *us= er_data) packet_destroy_partial(pkt, NULL); } while (!g_queue_is_empty(&conn->secondary_list)) { - pkt =3D g_queue_pop_head(&conn->secondary_list); + pkt =3D g_queue_pop_tail(&conn->secondary_list); packet_destroy(pkt, NULL); } } --=20 2.7.4 From nobody Thu Dec 18 19:28:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16448120868391010.4764604829066; Sun, 13 Feb 2022 20:14:46 -0800 (PST) Received: from localhost ([::1]:59504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJSlB-0003F4-OH for importer@patchew.org; Sun, 13 Feb 2022 23:14:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXg-0006Xo-Au for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59477) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXd-0000AB-WD for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:47 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-324-mahFdZuJO5acSDi-0HqC0g-1; Sun, 13 Feb 2022 23:00:42 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D4601091DA2; Mon, 14 Feb 2022 04:00:41 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-241.pek2.redhat.com [10.72.13.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id B35A346993; Mon, 14 Feb 2022 04:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644811245; 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=bY6cvK6nZc9hj0bIXLe/SWrY0nGYXsMM/ScTWeXubo0=; b=AhIKkdP7THivd5tujpFlFwe1uyZabxX1TvXog6FZHUdr2fmUqVnWl2cT8BBexWsU2wBYTm DBINO09Y8YrVIocO1DiwfFlam6XigVBEnDLxmcfoLvgfqeuzRVMcZDx8lKc96Ux78fPf+8 yMcV16XF5OJZsAO+3Ef6gHYg0l6FC3E= X-MC-Unique: mahFdZuJO5acSDi-0HqC0g-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 5/8] net/colo-compare.c: Update the default value comments Date: Mon, 14 Feb 2022 11:59:54 +0800 Message-Id: <20220214035957.71339-6-jasowang@redhat.com> In-Reply-To: <20220214035957.71339-1-jasowang@redhat.com> References: <20220214035957.71339-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -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=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: , Cc: Zhang Chen , Jason Wang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644812089010100001 Content-Type: text/plain; charset="utf-8" From: Zhang Chen Make the comments consistent with the REGULAR_PACKET_CHECK_MS. Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/colo-compare.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 216de5a..62554b5 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -1267,7 +1267,7 @@ static void colo_compare_complete(UserCreatable *uc, = Error **errp) } =20 if (!s->expired_scan_cycle) { - /* Set default value to 3000 MS */ + /* Set default value to 1000 MS */ s->expired_scan_cycle =3D REGULAR_PACKET_CHECK_MS; } =20 --=20 2.7.4 From nobody Thu Dec 18 19:28:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644811863229574.5383894355216; Sun, 13 Feb 2022 20:11:03 -0800 (PST) Received: from localhost ([::1]:50462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJShZ-0005Yv-QA for importer@patchew.org; Sun, 13 Feb 2022 23:11:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXg-0006ZV-TW for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXe-0000AF-Ot for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-FSIoZ-IzNhihwM4Pa8LbNA-1; Sun, 13 Feb 2022 23:00:45 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DBF4718397BE; Mon, 14 Feb 2022 04:00:43 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-241.pek2.redhat.com [10.72.13.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7359610A6; Mon, 14 Feb 2022 04:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644811246; 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=k1NJAYuxbBU0g4T+irextBwXVyFw4TEr/n6y5h1xTD4=; b=BlJtDM6rbkZ6WhMpIrmxsyzdavVZj50OKRBYPEnSztU0J/TJfdSWjX+k7ec53AzfRBnHBM GDOBrFkhfOVJ00OcE2kHGWUKqe0gX2AYgYfoskiHLjU3SGfxsfPZjkAEeg7/lZWn7RUDK+ IeilDWf8QWV46hUkpx3jAdKjCtDrhMQ= X-MC-Unique: FSIoZ-IzNhihwM4Pa8LbNA-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 6/8] net/filter: Optimize filter_send to coroutine Date: Mon, 14 Feb 2022 11:59:55 +0800 Message-Id: <20220214035957.71339-7-jasowang@redhat.com> In-Reply-To: <20220214035957.71339-1-jasowang@redhat.com> References: <20220214035957.71339-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=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: , Cc: Jason Wang , Zhang Chen , Rao Lei , qemu-devel@nongnu.org, Li Zhijian Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644811865407100001 Content-Type: text/plain; charset="utf-8" From: Rao Lei This patch is to improve the logic of QEMU main thread sleep code in qemu_chr_write_buffer() where it can be blocked and can't run other coroutines during COLO IO stress test. Our approach is to put filter_send() in a coroutine. In this way, filter_send() will call qemu_coroutine_yield() in qemu_co_sleep_ns(), so that it can be scheduled out and QEMU main thread has opportunity to run other tasks. Signed-off-by: Lei Rao Signed-off-by: Zhang Chen Reviewed-by: Li Zhijian Reviewed-by: Zhang Chen Signed-off-by: Jason Wang --- net/filter-mirror.c | 66 ++++++++++++++++++++++++++++++++++++++++++-------= ---- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/net/filter-mirror.c b/net/filter-mirror.c index f20240c..34a63b5 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -20,6 +20,7 @@ #include "chardev/char-fe.h" #include "qemu/iov.h" #include "qemu/sockets.h" +#include "block/aio-wait.h" =20 #define TYPE_FILTER_MIRROR "filter-mirror" typedef struct MirrorState MirrorState; @@ -42,20 +43,21 @@ struct MirrorState { bool vnet_hdr; }; =20 -static int filter_send(MirrorState *s, - const struct iovec *iov, - int iovcnt) +typedef struct FilterSendCo { + MirrorState *s; + char *buf; + ssize_t size; + bool done; + int ret; +} FilterSendCo; + +static int _filter_send(MirrorState *s, + char *buf, + ssize_t size) { NetFilterState *nf =3D NETFILTER(s); int ret =3D 0; - ssize_t size =3D 0; uint32_t len =3D 0; - char *buf; - - size =3D iov_size(iov, iovcnt); - if (!size) { - return 0; - } =20 len =3D htonl(size); ret =3D qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len= )); @@ -80,10 +82,7 @@ static int filter_send(MirrorState *s, } } =20 - buf =3D g_malloc(size); - iov_to_buf(iov, iovcnt, 0, buf, size); ret =3D qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); - g_free(buf); if (ret !=3D size) { goto err; } @@ -94,6 +93,47 @@ err: return ret < 0 ? ret : -EIO; } =20 +static void coroutine_fn filter_send_co(void *opaque) +{ + FilterSendCo *data =3D opaque; + + data->ret =3D _filter_send(data->s, data->buf, data->size); + data->done =3D true; + g_free(data->buf); + aio_wait_kick(); +} + +static int filter_send(MirrorState *s, + const struct iovec *iov, + int iovcnt) +{ + ssize_t size =3D iov_size(iov, iovcnt); + char *buf =3D NULL; + + if (!size) { + return 0; + } + + buf =3D g_malloc(size); + iov_to_buf(iov, iovcnt, 0, buf, size); + + FilterSendCo data =3D { + .s =3D s, + .size =3D size, + .buf =3D buf, + .ret =3D 0, + }; + + Coroutine *co =3D qemu_coroutine_create(filter_send_co, &data); + qemu_coroutine_enter(co); + + while (!data.done) { + aio_poll(qemu_get_aio_context(), true); + } + + return data.ret; +} + static void redirector_to_filter(NetFilterState *nf, const uint8_t *buf, int len) --=20 2.7.4 From nobody Thu Dec 18 19:28:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644811953320289.820871420686; Sun, 13 Feb 2022 20:12:33 -0800 (PST) Received: from localhost ([::1]:55042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJSj1-0000EE-Uc for importer@patchew.org; Sun, 13 Feb 2022 23:12:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXm-0006eO-1Z for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXj-0000Az-1b for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:53 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-E31MarUBPUKxbboUR-kBzA-1; Sun, 13 Feb 2022 23:00:47 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C2BB1006AA0; Mon, 14 Feb 2022 04:00:46 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-241.pek2.redhat.com [10.72.13.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DFD7610A6; Mon, 14 Feb 2022 04:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644811250; 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=h3RedhG9aD0ZTxmpdFxJl0pN527mHZOxNzzvpNCSUyU=; b=cGy27FTdwq/SzqblC9Naxm3/0MoYDXShRVzISrUVWUiwj7QYGWrw1Q58W8aNtCFXSDT746 RCYw5Ck69h6dX+egeuB0tH1fuICibjl2tWAVUqu2uQ7zpr4yIGIDpwGm296SVfTwKiq4h1 tPSsw6QA6M2TJNIg/h8dNzeWuyvvQ7c= X-MC-Unique: E31MarUBPUKxbboUR-kBzA-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 7/8] hw/net: e1000e: Clear ICR on read when using non MSI-X interrupts Date: Mon, 14 Feb 2022 11:59:56 +0800 Message-Id: <20220214035957.71339-8-jasowang@redhat.com> In-Reply-To: <20220214035957.71339-1-jasowang@redhat.com> References: <20220214035957.71339-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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: -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=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: , Cc: Nick Hudson , Jason Wang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644811954080100001 Content-Type: text/plain; charset="utf-8" From: Nick Hudson In section 7.4.3 of the 82574 datasheet it states that "In systems that do not support MSI-X, reading the ICR register clears it's bits..." Some OSes rely on this. Signed-off-by: Nick Hudson Signed-off-by: Jason Wang --- hw/net/e1000e_core.c | 5 +++++ hw/net/trace-events | 1 + 2 files changed, 6 insertions(+) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 8ae6fb7..2c51089 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2607,6 +2607,11 @@ e1000e_mac_icr_read(E1000ECore *core, int index) core->mac[ICR] =3D 0; } =20 + if (!msix_enabled(core->owner)) { + trace_e1000e_irq_icr_clear_nonmsix_icr_read(); + core->mac[ICR] =3D 0; + } + if ((core->mac[ICR] & E1000_ICR_ASSERTED) && (core->mac[CTRL_EXT] & E1000_CTRL_EXT_IAME)) { trace_e1000e_irq_icr_clear_iame(); diff --git a/hw/net/trace-events b/hw/net/trace-events index 643338f..4c0ec3f 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -221,6 +221,7 @@ e1000e_irq_write_ics(uint32_t val) "Adding ICR bits 0x%= x" e1000e_irq_icr_process_iame(void) "Clearing IMS bits due to IAME" e1000e_irq_read_ics(uint32_t ics) "Current ICS: 0x%x" e1000e_irq_read_ims(uint32_t ims) "Current IMS: 0x%x" +e1000e_irq_icr_clear_nonmsix_icr_read(void) "Clearing ICR on read due to n= on MSI-X int" e1000e_irq_icr_read_entry(uint32_t icr) "Starting ICR read. Current ICR: 0= x%x" e1000e_irq_icr_read_exit(uint32_t icr) "Ending ICR read. Current ICR: 0x%x" e1000e_irq_icr_clear_zero_ims(void) "Clearing ICR on read due to zero IMS" --=20 2.7.4 From nobody Thu Dec 18 19:28:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644811611879870.051745730387; Sun, 13 Feb 2022 20:06:51 -0800 (PST) Received: from localhost ([::1]:40806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJSdX-0007W0-Ip for importer@patchew.org; Sun, 13 Feb 2022 23:06:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXq-0006je-RR for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:01:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJSXm-0000Ba-3X for qemu-devel@nongnu.org; Sun, 13 Feb 2022 23:00:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-467-FAJAJgqfP_WCIa9AjKupfQ-1; Sun, 13 Feb 2022 23:00:49 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42A6E1091DA1; Mon, 14 Feb 2022 04:00:48 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-241.pek2.redhat.com [10.72.13.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 960D546993; Mon, 14 Feb 2022 04:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644811252; 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=yA6fcj2d5bddIJ8jBnTDbw8Qw+Nc1V5MgmXJde4PnxY=; b=GhHPJhK6FfXCZwWjq4TvnHDZ2rYsphq0GKK0UBgp0F/Q7fo5yZOikTreDSXohA3zwGA5LC mKIdfOV9hQd7nijeBF7fKzXNWngtLZMU1CMIGshzXidvlLupJtciUS3kH33kIUrTqrDxh4 1/r9s1pTKE/S3iiIyYp4bCs7zDAVAOg= X-MC-Unique: FAJAJgqfP_WCIa9AjKupfQ-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 8/8] net/eth: Don't consider ESP to be an IPv6 option header Date: Mon, 14 Feb 2022 11:59:57 +0800 Message-Id: <20220214035957.71339-9-jasowang@redhat.com> In-Reply-To: <20220214035957.71339-1-jasowang@redhat.com> References: <20220214035957.71339-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=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: , Cc: Thomas Jansen , Jason Wang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644811613683100003 Content-Type: text/plain; charset="utf-8" From: Thomas Jansen The IPv6 option headers all have in common that they start with some common fields, in particular the type of the next header followed by the extention header length. This is used to traverse the list of the options. The ESP header does not follow that format, which can break the IPv6 option header traversal code in eth_parse_ipv6_hdr(). The effect of that is that network interfaces such as vmxnet3 that use the following call chain eth_is_ip6_extension_header_type eth_parse_ipv6_hdr net_tx_pkt_parse_headers net_tx_pkt_parse vmxnet3_process_tx_queue to send packets from the VM out to the host will drop packets of the following structure: Ethernet-Header(IPv6-Header(ESP(encrypted data))) Note that not all types of network interfaces use the net_tx_pkt_parse function though, leading to inconsistent behavior regarding sending those packets. The e1000 network interface for example does not suffer from this limitation. By not considering ESP to be an IPv6 header we can allow sending those packets out to the host on all types of network interfaces. Fixes: 75020a702151 ("Common definitions for VMWARE devices") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/149 Buglink: https://bugs.launchpad.net/qemu/+bug/1758091 Signed-off-by: Thomas Jansen Signed-off-by: Jason Wang --- net/eth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/eth.c b/net/eth.c index fe876d1..f074b2f 100644 --- a/net/eth.c +++ b/net/eth.c @@ -389,7 +389,6 @@ eth_is_ip6_extension_header_type(uint8_t hdr_type) case IP6_HOP_BY_HOP: case IP6_ROUTING: case IP6_FRAGMENT: - case IP6_ESP: case IP6_AUTHENTICATION: case IP6_DESTINATON: case IP6_MOBILITY: --=20 2.7.4