From patchwork Fri Dec 21 16:26:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 154411 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1117851ljp; Fri, 21 Dec 2018 08:29:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wc7yagJ26H/pjmtvLUqRS1eUekHivuufQ2AVyT6LRvQ0A6yjoqIq9tWAuChE6Ci3BkWbOz X-Received: by 2002:a25:dcf:: with SMTP id 198mr3121732ybn.518.1545409745189; Fri, 21 Dec 2018 08:29:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545409745; cv=none; d=google.com; s=arc-20160816; b=vY7SZlpP56aN0aW8pUVkrSqS7yaX+20FP4M9mnb08DMy0y2HnZJl9A56BnAD2eQPQs x8Lq5sVHgcJ4b7wLKwVJ5EdLYjodet0LLeudIHfohZsgpyneIR/Kuh7taDb5NsyMPwaE f2c7djG5hU5xma4zbw5k56+k5I6O7zGZGUZatbP9o4epApEBUZtVk8XknoKeWJVN+Fi2 y3w9F7GqGKLFTjIHL6OZmcCKRuBG6thfdVu+MNTK2XSj0w1qipvClo3iG4c/VFDNbx0Y iQRXAdIt7dQTp+qz86wFuwJnPFIOuWrhi2JZnsy+qdxT0AklpFIWgaK2W54mey/xZKZ3 9o0w== 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=+vobpsGgNlJjXShc4jKD2JEJiqQxv/2g6acEBJYP75k=; b=PTy3y9qvjckEdSX6PdsbQfB4CnNyWsF/kV6C/z3P66mqpVjFMoy6h/N4ZOhwuO2uzs 1ZMu7Y8ZiYGK6TfM53x6UsaFdWGEkS9+Xu7cYnUynjgdARbP/6X7qs/tLXKPumUBzPsp XxFEVLx62KZJ8fwLwpMt9sL2kVIDV/GDUnntvLQm5J9pJpVBYbDxUI6oYEU3VlSmcGcf ZuMkqc+Jp1s2yaxUbax56LA5VYLK9T52YT/cAx1dVDRbT9GFkQmGdgb5kXxRwGfWRsDg hdL1xNULyxG4ceerUwS8YC5VtBtjqAdsz3EDeE0YM03fL6NWSHm/lKBTzmUTByY97/Cy oSGQ== 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 d20si12798755ybc.113.2018.12.21.08.29.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Dec 2018 08:29:05 -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 1gaNdj-00069C-4K; Fri, 21 Dec 2018 16:27:07 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gaNdi-00068O-PJ for xen-devel@lists.xenproject.org; Fri, 21 Dec 2018 16:27:06 +0000 X-Inumbo-ID: 415d5816-053d-11e9-8e1d-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 415d5816-053d-11e9-8e1d-bc764e045a96; Fri, 21 Dec 2018 16:27:06 +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 B3957EBD; Fri, 21 Dec 2018 08:27:05 -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 C4D5F3F5C0; Fri, 21 Dec 2018 08:27:04 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 21 Dec 2018 16:26:47 +0000 Message-Id: <20181221162650.11515-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181221162650.11515-1-julien.grall@arm.com> References: <20181221162650.11515-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.12 v3 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 , sstabellini@kernel.org, Andrii Anisov MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" For auto-translated domain, the only way to map a page to itself is the using the foreign map API. The current code does not allow mapping page from special page (such as DOMID_XEN). As xentrace buffers 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 Reviewed-by: Stefano Stabellini --- Changes in v3: - Add Stefano's reviewed-by - Fix typoes Changes in v2: - Add Andrii's reviewed-by --- 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 3bf11eec4f..01ae2cccc0 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1233,20 +1233,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; } @@ -1255,7 +1255,7 @@ 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; } @@ -1264,13 +1264,13 @@ int xenmem_add_to_physmap_one( else { put_page(page); - rcu_unlock_domain(od); + put_pg_owner(od); return -EINVAL; } mfn = page_to_mfn(page); - rcu_unlock_domain(od); + put_pg_owner(od); break; } case XENMAPSPACE_dev_mmio: