From nobody Wed Nov 27 11:37:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1699267235; cv=none; d=zohomail.com; s=zohoarc; b=QbCgA+MoBGFtGDzFYmBsBykw3hGjhFZhkJFYui8YE4SZPooydEYpzrPiWz0vYAqQiIwQmDRExJFE+akNj8xDOfzEgmnD3obgBvtADSKpdNFfnk4uB6PBmx7nGlCk/Vi2b98T2jLhab1AXwpCXwrrqXAxgXgkKzSHJRJRVEIK7Cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699267235; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2aX82uZpC1qyK8a13DdVvtrvr4nDdAxx84xCzWlWkQE=; b=gJvbSlFWdF8HKT7Jq7u0rtUAOMTDBUNaiOSsaCjrf+zURC/343cAtYFPHLHbkvHQfA7X/UIiGnOenEHIEnqWVK6ZvAOmFq4YYOegLGAbgvsm98VMDF/w/hhwBJjnlNgPCJeIpIv0w/jh1O8PdAT7XZ0IyhRJ5f2zNWjBg8aXFjA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1699267235937853.9414002729476; Mon, 6 Nov 2023 02:40:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.627881.978768 (Exim 4.92) (envelope-from ) id 1qzx1i-0001dg-2C; Mon, 06 Nov 2023 10:40:14 +0000 Received: by outflank-mailman (output) from mailman id 627881.978768; Mon, 06 Nov 2023 10:40:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1h-0001a9-QM; Mon, 06 Nov 2023 10:40:13 +0000 Received: by outflank-mailman (input) for mailman id 627881; Mon, 06 Nov 2023 10:40:12 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qzx1g-00010q-CY for xen-devel@lists.xenproject.org; Mon, 06 Nov 2023 10:40:12 +0000 Received: from desiato.infradead.org (desiato.infradead.org [2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id db10bb24-7c90-11ee-98da-6d05b1d4d9a1; Mon, 06 Nov 2023 11:40:09 +0100 (CET) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qzx1R-00ARzw-0T; Mon, 06 Nov 2023 10:39:57 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96.2 #2 (Red Hat Linux)) id 1qzx1Q-000qGD-0J; Mon, 06 Nov 2023 10:39:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: db10bb24-7c90-11ee-98da-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description; bh=2aX82uZpC1qyK8a13DdVvtrvr4nDdAxx84xCzWlWkQE=; b=Lsa03UYsBW/tPFhN+jMR5L26U/ TVzIcfwnVOKWq5iVAbYsqR6CCu2/cqD2aOvhXmFK94xOl7AaqnrWzCxnvgNIK+qbGL3dSymFt2T1w TxnN1TH0mJkh1qzM/BhXXPzV7ivfJRv24SyfrEi9Wn71X/x5BxUf3616HSSSnHGXSzY5RLRicYzGq 7YwIXlaz/0icDCQWAP1xDbdRgUrI64/oY3c6TeFVPJwinCYCKUzxgRZ0K+HaQk+yAufoKx5SztD5n PuPTmD1h8oBzywh7Jh1H9fiiYouwogazRnsvbqM526NkjyZpNfe1bEFjOBIPG7UHC0kDEpTVLKQW6 aL2RWHyQ==; From: David Woodhouse To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , Kevin Wolf , Hanna Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , xen-devel@lists.xenproject.org, qemu-block@nongnu.org, kvm@vger.kernel.org Subject: [PULL 5/7] hw/xen: fix XenStore watch delivery to guest Date: Mon, 6 Nov 2023 10:39:53 +0000 Message-ID: <20231106103955.200867-6-dwmw2@infradead.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231106103955.200867-1-dwmw2@infradead.org> References: <20231106103955.200867-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1699267236866100001 From: David Woodhouse When fire_watch_cb() found the response buffer empty, it would call deliver_watch() to generate the XS_WATCH_EVENT message in the response buffer and send an event channel notification to the guest=E2=80=A6 without actually *copying* the response buffer into the ring. So there was nothing for the guest to see. The pending response didn't actually get processed into the ring until the guest next triggered some activity from its side. Add the missing call to put_rsp(). It might have been slightly nicer to call xen_xenstore_event() here, which would *almost* have worked. Except for the fact that it calls xen_be_evtchn_pending() to check that it really does have an event pending (and clear the eventfd for next time). And under Xen it's defined that setting that fd to O_NONBLOCK isn't guaranteed to work, so the emu implementation follows suit. This fixes Xen device hot-unplug. Cc: qemu-stable@nongnu.org Fixes: 0254c4d19df ("hw/xen: Add xenstore wire implementation and implement= ation stubs") Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_xenstore.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index 660d0b72f9..8e716a7009 100644 --- a/hw/i386/kvm/xen_xenstore.c +++ b/hw/i386/kvm/xen_xenstore.c @@ -1357,10 +1357,12 @@ static void fire_watch_cb(void *opaque, const char = *path, const char *token) } else { deliver_watch(s, path, token); /* - * If the message was queued because there was already ring activi= ty, - * no need to wake the guest. But if not, we need to send the evtc= hn. + * Attempt to queue the message into the actual ring, and send + * the event channel notification if any bytes are copied. */ - xen_be_evtchn_notify(s->eh, s->be_port); + if (s->rsp_pending && put_rsp(s) > 0) { + xen_be_evtchn_notify(s->eh, s->be_port); + } } } =20 --=20 2.41.0