From patchwork Thu Dec 20 19:23:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 154361 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp50609ljp; Thu, 20 Dec 2018 11:26:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/V9EAqZoz1AgjXrwYNnmBhUSa5Vrls6ZCMpb450QrdZGlU1hzu5byZ0nIGo9j27M2udn7Xc X-Received: by 2002:a25:8311:: with SMTP id s17mr26487408ybk.84.1545333965908; Thu, 20 Dec 2018 11:26:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545333965; cv=none; d=google.com; s=arc-20160816; b=BOdsCE18G3XnwKB1HHtYxmYfeyQWHSgFHtgwXOsQV7W2s2y+s/NqOtF4K7GqTTYqoy BupmjrQ/vIM3nWi0Dj7Qa/r/1DSt24f7c9SeobJmDNHUX6b2/gFxxgupph5zCYPaO6EP gELFB/9W4h101Mg8tkkhmcjyQA/LAMFUXfoEm8hpDbgeiKCzDCAaINp+BERzUCsIlfQb NhTRO9HSDIyHX8jb+OG5N4enHXzTAgZe7RNLxejQ7FAx61rm7e8+6rivrrdS68SqKAf1 vRnbRy7ZYSj/Km7QHhebbziEaix0xP+uekgdz2z5FFubASDhaUas8x1OTsY6nWmKv5MU qehw== 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=yJZLfYCUpu/oFcmMt6cNV+cfM2S0FYrBbGLdYfff7fc=; b=UV9+msRZs9H679X7sIClR64a8AeI7yLlr4yjqKOgZ+u7bD6/FImlswn1RKrWQymz0R j10lQ3Z/bA+f8IvHAqdJg/70UxU2fq3N9NSqUCzp3Ei2VSlTV9fQmJc6d4mzdpzvQwBo cKpJwJSP14iV3+v/aAUV8OjF1RNH/jvDiakiRLTp4zuGVJKs/kHHcGVyow9FA57IAxG7 uSa9MjBqS/5tWYVZklnWrfjlSmr+cyDaq4yLzGuAJxNZsbEAhXghU1cw2d/vsbJbV2a/ m+hwArm533ZFf+JOdDGfyEcOSkPB3Xbo78/HHgh1IV8rQyMlRQ5NwiKjArwv5bSI40AI 94EQ== 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 129-v6si12977683ybo.302.2018.12.20.11.26.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Dec 2018 11:26: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 1ga3vI-0001yB-CR; Thu, 20 Dec 2018 19:23:56 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ga3vH-0001xr-Av for xen-devel@lists.xenproject.org; Thu, 20 Dec 2018 19:23:55 +0000 X-Inumbo-ID: c9f01d2a-048c-11e9-8e1d-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id c9f01d2a-048c-11e9-8e1d-bc764e045a96; Thu, 20 Dec 2018 19:23:54 +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 D981E15AD; Thu, 20 Dec 2018 11:23:53 -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 EB0683F575; Thu, 20 Dec 2018 11:23:52 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 20 Dec 2018 19:23:35 +0000 Message-Id: <20181220192338.17526-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181220192338.17526-1-julien.grall@arm.com> References: <20181220192338.17526-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.12 v2 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 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 Reviewed-by: Stefano Stabellini --- 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 58f7e54640..49d7a76aa2 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,21 +1255,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: