From patchwork Wed Jul 6 13:01:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 71453 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp853983qgy; Wed, 6 Jul 2016 06:03:57 -0700 (PDT) X-Received: by 10.36.120.71 with SMTP id p68mr20022729itc.46.1467810237679; Wed, 06 Jul 2016 06:03:57 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id j67si883149ith.44.2016.07.06.06.03.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2016 06:03:57 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKmST-0000KP-Ep; Wed, 06 Jul 2016 13:01:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKmSR-0000HS-MU for xen-devel@lists.xen.org; Wed, 06 Jul 2016 13:01:39 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id E2/33-16470-3310D775; Wed, 06 Jul 2016 13:01:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTdeIsTb cYNMOVYslHxezODB6HN39mymAMYo1My8pvyKBNePyrNMsBWflKu6vbWFtYHwp1sXIxSEksIlR 4v3W38wQzmlGiVlvd7B2MXJysAloStz5/IkJxBYRkJa49vkyI4jNLOAg8ebjPRYQW1ggRKLl1 0mwGhYBVYkHXx+wg9i8Aq4Sb35cBItLCMhJnDw2GWwmJ1B8+rXHYDVCAi4S2xdPYp7AyL2AkW EVo3pxalFZapGuqV5SUWZ6RkluYmaOrqGBsV5uanFxYnpqTmJSsV5yfu4mRqB/6xkYGHcwXv7 qdIhRkoNJSZSX5Vt1uBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3ob/NeFCgkWp6akVaZk5wECD SUtw8CiJ8D4CSfMWFyTmFmemQ6ROMSpKifN2giQEQBIZpXlwbbDgvsQoKyXMy8jAwCDEU5Bal JtZgir/ilGcg1FJmPfmP6ApPJl5JXDTXwEtZgJa/NOlGmRxSSJCSqqBUdD1RrRfrq8LO4/Tlw cGH8r/G6oqLLiv8XhKy4zjHv6XXNIdzy6/wLdfWyh/YWup7IenX59dv6Tcx9+z7iir/Ovd+58 XrL79ZdKc9c9qLi+/Lnup5ZepzaVGozkVNjsea5YHz2xICfjxff6hg3ZXNrDVZrRLO9XVTH/5 I6js9T4TznW324v9SpRYijMSDbWYi4oTAQw/+G1pAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1467810093!32456182!5 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9204 invoked from network); 6 Jul 2016 13:01:38 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-31.messagelabs.com with SMTP; 6 Jul 2016 13:01:38 -0000 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 D4BDABB4; Wed, 6 Jul 2016 06:02:36 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 560AA3F21A; Wed, 6 Jul 2016 06:01:37 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 6 Jul 2016 14:01:12 +0100 Message-Id: <1467810073-27971-14-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467810073-27971-1-git-send-email-julien.grall@arm.com> References: <1467810073-27971-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v6 13/14] xen/arm: p2m: Use typesafe gfn for {max, lowest}_mapped_gfn X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v6: - Add Stefano's acked-by Changes in v4: - Patch added --- xen/arch/arm/mm.c | 2 +- xen/arch/arm/p2m.c | 18 +++++++++--------- xen/include/asm-arm/p2m.h | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index b5fc034..4e256c2 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1004,7 +1004,7 @@ int page_is_ram_type(unsigned long mfn, unsigned long mem_type) unsigned long domain_get_maximum_gpfn(struct domain *d) { - return d->arch.p2m.max_mapped_gfn; + return gfn_x(d->arch.p2m.max_mapped_gfn); } void share_xen_page_with_guest(struct page_info *page, diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index b98eff4..c7f6766 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -976,7 +976,7 @@ static int apply_p2m_changes(struct domain *d, * This is set in preempt_count_limit. * */ - p2m->lowest_mapped_gfn = addr >> PAGE_SHIFT; + p2m->lowest_mapped_gfn = _gfn(addr >> PAGE_SHIFT); rc = -ERESTART; goto out; @@ -1117,8 +1117,8 @@ static int apply_p2m_changes(struct domain *d, if ( op == INSERT ) { - p2m->max_mapped_gfn = max(p2m->max_mapped_gfn, egfn); - p2m->lowest_mapped_gfn = min(p2m->lowest_mapped_gfn, sgfn); + p2m->max_mapped_gfn = gfn_max(p2m->max_mapped_gfn, _gfn(egfn)); + p2m->lowest_mapped_gfn = gfn_min(p2m->lowest_mapped_gfn, _gfn(sgfn)); } rc = 0; @@ -1383,8 +1383,8 @@ int p2m_init(struct domain *d) p2m->root = NULL; - p2m->max_mapped_gfn = 0; - p2m->lowest_mapped_gfn = ULONG_MAX; + p2m->max_mapped_gfn = _gfn(0); + p2m->lowest_mapped_gfn = _gfn(ULONG_MAX); p2m->default_access = p2m_access_rwx; p2m->mem_access_enabled = false; @@ -1401,8 +1401,8 @@ int relinquish_p2m_mapping(struct domain *d) struct p2m_domain *p2m = &d->arch.p2m; return apply_p2m_changes(d, RELINQUISH, - pfn_to_paddr(p2m->lowest_mapped_gfn), - pfn_to_paddr(p2m->max_mapped_gfn), + pfn_to_paddr(gfn_x(p2m->lowest_mapped_gfn)), + pfn_to_paddr(gfn_x(p2m->max_mapped_gfn)), pfn_to_paddr(mfn_x(INVALID_MFN)), MATTR_MEM, 0, p2m_invalid, d->arch.p2m.default_access); @@ -1413,8 +1413,8 @@ int p2m_cache_flush(struct domain *d, gfn_t start, unsigned long nr) struct p2m_domain *p2m = &d->arch.p2m; gfn_t end = gfn_add(start, nr); - start = gfn_max(start, _gfn(p2m->lowest_mapped_gfn)); - end = gfn_min(end, _gfn(p2m->max_mapped_gfn)); + start = gfn_max(start, p2m->lowest_mapped_gfn); + end = gfn_min(end, p2m->max_mapped_gfn); return apply_p2m_changes(d, CACHEFLUSH, pfn_to_paddr(gfn_x(start)), diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 6e258b9..34096bc 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -34,13 +34,13 @@ struct p2m_domain { /* Highest guest frame that's ever been mapped in the p2m * Only takes into account ram and foreign mapping */ - unsigned long max_mapped_gfn; + gfn_t max_mapped_gfn; /* Lowest mapped gfn in the p2m. When releasing mapped gfn's in a * preemptible manner this is update to track recall where to * resume the search. Apart from during teardown this can only * decrease. */ - unsigned long lowest_mapped_gfn; + gfn_t lowest_mapped_gfn; /* Gather some statistics for information purposes only */ struct {