From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202502 header.b=OqGsqHzd; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id B3E4A5A0638 for ; Fri, 14 Feb 2025 14:08:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1739538527; bh=woNCfVrKmZmiQJyK/BMX0nGFFyp1PkoFb8bv+oOFJ6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OqGsqHzdapXS4aTbnPB+IgYbj8ZvOCVNQ5bW/XsRrgbNbaRoFlU2eEzhLVzjlBjfs JSb4BSr2FAjc2szWIPto1zVukXwHEt6a6bnL6IiRiUe9QFS9wZxGwsKLted52WIDtc oqM5Zc7YS68Qhk9Qk21AbiNFJkT7BiygTCwMJA7tVSvPjZzlVhA2ctxu0fRyZubXgh WNONwMpsgkG6UTV/8+eTL2KtWyCRojgmwL0/PKkYg82e7fXBIWwxyu2EkBr+SykStI GFYiUKnsfZPLEsZiYg2Z0MbNFkDOc9keC4az6/GOkRkEP75faYxSADGHBmx/wbpYbo IpNAlBABDJ5RQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4YvXRz6hTgz4wvg; Sat, 15 Feb 2025 00:08:47 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v24 1/5] vhost_user: Clear ring address on GET_VRING_BASE Date: Sat, 15 Feb 2025 00:08:41 +1100 Message-ID: <20250214130845.3475757-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214130845.3475757-1-david@gibson.dropbear.id.au> References: <20250214130845.3475757-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: BYRFARXMYHSPQQAVUVQB4MZTZCSMIKHD X-Message-ID-Hash: BYRFARXMYHSPQQAVUVQB4MZTZCSMIKHD X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: GET_VRING_BASE stops the queue, clearing the call and kick fds. However, we don't clear vring.avail. That means that if vu_queue_notify() is called it won't realise the queue isn't ready and will die with an EBADFD. We get this during migration, because for some reason, qemu reconfigures the vhost-user device when a migration is triggered. There's a window between the GET_VRING_BASE and re-establishing the call fd where the notify function can be called, causing a crash. Signed-off-by: David Gibson --- vhost_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vhost_user.c b/vhost_user.c index 7ab13774..be1aa942 100644 --- a/vhost_user.c +++ b/vhost_user.c @@ -732,6 +732,7 @@ static bool vu_get_vring_base_exec(struct vu_dev *vdev, msg->hdr.size = sizeof(msg->payload.state); vdev->vq[idx].started = false; + vdev->vq[idx].vring.avail = 0; if (vdev->vq[idx].call_fd != -1) { close(vdev->vq[idx].call_fd); -- 2.48.1