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 2699446250 for ; Mon, 17 Feb 2025 18:05:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 17E6640289; Mon, 17 Feb 2025 18:05:02 +0100 (CET) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mails.dpdk.org (Postfix) with ESMTP id 55C86400D6 for ; Mon, 17 Feb 2025 18:05:01 +0100 (CET) Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-38dcac27bcbso3421220f8f.0 for ; Mon, 17 Feb 2025 09:05:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739811901; x=1740416701; darn=dpdk.org; 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=ACbputX3Vw8flpy62hwYr1nChKl0HpWenlAXy02VaoU=; b=MXDVTMC3DZeITr6O8q8FAa0g4GDUUaxEwSIcMgxYt1DsQk1fq5YyI8MPmNdL0lW+iT 6Gx4ERDSVuKDok3xKPYqVQYeEkjiQDJkSfY68aYORH4bvJMZ9A6p9wWrDDDM8D99ZyK/ Vr92cY3IIKRkXAvtuZla8s2TLyQBA4YGecgKhUB/Zu9KcPN9oNunDa//nytkASqSOuHL qryGc14JCA0AIHGl3ddeXDrOmnf4+XFQOEMH/Zz54DtuHTl3WsRlAVekMhhNSy567tvp iAbbro8MhWXgHkl6rSvzuHbi1+1bHALi9QPAGzq8oSOtI/6hE5ovLZnl2waAMq793AlJ CFGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739811901; x=1740416701; 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=ACbputX3Vw8flpy62hwYr1nChKl0HpWenlAXy02VaoU=; b=GvJiq4AMp2X1x/KYEsmLXqeMK+hKTLkYtChlfxebCLw3blu05s8AQooreWgqLtbHwJ dLLTdJ2RvtYDMS1Q9L0N4sgw1JYAETy6KDxpHocTTUx3HoIN4YeXlQ+jMFKIQ1nHr0W2 orCZf6S0M9h+f7RVOzw1fRyGtMmpiYQPNpBx3GgsbiulHmYejWQjgX0dF5XTxPuBCR4B GByWTbupkx2JaPABQbYkazYAPapfShuRf236/FNJtMgUwxmNA7k8QmkLxh56fwE90ino +Cf1cbsc32P5Ave+OzTlqBJL932yz15gxPTP2eFIvc/Kme6I36iVeellApN+0kjIcCrZ VYqg== X-Forwarded-Encrypted: i=1; AJvYcCXjIoVWPMX1d0D/xqKwHipjWFLjqfml+RZ8QhlMTgPA30jRYz/iR0DIiMAJ/RewcAGdIrtS83Y=@dpdk.org X-Gm-Message-State: AOJu0Yy04EdQ7GfWLJhYmGc38tZ2mKaZuPV0zIRoWncPBw5s8fALUjKz YfmvPIyvyIW2KxA4g4erd+IhYgjEX93Bxfj7aW7MDfdZhzdRfa7m X-Gm-Gg: ASbGncteRl/SMNk9h/LxsOzTU38djXvDTT05w8LaMjmnULS+/3GeiszD/M8w3ztJOUJ VoreF5ph3S6ruPFdZTFniDu6wuu+q91rl5yiIrJCz6A8bnAefnfUwTHBRYtLME2vfP4ZKfxb9/P Uh23K4E7nZPYS5qST7PR9MYA9gSa8yGyUBSc+cxSuLmTFXiMO44byPbdh8JYMOSiznoPBXBVMh+ 9KpRbsMQlAKntC6r8lmE3v19Zr8dAbio8SLeRYS1YS+ZhGXCnTt6vnjwshKxddKtkwLop5qqTcp C5W14/NIgxG5qPOFqpcjVw== X-Google-Smtp-Source: AGHT+IGhymJ6eKfBTe6F6ZN0rDioLJRI7r7PA7QB4JC5gWZuX/DkCYvSBMflGCPhHJemzfZYJxtHTg== X-Received: by 2002:a5d:64a7:0:b0:38d:ae1e:2f3c with SMTP id ffacd0b85a97d-38f33c2886emr10038377f8f.25.1739811900511; Mon, 17 Feb 2025 09:05:00 -0800 (PST) Received: from localhost ([2a01:4b00:d036:ae00:f83c:95e7:29fd:a997]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-38f259d5eeesm12906464f8f.63.2025.02.17.09.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 09:05:00 -0800 (PST) From: luca.boccassi@gmail.com To: Jianping Zhao Cc: Maxime Coquelin , dpdk stable Subject: patch 'vhost: clear ring addresses when getting vring base' has been queued to stable release 22.11.8 Date: Mon, 17 Feb 2025 17:03:35 +0000 Message-ID: <20250217170456.1068278-2-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250217170456.1068278-1-luca.boccassi@gmail.com> References: <20250217170456.1068278-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Hi, FYI, your patch has been queued to stable release 22.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/19/25. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/08c98824562edf4282350383ec4f55a2fe85e57f Thanks. Luca Boccassi --- >From 08c98824562edf4282350383ec4f55a2fe85e57f Mon Sep 17 00:00:00 2001 From: Jianping Zhao Date: Wed, 27 Nov 2024 10:03:49 +0800 Subject: [PATCH] vhost: clear ring addresses when getting vring base [ upstream commit 1846fe767f00a9d0dade333e7838f81e6721b694 ] 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") Signed-off-by: Jianping Zhao Reviewed-by: Maxime Coquelin --- .mailmap | 1 + lib/vhost/vhost_user.c | 1 + 2 files changed, 2 insertions(+) diff --git a/.mailmap b/.mailmap index bef76e5fd9..3127a1f91f 100644 --- a/.mailmap +++ b/.mailmap @@ -613,6 +613,7 @@ Jia He Jianbo Liu Jianfeng Tan Jiangu Zhao +Jianping Zhao Jianwei Ma Jianwei Mei Jiaqi Min diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index d665d6c7d9..6657355c2a 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -2147,6 +2147,7 @@ vhost_user_get_vring_base(struct virtio_net **pdev, rte_spinlock_lock(&vq->access_lock); vring_invalidate(dev, vq); + memset(&vq->ring_addrs, 0, sizeof(struct vhost_vring_addr)); rte_spinlock_unlock(&vq->access_lock); return RTE_VHOST_MSG_RESULT_REPLY; -- 2.47.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-02-17 16:13:16.987365371 +0000 +++ 0002-vhost-clear-ring-addresses-when-getting-vring-base.patch 2025-02-17 16:13:16.782441593 +0000 @@ -1 +1 @@ -From 1846fe767f00a9d0dade333e7838f81e6721b694 Mon Sep 17 00:00:00 2001 +From 08c98824562edf4282350383ec4f55a2fe85e57f Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 1846fe767f00a9d0dade333e7838f81e6721b694 ] + @@ -36 +37,0 @@ -Cc: stable@dpdk.org @@ -46 +47 @@ -index b90ff0444c..cc1ffe1ad9 100644 +index bef76e5fd9..3127a1f91f 100644 @@ -49 +50,2 @@ -@@ -674,6 +674,7 @@ Jianbo Liu +@@ -613,6 +613,7 @@ Jia He + Jianbo Liu @@ -51 +52,0 @@ - Jiang Yu @@ -58 +59 @@ -index 6d92ad904e..52d8078d7c 100644 +index d665d6c7d9..6657355c2a 100644 @@ -61 +62 @@ -@@ -2277,6 +2277,7 @@ vhost_user_get_vring_base(struct virtio_net **pdev, +@@ -2147,6 +2147,7 @@ vhost_user_get_vring_base(struct virtio_net **pdev, @@ -63 +64 @@ - rte_rwlock_write_lock(&vq->access_lock); + rte_spinlock_lock(&vq->access_lock); @@ -66 +67 @@ - rte_rwlock_write_unlock(&vq->access_lock); + rte_spinlock_unlock(&vq->access_lock);