From nobody Sat May 4 11:52:43 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; 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=1588089137; cv=none; d=zohomail.com; s=zohoarc; b=EwQzF/+g/7R8JvOt1nrGAGlW4+AuJu2Tw7ww+P8ce+VuewKAzOFR/Gcl2kp19mrz1lqywUO7VJp8PqOEyeCWVqNl/+IRzQ5W3AkdJS/+uTWAQbSgJCd8LhB8pu1DAROczalBiGVXB7FCMRiYCGsgd7qHrWfMMiDugoslKSinPbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588089137; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=o6oFGm/AnMMzaGz+3o6pTbcgmUVIZdGrzPqhm6YyLKU=; b=Gb99+njgaPlNFHMVxE214/lp2+SIBOHTcx7hX9lnEcfMT3vAUYy53XZJ17WjvXj9QpYxaEOTvY9JT4cOhywrCQN4mD+m7VbEvuuwDaEPgLEcMdPGb3Xj8pTkFXp+ygOG0loK7p8WOAOUFPvJdBk0Gg5sfPl88Cl2VWVMhLrL8fY= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1588089137410273.12490142424394; Tue, 28 Apr 2020 08:52:17 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTSWU-00081d-M5; Tue, 28 Apr 2020 15:51:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTSWT-00081Y-Gy for xen-devel@lists.xenproject.org; Tue, 28 Apr 2020 15:51:49 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2b4cbcde-8968-11ea-9887-bc764e2007e4; Tue, 28 Apr 2020 15:51:48 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2BA73AC85; Tue, 28 Apr 2020 15:51:47 +0000 (UTC) X-Inumbo-ID: 2b4cbcde-8968-11ea-9887-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Subject: [PATCH] tools/xenstore: don't store domU's mfn of ring page in xensotred Date: Tue, 28 Apr 2020 17:51:44 +0200 Message-Id: <20200428155144.8253-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The XS_INTRODUCE command has two parameters: the mfn (or better: gfn) of the domain's xenstore ring page and the event channel of the domain for communicating with Xenstore. The gfn is not really needed. It is stored in the per-domain struct in xenstored and in case of another XS_INTRODUCE for the domain it is tested to match the original value. If it doesn't match the command is aborted via EINVAL. Today there shouldn't be multiple XS_INTRODUCE requests for the same domain issued, so the mfn/gfn can just be ignored and multiple XS_INTRODUCE commands can be rejected without testing the mfn/gfn. Signed-off-by: Juergen Gross Acked-by: Andrew Cooper --- tools/xenstore/xenstored_domain.c | 47 ++++++++++++++++-------------------= ---- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index 5858185211..17328f9fc9 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -369,7 +369,6 @@ int do_introduce(struct connection *conn, struct buffer= ed_data *in) struct domain *domain; char *vec[3]; unsigned int domid; - unsigned long mfn; evtchn_port_t port; int rc; struct xenstore_domain_interface *interface; @@ -381,7 +380,7 @@ int do_introduce(struct connection *conn, struct buffer= ed_data *in) return EACCES; =20 domid =3D atoi(vec[0]); - mfn =3D atol(vec[1]); + /* Ignore the mfn, we don't need it. */ port =3D atoi(vec[2]); =20 /* Sanity check args. */ @@ -390,34 +389,26 @@ int do_introduce(struct connection *conn, struct buff= ered_data *in) =20 domain =3D find_domain_by_domid(domid); =20 - if (domain =3D=3D NULL) { - interface =3D map_interface(domid); - if (!interface) - return errno; - /* Hang domain off "in" until we're finished. */ - domain =3D new_domain(in, domid, port); - if (!domain) { - rc =3D errno; - unmap_interface(interface); - return rc; - } - domain->interface =3D interface; - domain->mfn =3D mfn; - - /* Now domain belongs to its connection. */ - talloc_steal(domain->conn, domain); - - fire_watches(NULL, in, "@introduceDomain", false); - } else if ((domain->mfn =3D=3D mfn) && (domain->conn !=3D conn)) { - /* Use XS_INTRODUCE for recreating the xenbus event-channel. */ - if (domain->port) - xenevtchn_unbind(xce_handle, domain->port); - rc =3D xenevtchn_bind_interdomain(xce_handle, domid, port); - domain->port =3D (rc =3D=3D -1) ? 0 : rc; - domain->remote_port =3D port; - } else + if (domain) return EINVAL; =20 + interface =3D map_interface(domid); + if (!interface) + return errno; + /* Hang domain off "in" until we're finished. */ + domain =3D new_domain(in, domid, port); + if (!domain) { + rc =3D errno; + unmap_interface(interface); + return rc; + } + domain->interface =3D interface; + + /* Now domain belongs to its connection. */ + talloc_steal(domain->conn, domain); + + fire_watches(NULL, in, "@introduceDomain", false); + domain_conn_reset(domain); =20 send_ack(conn, XS_INTRODUCE); --=20 2.16.4