[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 05/13] xen/arm: introduce get_pages_from_gfn
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Penny Zheng <Penny.Zheng@xxxxxxx>
- Date: Fri, 11 Mar 2022 14:11:15 +0800
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2tUy/0RXwgpLcKCk4dgzOJCVdOMJ/pIH58P1Z/r+6Ms=; b=m/k3EKXbeVect56qh7hRMes04UP22AwB/5bsntYqaFi+jkxxNdh9zYBVHWLg9t6R80nFi2AIK3WdvRn5fwu9TQn4OCVNIH1iAw6d1K1dv3bXDwr/GRLoOsj+6SZrV+0hsKcuSGQXvAMCG91dvoT7e88qLzX7XHx7puMpN+cw5XPUsMO6FeIu0racbAC2rlBjAe1SSPgwoNEHTN46g24vDY21kCmqbdBYH7cPY9QmlwA5aaAfB2KabJPUdRint8w18UUa/8ebuFBbvYGZaKCqe3bFVYDXrEk7xfKC8HA8SdkmaaO9Qbyla6Adsm1N4+6LgYCHR4w8/+VIGfeIBIMGcg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nz2IqV+9TTz6sdPjRlH6hcPMppdkxe4txsu3HLjSwiekouz6gLpEj7GXg46Ym04eq7myHhRRIsBbAeiFqd6aIfNXOFRulb/KlKiyI6YB20kScu6ZxuqE9Q+jgAJz8b8wyCM/i5MovcbnOTog8L+P1ox1dNNSfdp0aIS9PEwWbhEysRufraSGZQpnOv5Q0LOgA+WQEV2Zko077JEjjXUO2dAfbWdNjhPwMKgk417O/Nogn5f1JzsU/XQCd/G00UfIkaDVtJZAMiMaxLrkWZ36h3ckT+WzU6rXckGyd8rY+osF7RUMvyrmYI6i0WISujIhPQcG7vp57hABTfJDXDoxNQ==
- Cc: <nd@xxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Fri, 11 Mar 2022 06:12:54 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
From: Penny Zheng <penny.zheng@xxxxxxx>
In order to getting statically shared pages based on gfn with nr_pages, this
commit introduces a new helper get_pages_from_gfn to acquire a set of pages
based on [gfn, gfn + nr_gfns), with the same P2M type.
Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
---
xen/arch/arm/include/asm/p2m.h | 37 ++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h
index 58590145b0..b23024b9a1 100644
--- a/xen/arch/arm/include/asm/p2m.h
+++ b/xen/arch/arm/include/asm/p2m.h
@@ -370,6 +370,43 @@ static inline struct page_info *get_page_from_gfn(
return page;
}
+static inline int get_pages_from_gfn(struct domain *d, unsigned long gfn,
+ unsigned long nr_gfns,
+ struct page_info **pages, p2m_type_t *t,
+ p2m_query_t q)
+{
+ p2m_type_t _t;
+ unsigned long i = 0;
+ int ret = 0;
+
+ for ( ; i < nr_gfns; i++ )
+ {
+ pages[i] = get_page_from_gfn(d, gfn + i, t, q);
+
+ if ( !pages[i] )
+ {
+ ret = -ENOENT;
+ goto fail_get;
+ }
+
+ if ( i == 0 )
+ _t = *t;
+ /* Check if all pages share the same p2m type. */
+ else if ( *t != _t )
+ {
+ ret = -EINVAL;
+ goto fail_get;
+ }
+ }
+
+ return ret;
+
+ fail_get:
+ while( --i >= 0 )
+ put_page(pages[i]);
+ return ret;
+}
+
int get_page_type(struct page_info *page, unsigned long type);
bool is_iomem_page(mfn_t mfn);
static inline int get_page_and_type(struct page_info *page,
--
2.25.1
|