From patchwork Fri Dec 21 16:26:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 154405 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1117741ljp; Fri, 21 Dec 2018 08:28:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/WJtmH7U22qBOCQHg/yH8zJsaIQQMP1+Nm899gbfEoAPTiYMM5FAGP7gFlFLvMfes3Xbprj X-Received: by 2002:a81:6e43:: with SMTP id j64mr3192072ywc.171.1545409739214; Fri, 21 Dec 2018 08:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545409739; cv=none; d=google.com; s=arc-20160816; b=v+km4ILbRu5n2zNoHqSoqnzHl0Gm6e7sNHWe5zq2DI+f7xUoka0iEooPiBmdr68P7I yhj3cpDgmYpTSBDWUGLpvaR0cMKbdM9BTYlAxv507kEJw+7+P8SZgyk+zHuT5LHSnK2n nsK6lzaGkx7QdHNg9T4EqagE4fVClbwglLJD2sxAOn4TiAu9UzVGeZEYmMydwRAINMNg E5nYbxIQjgx3h07yNFI/CAPMSrZok27Lgvq0PufL9p4tsK3vvUZsu8riz9K7+3UUJxfW Bf0Oe4Kt5ciiBIcRiaQ7YRWHR6gO2zF0/J3AOhgk2ollCzdYrsqZsFiENTN+C4eVLwOw AwrQ== 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=yan0dKRAF8JVh7bjSZQPU5BTd04hlkvCc3n1yzE7rAk=; b=c0iWqw3SaH53955T1g2xQ4SnBtuJBb58MTJuYJQA7C8ABkT59d9WJtJcVyxvD85oNh pSg6UnFBPBa52B7Mbx7dF/xpBue4udu2C0YLOJrGpTr5pvy2jYdybH/Yyr0byA6Myj+2 SKfIYoxByJJg1I9YuPudsJmCXh4IxpabWD5QQW0FBzHVQ00wavmzqARoK/cjUfq+k5/Y XHTUtXI0php5M9T6zlFPpYKRtMn/uN3aW7gKyjEWjl+c7KUm/lhp8adegm5BvhPxIvko sMnER4HsKopz0NwBK8xoJDVEZb/k+G41lpj9mpsxQpjiuW7NEtItI/jOOfz04oDW/9ws CWFg== 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 a17si14903208ybq.294.2018.12.21.08.28.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Dec 2018 08:28:59 -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 1gaNdi-00068W-Rj; Fri, 21 Dec 2018 16:27:06 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gaNdh-00067o-CM for xen-devel@lists.xenproject.org; Fri, 21 Dec 2018 16:27:05 +0000 X-Inumbo-ID: 40a32dd0-053d-11e9-8e1d-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 40a32dd0-053d-11e9-8e1d-bc764e045a96; Fri, 21 Dec 2018 16:27:04 +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 8A00D1596; Fri, 21 Dec 2018 08:27:04 -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 BE9DB3F5C0; Fri, 21 Dec 2018 08:27:03 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 21 Dec 2018 16:26:46 +0000 Message-Id: <20181221162650.11515-5-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 4/8] xen/arm: Make get_page_from_gfn working with 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 MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" DOMID_XEN is used to share pages beloging to the hypervisor (e.g trace buffers). Unlike other domains, DOMID_XEN is a non-auto translated domain and therefore does not have a P2M. This patch adds a special case for DOMID_XEN in get_page_from_gfn. We may want to provide "non-auto translated helpers" in the future if we see more case. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov --- Changes in v3: - Split from "xen/arm: Add support for read-only foreign mappings" - Use likely rather than unlikely - Fix typoes --- xen/include/asm-arm/p2m.h | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index a03a033a05..041dea827c 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -300,7 +300,38 @@ struct page_info *p2m_get_page_from_gfn(struct domain *d, gfn_t gfn, static inline struct page_info *get_page_from_gfn( struct domain *d, unsigned long gfn, p2m_type_t *t, p2m_query_t q) { - return p2m_get_page_from_gfn(d, _gfn(gfn), t); + mfn_t mfn; + p2m_type_t _t; + struct page_info *page; + + /* + * Special case for DOMID_XEN as it is the only domain so far that is + * not auto-translated. + */ + if ( likely(d != dom_xen) ) + return p2m_get_page_from_gfn(d, _gfn(gfn), t); + + if ( !t ) + t = &_t; + + *t = p2m_invalid; + + /* + * DOMID_XEN sees 1-1 RAM. The p2m_type is based on the type of the + * page. + */ + mfn = _mfn(gfn); + page = mfn_to_page(mfn); + + if ( !mfn_valid(mfn) || !get_page(page, d) ) + return NULL; + + if ( page->u.inuse.type_info & PGT_writable_page ) + *t = p2m_ram_rw; + else + *t = p2m_ram_ro; + + return page; } int get_page_type(struct page_info *page, unsigned long type);