From nobody Tue May 14 17:55:38 2024 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688441746; cv=none; d=zohomail.com; s=zohoarc; b=ld+Jm9wRKc19DcY0j8Yqx/VJiHLaEehKNIfqoLMkTuTm6ARQTogLvV6uQMGQO6YXhCv/jro5AS3C34IRSCyat8IdPKUMkoPApx2NyWNClu0uFZtWJbzDevuYbjh4llZ72qWwdEHaSugGQLjAOuBTJKxXrANiDJ/El00KEv4QsKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688441746; 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=e3CZYmpUITOvdpykc8+NdOHFwjtnMg+PjG83VfEH+ko=; b=BtszLmA6VpbHm2aG6orXqC8kXoiMCBlDBdCZiFWhn9DhAtQYJ+WuWzDvq9R/P1cWcBqZxr1EFPEhd0yrVvtVL7SXs2er4QTSLb2NhrzBQAtKjwhOECDxIbjKf3JYc3IdCxv4jaojX4N9BtcF7VWkOpaejnflNunVAz6XLuRreG0= 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 1688441746812906.3949206455076; Mon, 3 Jul 2023 20:35:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGWoS-0001AV-83; Mon, 03 Jul 2023 23:34:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGWoQ-00019v-TV; Mon, 03 Jul 2023 23:34:46 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGWoP-00032n-8G; Mon, 03 Jul 2023 23:34:46 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6682909acadso2481168b3a.3; Mon, 03 Jul 2023 20:34:44 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id z10-20020a170902708a00b001b830d8bc40sm9905139plk.74.2023.07.03.20.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 20:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688441683; x=1691033683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e3CZYmpUITOvdpykc8+NdOHFwjtnMg+PjG83VfEH+ko=; b=Uq/u1hIJ7xw51iyIgtADhmz+x3+puH1MxqnU6+RYOPoTzdBLz4EeOIbpKIOz1HMqrU uOpjliQcyfkcclZx2qr6Ye1HMCMV7caLkFy06lI1p6rdQGILnGwPIb6CDYLK7xCNyM5e /Ovlhze+idafiZRNyZUF6xY2SYlhn6cDkgZZ9uxY8JAqc3HOKBeWg5mu6ciqE2U4CRzT BsAwd+biBP8vR7N96Q5yeDDPC3Zmco4lZSsMsMI2qbKZ/KW/A2jPsWxJbJ2AYQMp0WFk ru23H8H5N3P8Pn0p4UjDoldiiGFxX/o6KXbpp3J4vNBe9UXGOiMiiJklGOsu+24k3pHk g6+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688441683; x=1691033683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e3CZYmpUITOvdpykc8+NdOHFwjtnMg+PjG83VfEH+ko=; b=CInAXS5w60O/CzYr+piExqYnLRWns8DdtSkcPcH8o+qb7tQg/fPviga3OLGcF7HYYZ iXgj4MufG6zVnt2hyIL4v9yznTctEE/b2oc5M2iBzux4hqvsGsm5kJ7UvKphO5gjjIAx QuZR0KrDX6rTdrL8oqARHQNa0imtLgCBhIy1easzWUtAh4YGkXCQNIztJ1U3jpjAv2s+ nFM622dB+cFJ4OzijJ2ybF9V+sBUNDNyLYKHtMxy15SWCs4J+8KMPJ4PQFe32LVmB2MJ V/jYXglAzu4+huYOldgW2fS1hEwljVqILncvfM3Q06F0+Pyy2AIFs+gtmq1s4lwxnr3P 767w== X-Gm-Message-State: ABy/qLZ83zx07YszgwDSy7WAAQyp/FPpT5jFsELqLs5jET2T2gdAq9rn NQ1bAMBfpseLrJWKN3f4gik= X-Google-Smtp-Source: APBJJlEeHJhvL8yO/rkOGOHEpR1DL7v8DKpPl14CmhRaV7CP+9aV2PkZyKMpLff9ycajS0y2Gj6Zlw== X-Received: by 2002:a05:6a21:9991:b0:12d:cf28:3bc7 with SMTP id ve17-20020a056a21999100b0012dcf283bc7mr8820484pzb.11.1688441682986; Mon, 03 Jul 2023 20:34:42 -0700 (PDT) From: Hawkins Jiawei To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com Cc: qemu-stable@nongnu.org, qemu-devel@nongnu.org, yin31149@gmail.com, 18801353760@163.com Subject: [PATCH v3 1/3] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_mac() Date: Tue, 4 Jul 2023 11:34:33 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 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=2607:f8b0:4864:20::435; envelope-from=yin31149@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688441747928100003 According to VirtIO standard, "The class, command and command-specific-data are set by the driver, and the device sets the ack byte. There is little it can do except issue a diagnostic if ack is not VIRTIO_NET_OK." Therefore, QEMU should stop sending the queued SVQ commands and cancel the device startup if the device's ack is not VIRTIO_NET_OK. Yet the problem is that, vhost_vdpa_net_load_mac() returns 1 based on `*s->status !=3D VIRTIO_NET_OK` when the device's ack is VIRTIO_NET_ERR. As a result, net->nc->info->load() also returns 1, this makes vhost_net_start_one() incorrectly assume the device state is successfully loaded by vhost_vdpa_net_load() and return 0, instead of goto `fail` label to cancel the device startup, as vhost_net_start_one() only cancels the device startup when net->nc->info->load() returns a negative value. This patch fixes this problem by returning -EIO when the device's ack is not VIRTIO_NET_OK. Fixes: f73c0c43ac ("vdpa: extract vhost_vdpa_net_load_mac from vhost_vdpa_n= et_load") Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang Acked-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- v3: - split the fixes suggested by Eugenio - return -EIO suggested by Michael v2: https://lore.kernel.org/all/69010e9ebb5e3729aef595ed92840f43e48e53e5.16= 87875592.git.yin31149@gmail.com/ - fix the same bug in vhost_vdpa_net_load_offloads() v1: https://lore.kernel.org/all/07a1133d6c989394b342e35d8202257771e76769.16= 86746406.git.yin31149@gmail.com/ net/vhost-vdpa.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e19ab063fa..ee273c40ca 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -646,8 +646,9 @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, c= onst VirtIONet *n) if (unlikely(dev_written < 0)) { return dev_written; } - - return *s->status !=3D VIRTIO_NET_OK; + if (*s->status !=3D VIRTIO_NET_OK) { + return -EIO; + } } =20 return 0; --=20 2.25.1 From nobody Tue May 14 17:55:38 2024 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688441751; cv=none; d=zohomail.com; s=zohoarc; b=H8GGkrh1LQlkXJ5nrXTHwYM0pw+fgLkfaylKwkP8IAn2rrMwWeuJrFocPm1F/UY9Mm9k7CmP1mNWkTDVmEIdI3R1H6x7c17rmOFbU4IpwD5jUI4JzUCWs4kboiOB7Yao3yw3Oxe29kUgBsQS0CRJSqoTjLtGp0vqmYbKVMzxEDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688441751; 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=d4hybVCX0OeK0QstPXvMpIqBFqBkok82Ipoq0R1xsO8=; b=erkrKOIF3bkggIX38lMlv0dM3P73HmCdy5vqDqKKkgZbCgm9AbOjKU9kp+yeyQwuEpi+FsJZmTEPNhh0UJ+zwRSPDZo6+KSu3ZxKwEG34DfttWZBINerN/nkwzOdk3xvXHufBgmtCVgEbbu40hSJl8r6gJCTNG5lEHt6PxQ/ngk= 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 1688441751480722.2038622450606; Mon, 3 Jul 2023 20:35:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGWoV-0001Bk-4Z; Mon, 03 Jul 2023 23:34:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGWoT-0001Ap-4I; Mon, 03 Jul 2023 23:34:49 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGWoR-00032u-GO; Mon, 03 Jul 2023 23:34:48 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1b89b75dc1cso9089995ad.1; Mon, 03 Jul 2023 20:34:46 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id i7-20020a170902c94700b001b8707b70d1sm6338993pla.214.2023.07.03.20.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 20:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688441686; x=1691033686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d4hybVCX0OeK0QstPXvMpIqBFqBkok82Ipoq0R1xsO8=; b=SsYFuYZDy5rNK8kyTX9O6TscQZWHne1yMaxCRTucBhdgp26xSB+cn+s9TbsnpXPgaM Yb7/VTP7oE1r7I+MFvQVsTw+LLSkBOzZQlBoeUpkTPQUSoAUme5fW1Bag0n1zXsxd1K+ KOPYDS4RXEbuxDzxynq1j4Jjc2fd3NrmhDR/m8qsq+B+LmNb0AMT90hZg4/RIw44olVk kC0rG5vLX5PTjN8KyfQ59kxgATN3bjoVr61BqQanI6QFMMgJS9/ueZLzXeaXKF8m9oqf 8/bUb/DfYDPyLjhgZSahawVdrXqDUAAkYGBspJdhzi8mgZiUInyzCCebL+S9D9P4//qd m1kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688441686; x=1691033686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d4hybVCX0OeK0QstPXvMpIqBFqBkok82Ipoq0R1xsO8=; b=VbLwizdeSTOFlcHZp91Hp+gm46lKIengfg2hVVzUjAnCg3vRFHlTX3M0wBYJyFGv+l fIQu3xIg8T7rCiMTcLOmCU3bdd5XLQtlWLPG4T4t2N4Vrk4ZUyZ0kqjRLL4fMzYf0wxF BpHKEWgNFTFOE6undBHsgFUxPPQ3PmdfUuy7YIW55aN5PWgaYvSaiUG+1VPaXvSAltB0 memikpoF2ekrp6E0dXv7WO8SkFRo9P8zpUunbjFEv3HlLA4q2ez+rGWZDbsk6JryKTZf hsCJF+4UNLD2Sg0bdFmEa53T+Yh+pm8NywdnEBZ2Y+pAaEB9X1vgL9nM/3rFd800U//9 ezFQ== X-Gm-Message-State: AC+VfDwdbZiSRNJ6rOj/KIupUvO4r64NNTvhzbgvO/0OFtNpHdoj3YRB QdBFQBg4JPaPavrN9j1vSD8= X-Google-Smtp-Source: ACHHUZ6Av3yZrd2mhIJ5ZfB21+j+pRFKdNlRx4USdtsJKf+bURpHPfR0A0jr7R0hCU5bXO6leoRpHw== X-Received: by 2002:a17:902:e84e:b0:1b7:de50:7d9c with SMTP id t14-20020a170902e84e00b001b7de507d9cmr27482692plg.15.1688441685551; Mon, 03 Jul 2023 20:34:45 -0700 (PDT) From: Hawkins Jiawei To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com Cc: qemu-stable@nongnu.org, qemu-devel@nongnu.org, yin31149@gmail.com, 18801353760@163.com Subject: [PATCH v3 2/3] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_mq() Date: Tue, 4 Jul 2023 11:34:34 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 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=2607:f8b0:4864:20::633; envelope-from=yin31149@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688441753639100007 According to VirtIO standard, "The class, command and command-specific-data are set by the driver, and the device sets the ack byte. There is little it can do except issue a diagnostic if ack is not VIRTIO_NET_OK." Therefore, QEMU should stop sending the queued SVQ commands and cancel the device startup if the device's ack is not VIRTIO_NET_OK. Yet the problem is that, vhost_vdpa_net_load_mq() returns 1 based on `*s->status !=3D VIRTIO_NET_OK` when the device's ack is VIRTIO_NET_ERR. As a result, net->nc->info->load() also returns 1, this makes vhost_net_start_one() incorrectly assume the device state is successfully loaded by vhost_vdpa_net_load() and return 0, instead of goto `fail` label to cancel the device startup, as vhost_net_start_one() only cancels the device startup when net->nc->info->load() returns a negative value. This patch fixes this problem by returning -EIO when the device's ack is not VIRTIO_NET_OK. Fixes: f64c7cda69 ("vdpa: Add vhost_vdpa_net_load_mq") Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang Acked-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- v3: - split the fixes suggested by Eugenio - return -EIO suggested by Michael v2: https://lore.kernel.org/all/69010e9ebb5e3729aef595ed92840f43e48e53e5.16= 87875592.git.yin31149@gmail.com/ - fix the same bug in vhost_vdpa_net_load_offloads() v1: https://lore.kernel.org/all/07a1133d6c989394b342e35d8202257771e76769.16= 86746406.git.yin31149@gmail.com/ net/vhost-vdpa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index ee273c40ca..03d87e85c8 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -671,8 +671,11 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, if (unlikely(dev_written < 0)) { return dev_written; } + if (*s->status !=3D VIRTIO_NET_OK) { + return -EIO; + } =20 - return *s->status !=3D VIRTIO_NET_OK; + return 0; } =20 static int vhost_vdpa_net_load_offloads(VhostVDPAState *s, --=20 2.25.1 From nobody Tue May 14 17:55:38 2024 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688441751; cv=none; d=zohomail.com; s=zohoarc; b=HLti67XQAlsIl/SjbWTUozxC+ESHlMuE/Rb6ta9sMt8KoqoOWDct9vAUj/h2NZfXvQSkjAsEq02JLfHOWdU5hKwxtpSPKByT/rC2LqrteF1XhQaVbB8HenkvUrx0mabWh3WLR5YrsAeQm1qtv9+QirfSpzDW9E6xbJXCbbBmqk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688441751; 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=UieVTM0ijH4N8thbVTg381kGlKgp/GZSBGu7R4hXdyI=; b=bQjobU3aqbFLdm5uwhsTTedlS6gWRhKdt8MZaIVAVIBEp/dcnx2HsGf8RYJqmiuh1HayDPdDAroEpbtRZoo3rszu/phB2jr8rq6aNBwk9VJhLAwD/DVG3RiAtieZMVE/+xSc/CYE9kO3BWPnWxTcx2BqZ97g/GoRK/EI5/ZfZZE= 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 1688441751307876.6881650317448; Mon, 3 Jul 2023 20:35:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGWoX-0001CH-MS; Mon, 03 Jul 2023 23:34:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGWoW-0001Bn-56; Mon, 03 Jul 2023 23:34:52 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGWoU-00033S-Hw; Mon, 03 Jul 2023 23:34:51 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-67ef5af0ce8so4214006b3a.2; Mon, 03 Jul 2023 20:34:49 -0700 (PDT) Received: from localhost ([159.226.94.115]) by smtp.gmail.com with ESMTPSA id 141-20020a630293000000b00514256c05c2sm15591861pgc.7.2023.07.03.20.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 20:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688441689; x=1691033689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UieVTM0ijH4N8thbVTg381kGlKgp/GZSBGu7R4hXdyI=; b=exvGYXYX83DV3z8u4ykn6T+NpWAjfZrrWrKl0+Bbriprcpgm8Lux96Zncj+ugjSP7x XLqvvOT5NBVus1VrAqKZ9T+XfrKwljb2AeAIIWyta1+tJ0UmscF0Zy4mf1ubXBdXa4+Z 9X3ImglMlS/FTH++hvw73/oa+vEy8gUf6qy8GwXSvztQsBYTbPn8Jh2Y6POlduDPotQ2 wftC5LTMajWEi9iVNjrB2GXxIafVGFG74GYWsUO1x/vvGChivGCDcwgFtOk/aXqCAWdo MEgGgidCD8YFDTI/Y365WeTRH4bRbye1UNCVnqMKtHyTlG2Vb3DkosYvOGx/p1TM8IGJ jJ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688441689; x=1691033689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UieVTM0ijH4N8thbVTg381kGlKgp/GZSBGu7R4hXdyI=; b=MOpahKSh/ce3RqZsSjaHQEJcLMBLNqjbdDLT79TweF4ubALyPt8JYDvia5tQBo8BJi xGXpD3ehcxMJLWtb5xQTYR3v5jIDmjh6h+656/vjibEv9tGDzs5OnQnw8oSZ/zxsvOva fczE9hHBnkydUWsmyjVUR+0p7I5oR9YoLLkZZwXWJzUEoArRQLDSh/JHKLCcpXTOTLur MP7U1prfGx7Bzy/6WCaUrxczCFvfjNpkJYfkRWvMq2yOQnqxqXSBxZQRymUfr3imirJN oYtInaPQI2E8+ZelwmtHdghI+h//mNpf6ZhHIOfq8lD03wIBM1ra+qijoHKqNYiEuXud ZwpA== X-Gm-Message-State: ABy/qLasXU79p8osOzmxSqKbCKgB1Kr0MxYY8vvHx4LvLLsEQKWn5pmg QzARPcW/wWrXZvHo9Xrk598= X-Google-Smtp-Source: APBJJlF7O1pgV0bcuOIx6l2q0/fnlQUXcnVaa3LwE37FxNpfPnL5xSELub30o/g1PpERldwxF6g/qw== X-Received: by 2002:a05:6a00:148b:b0:682:4c9f:aa0 with SMTP id v11-20020a056a00148b00b006824c9f0aa0mr16194594pfu.29.1688441688516; Mon, 03 Jul 2023 20:34:48 -0700 (PDT) From: Hawkins Jiawei To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com Cc: qemu-stable@nongnu.org, qemu-devel@nongnu.org, yin31149@gmail.com, 18801353760@163.com Subject: [PATCH v3 3/3] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_offloads() Date: Tue, 4 Jul 2023 11:34:35 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 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=2607:f8b0:4864:20::435; envelope-from=yin31149@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1688441751632100001 According to VirtIO standard, "The class, command and command-specific-data are set by the driver, and the device sets the ack byte. There is little it can do except issue a diagnostic if ack is not VIRTIO_NET_OK." Therefore, QEMU should stop sending the queued SVQ commands and cancel the device startup if the device's ack is not VIRTIO_NET_OK. Yet the problem is that, vhost_vdpa_net_load_offloads() returns 1 based on `*s->status !=3D VIRTIO_NET_OK` when the device's ack is VIRTIO_NET_ERR. As a result, net->nc->info->load() also returns 1, this makes vhost_net_start_one() incorrectly assume the device state is successfully loaded by vhost_vdpa_net_load() and return 0, instead of goto `fail` label to cancel the device startup, as vhost_net_start_one() only cancels the device startup when net->nc->info->load() returns a negative value. This patch fixes this problem by returning -EIO when the device's ack is not VIRTIO_NET_OK. Fixes: 0b58d3686a ("vdpa: Add vhost_vdpa_net_load_offloads()") Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang Acked-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- v3: - split the fixes suggested by Eugenio - return -EIO suggested by Michael v2: https://lore.kernel.org/all/69010e9ebb5e3729aef595ed92840f43e48e53e5.16= 87875592.git.yin31149@gmail.com/ - fix the same bug in vhost_vdpa_net_load_offloads() v1: https://lore.kernel.org/all/07a1133d6c989394b342e35d8202257771e76769.16= 86746406.git.yin31149@gmail.com/ net/vhost-vdpa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 03d87e85c8..36aa2d7f8c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -712,8 +712,11 @@ static int vhost_vdpa_net_load_offloads(VhostVDPAState= *s, if (unlikely(dev_written < 0)) { return dev_written; } + if (*s->status !=3D VIRTIO_NET_OK) { + return -EIO; + } =20 - return *s->status !=3D VIRTIO_NET_OK; + return 0; } =20 static int vhost_vdpa_net_load(NetClientState *nc) --=20 2.25.1