From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 52EB045DB3 for ; Wed, 27 Nov 2024 09:35:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D9D14028B; Wed, 27 Nov 2024 09:35:51 +0100 (CET) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mails.dpdk.org (Postfix) with ESMTP id CFA8D400D6; Mon, 25 Nov 2024 03:01:43 +0100 (CET) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-72410cc7be9so3484460b3a.0; Sun, 24 Nov 2024 18:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732500102; x=1733104902; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yQkOm/SoVVc88VlU+LMbsWBWfmuY1dYv2w+nOgSKbZE=; b=ITZWmwLKPkyZwtF3cGmif/93ywx0dmuBn7Vt/PTDBxfvPANF2sJxTp/2CF4pTN8Pz+ EIjQJDDZZU0xbmo4eeBi4wQ08AK+jM9zal8erfNfnhOqKJlsMgMdFVGv1afmKEZlhbaO qS44Uw4OcBzhkN6AmsCTuVV1GJPGZD0Ovs1dAUfQzWXteyV/tCb09bvGWm5PQOcWFfMo fwkX913cFJs++R1boBSmVcWUIXkRAAI9awQkQHu7PlzB0LEniviBm4Abcdc8ud1ILsUK zNx6k0QD2OOsq2Q0rgcuyGChjLoX9O2LZhKwDJI6atFmUB8knd3zoyj5E7vjn1sqPNap eTGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732500102; x=1733104902; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yQkOm/SoVVc88VlU+LMbsWBWfmuY1dYv2w+nOgSKbZE=; b=qJs3x4Tc093xj3FFM1BdirWI0aJMz4KT1vYqEnZEKb+TpHvUZdrvcKTCMBChUQJktH zJCGQtgf0LaVpYa6My6jewShfXZqWEOPeIPM6/Zc5mBnDE+o1S9CUyRrptn1xh6h5aoa U+rM/A1/WQdx2aFHDYRBuxragU71j1xmuoyEnBSjzXzFKMZ3bKlKPwx7KR354En/rFf6 MYZVPxGVJZtof5zMYGXWGLKHRe4COPotnuW7EFDJWCEBSydG7571gbYSE8kgAtjLaVTH 1UJFc+3qrOnRtAmm4tMJR/IMMf7014sDpBEowJbczUqzhkV24VLOhl2laEbOG6W7x4Qn X+bg== X-Gm-Message-State: AOJu0YxOA0/gJSisNiGZYGaUBVBD/r6AaSC/gih81C9xy0qNoCbGq6jj TbOCTmWYDwRbMHci5TOkJEHwQDCgqSCAacbiTWlLygCPSF3ZZ6ulGgiC7WbQnkSX2Q== X-Gm-Gg: ASbGncuHaoypCaPSEPDrEkdj+daGuSgFVQGiEIyC/FT2YkcQr2NxA1Tp535Grc3TxLF dtrqc18kVr+9m8BGT1yh8ozko+FiEPHT327rkfrVmUvqv56hRe8kO/O0YnLtZlRmH1mmC6OzRhF VIsNp4XnJD61IBJMZWhMNM+nqtPDBweJppdDwUCZjB6ADVGBiZqq7e8M4r2rSpeckRNJQE32OsI 8KQGdM8X3+9bRKbH0PxznCDNrWBav+L+uyw2NtnKu/9452QDlIF2YA+yJ1dQwOrphYog8iENMA= X-Google-Smtp-Source: AGHT+IEw5aHloYVNU9s7OgcLkM6dxw6Soi7/Dy77LzN8o0eFb0keFmT2AtqmH+WZ8Xy4BV7opxKysw== X-Received: by 2002:a05:6a00:9a0:b0:71e:5950:97d2 with SMTP id d2e1a72fcca58-724df67dc69mr15193410b3a.17.1732500102549; Sun, 24 Nov 2024 18:01:42 -0800 (PST) Received: from jeffzhao-1.NEBULA-MATRIX.COM ([223.65.28.15]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724de53a276sm5394600b3a.106.2024.11.24.18.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2024 18:01:42 -0800 (PST) From: "jianping.zhao" To: dev@dpdk.org Cc: stable@dpdk.org, maxime.coquelin@redhat.com, chenbo.xia@intel.com, "Jianping.zhao" Subject: [PATCH] vhost: clear ring addresses when getting vring base Date: Mon, 25 Nov 2024 10:01:01 +0800 Message-Id: <20241125020101.2073294-1-zhao305149619@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 27 Nov 2024 09:35:49 +0100 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: "Jianping.zhao" Clear ring addresses during vring base retrieval to handle guest reboot scenarios correctly. This is particularly important for vdpa-blk devices where the following issue occurs: When a guest OS with vdpa-blk device reboots, during UEFI stage, only one vring is actually used and configured. However, QEMU still sends enable messages for all configured queues. The remaining queues retain their addresses from before reboot, which reference invalid memory mappings in the rebooted guest. The issue manifests in vq_is_ready(): static bool vq_is_ready(struct virtio_net *dev, struct vhost_virtqueue *vq) { /* Only checks pointer validity, not address freshness */ rings_ok = vq->desc && vq->avail && vq->used; ... } vq_is_ready() incorrectly considers these queues as ready because it only checks if desc/avail/used pointers are non-NULL, but cannot detect that these addresses are stale from the previous boot. Clear the ring addresses in vhost_user_get_vring_base() to force the guest driver to reconfigure them before use. This ensures that vq_is_ready() will return false for queues with stale addresses until they are properly reconfigured by the guest driver. Fixes: 3ea7052f4b1b ("vhost: postpone rings addresses translation") Cc: stable@dpdk.org Cc: Maxime Coquelin Cc: Chenbo Xia Signed-off-by: jianping.zhao --- lib/vhost/vhost_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 6d92ad904e..52d8078d7c 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -2277,6 +2277,7 @@ vhost_user_get_vring_base(struct virtio_net **pdev, rte_rwlock_write_lock(&vq->access_lock); vring_invalidate(dev, vq); + memset(&vq->ring_addrs, 0, sizeof(struct vhost_vring_addr)); rte_rwlock_write_unlock(&vq->access_lock); return RTE_VHOST_MSG_RESULT_REPLY; -- 2.34.1