From patchwork Tue Nov 6 19:14:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 150345 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4274053ljp; Tue, 6 Nov 2018 11:17:22 -0800 (PST) X-Google-Smtp-Source: AJdET5eY+swI6ZNOWogmXiNrEvbnQgx+ebX8E0PmnVmiUgN6ZEs9xK2uqWVJU83mKV5OBBANFcGc X-Received: by 2002:a81:441e:: with SMTP id r30-v6mr26249501ywa.48.1541531842207; Tue, 06 Nov 2018 11:17:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541531842; cv=none; d=google.com; s=arc-20160816; b=AI2b9bMyT/2PdVGbi/4Fa18PnRT2FPwS3l1LdbWR+h9pM+YWlV/VxyNLdRFGofSUdx /sk/MWQ9+XbEUr5QvbtSchTU7x/g63pe+x6kThVg8rFn2sPwevliGgqZ3mcd7ll095t5 JFvMB2Q7xfSmgunOp+Vf+lptr1gsiyPFKA93QXqGOKo39b5uDisPJ9pSLAP2e9muouwy 1BfNqgCz1w82vorzz+gejDxoT4Tn1Hw/Skl3UI4fYeDzp3d6JsYkSZVUIA1UNmu/3ssb xWwhQGPqgTcA+T30xen6NvseDpSilSAMbo2xGcfv+kUanFKkTW1Ezy43gs4lBAvxBxDb DhtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=5KBQRzf5WvRCGVMJlo/WgFDMYU7atSxiPnLtxslgGP0=; b=MZ/1dLZV2jkfV2wOVY8ISSXBvj90MWRcTNlTUIAX+2MFLG+ANI4lc2ed2QsZ7t+Es6 081YC+7cGZo1aUpUpBWGIctQh2ZOuX6zBMImUeN9oCo33gwAXilYUszcI2Bv3pI6cSWa +Npxdr857sHVJanakV0XbC1TDXw2VQ1oOIdZ8+GUK8FsF95YzTc3nJ8jgVWUkEunuofP pwJlQjuN63XLNJONgqVRK/wkw97PDDTvat46ZIl6Xf6pxeow6Y0EugyEdc3XoBlS5maD TmhqPhSGcvzjxVyPPZzzrU24zwbSaUb2liCi93465r7+A+OmnfXSrRlkUhT4Jw5h2U6h ibVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@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.google.com with ESMTPS id z6-v6si4387312ybg.136.2018.11.06.11.17.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Nov 2018 11:17:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gK6oi-0003cv-HL; Tue, 06 Nov 2018 19:15:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gK6oh-0003cb-9q for xen-devel@lists.xenproject.org; Tue, 06 Nov 2018 19:15:11 +0000 X-Inumbo-ID: 475798a4-e1f8-11e8-b36e-12d6303a7972 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 475798a4-e1f8-11e8-b36e-12d6303a7972; Tue, 06 Nov 2018 19:15:10 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A8DA5EBD; Tue, 6 Nov 2018 11:15:09 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7E9C3F718; Tue, 6 Nov 2018 11:15:08 -0800 (PST) From: Julien Grall To: sstabellini@kernel.org, xen-devel@lists.xenproject.org Date: Tue, 6 Nov 2018 19:14:51 +0000 Message-Id: <20181106191454.22143-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181106191454.22143-1-julien.grall@arm.com> References: <20181106191454.22143-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 5/8] xen/arm: Allow a privileged domain to map foreign page from DOMID_XEN X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" For auto-translated domain, the only way to map page to itself is the using foreign map API. The current code does not allow mapping page from special page (such as DOMID_XEN). As xentrace buffer are shared using DOMID_XEN, it is not possible to use tracing for Arm. This could be solved by using the helper get_pg_owner(). This helper will be able to get a reference on DOMID_XEN and therefore allow mapping for privileged domain. This patch replace the call to rcu_lock_domain_by_any_id() with get_pg_owner(). For consistency, all the call to rcu_unlock_domain are replaced by put_pg_owner(). Signed-off-by: Julien grall Reviewed-by: Andrii Anisov --- xen/arch/arm/mm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index e31b47a394..72d0285768 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1249,20 +1249,20 @@ int xenmem_add_to_physmap_one( struct domain *od; p2m_type_t p2mt; - od = rcu_lock_domain_by_any_id(extra.foreign_domid); + od = get_pg_owner(extra.foreign_domid); if ( od == NULL ) return -ESRCH; if ( od == d ) { - rcu_unlock_domain(od); + put_pg_owner(od); return -EINVAL; } rc = xsm_map_gmfn_foreign(XSM_TARGET, d, od); if ( rc ) { - rcu_unlock_domain(od); + put_pg_owner(od); return rc; } @@ -1271,21 +1271,21 @@ int xenmem_add_to_physmap_one( page = get_page_from_gfn(od, idx, &p2mt, P2M_ALLOC); if ( !page ) { - rcu_unlock_domain(od); + put_pg_owner(od); return -EINVAL; } if ( !p2m_is_ram(p2mt) ) { put_page(page); - rcu_unlock_domain(od); + put_pg_owner(od); return -EINVAL; } mfn = page_to_mfn(page); t = (p2mt == p2m_ram_rw) ? p2m_map_foreign_rw : p2m_map_foreign_ro; - rcu_unlock_domain(od); + put_pg_owner(od); break; } case XENMAPSPACE_dev_mmio: