[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] cxenstored: wait until after reset to notify dom0less domains


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Tue, 17 Oct 2023 01:02:29 +0000
  • Accept-language: zh-CN, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ekQvGqXYkcI8LaosjYeBIv6kfj2Eba46wW2OXj9K0zQ=; b=LfBP1gH3HqbYkL+yQVeCpDWKST0hg30zvQ6mInVoiJxEO3Z/u037f/GnAdR2fOKxDg523ddiGz4eq1Cdhtv0AinnthjskjAJeLtEAI9LG7PUnceeWBJ/yNLr/vF0pD4lPxAXQDqC7SJLUf0y0OcL5f+Tq7mAQgk68/5SUEKR6/XQCMglgACxbjo16MzKG+imFeLIAZU2waxwjdLUGLRIcz7DWg+nK2RXqz/CGSU+LmmVg8Y4c5hSo/+h+teffPUqGu2WY80+pHgsMvmcL5nA9BwsY9VuMLfalVJaE8mVnk6urJXDezmbs0pBXdR4K3ghK6I3Q/BIcr33Sr8ojKq3Vg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R/uRu7tft9X7wth+yydw1DW0FlmCYY/8mmvUDL4UEyAYlpYfBZ6vVjSxVrlKSsWHlOKC3yeIMEI9dpzLwaWeWSU5zJPRwLCzXe491pXh6LKbnpJgBmfdXnxSGGCSH+4lfg2kTtu5tSY0SKSTiZkwxlfgkZl1XD6Lsllbh9/EnVq52Nqi9VRbBb4Wxu1pAVUBFBc4NOJD9kNBL+LFlgnqtBFpXhl4/QRdOeurc2z6yEX8dvkAv8wbwrz1zkmgG9slrFMH5iEi880hqJT2Lq+v3kRjyRMqwm1kuZq5SmasWNFUuAa+YUg01fu/FDIvNEa8fxqA8jTehMFScbmx4IcNwg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxx>, "jgross@xxxxxxxx" <jgross@xxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "wl@xxxxxxx" <wl@xxxxxxx>
  • Delivery-date: Tue, 17 Oct 2023 01:02:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZ/in5rn86ZQ9wkk+3c1ZjNJ43H7BNEK2AgAAeJQA=
  • Thread-topic: [PATCH] cxenstored: wait until after reset to notify dom0less domains

Hi Stefano,

> On Oct 17, 2023, at 07:14, Stefano Stabellini <sstabellini@xxxxxxxxxx> wrote:
> 
> +Henry for release ack

Thanks, I think we did have Juergen for reviewing this patch so:

Release-acked-by: Henry Wang <Henry.Wang@xxxxxxx>

Kind regards,
Henry

> 
> 
> On Fri, 13 Oct 2023, Stefano Stabellini wrote:
>> From: George Dunlap <george.dunlap@xxxxxxxxx>
>> 
>> Commit fc2b57c9a ("xenstored: send an evtchn notification on
>> introduce_domain") introduced the sending of an event channel to the
>> guest when first introduced, so that dom0less domains waiting for the
>> connection would know that xenstore was ready to use.
>> 
>> Unfortunately, it was introduced in introduce_domain(), which 1) is
>> called by other functions, where such functionality is unneeded, and
>> 2) after the main XS_INTRODUCE call, calls domain_conn_reset().  This
>> introduces a race condition, whereby if xenstored is delayed, a domain
>> can wake up, send messages to the buffer, only to have them deleted by
>> xenstore before finishing its processing of the XS_INTRODUCE message.
>> 
>> Move the connect-and-notfy call into do_introduce() instead, after the
>> domain_conn_rest(); predicated on the state being in the
>> XENSTORE_RECONNECT state.
>> 
>> (We don't need to check for "restoring", since that value is always
>> passed as "false" from do_domain_introduce()).
>> 
>> Also take the opportunity to add a missing wmb barrier after resetting
>> the indexes of the ring in domain_conn_reset.
>> 
>> This change will also remove an extra event channel notification for
>> dom0 (because the notification is now done by do_introduce which is not
>> called for dom0.) The extra dom0 event channel notification was only
>> introduced by fc2b57c9a and was never present before. It is not needed
>> because dom0 is the one to tell xenstored the connection parameters, so
>> dom0 has to know that the ring page is setup correctly by the time
>> xenstored starts looking at it. It is dom0 that performs the ring page
>> init.
>> 
>> Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxx>
>> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
>> CC: jgross@xxxxxxxx
>> CC: julien@xxxxxxx
>> CC: wl@xxxxxxx
>> ---
>> tools/xenstored/domain.c | 14 ++++++++------
>> 1 file changed, 8 insertions(+), 6 deletions(-)
>> 
>> diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
>> index a6cd199fdc..f6ef37856c 100644
>> --- a/tools/xenstored/domain.c
>> +++ b/tools/xenstored/domain.c
>> @@ -923,6 +923,7 @@ static void domain_conn_reset(struct domain *domain)
>> 
>> domain->interface->req_cons = domain->interface->req_prod = 0;
>> domain->interface->rsp_cons = domain->interface->rsp_prod = 0;
>> + xen_wmb();
>> }
>> 
>> /*
>> @@ -988,12 +989,6 @@ static struct domain *introduce_domain(const void *ctx,
>> /* Now domain belongs to its connection. */
>> talloc_steal(domain->conn, domain);
>> 
>> - if (!restore) {
>> - /* Notify the domain that xenstore is available */
>> - interface->connection = XENSTORE_CONNECTED;
>> - xenevtchn_notify(xce_handle, domain->port);
>> - }
>> -
>> if (!is_master_domain && !restore)
>> fire_special_watches("@introduceDomain");
>> } else {
>> @@ -1033,6 +1028,13 @@ int do_introduce(const void *ctx, struct connection 
>> *conn,
>> 
>> domain_conn_reset(domain);
>> 
>> + if (domain->interface != NULL &&
>> + domain->interface->connection == XENSTORE_RECONNECT) {
>> + /* Notify the domain that xenstore is available */
>> + domain->interface->connection = XENSTORE_CONNECTED;
>> + xenevtchn_notify(xce_handle, domain->port);
>> + }
>> +
>> send_ack(conn, XS_INTRODUCE);
>> 
>> return 0;
>> -- 
>> 2.25.1
>> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.