From patchwork Mon Jun 27 16:54:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 70932 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1167399qgy; Mon, 27 Jun 2016 09:56:05 -0700 (PDT) X-Received: by 10.36.73.219 with SMTP id e88mr9758398itd.88.1467046565157; Mon, 27 Jun 2016 09:56:05 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v63si6711652ioe.155.2016.06.27.09.56.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jun 2016 09:56:05 -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 1bHZo6-0005x7-Hx; Mon, 27 Jun 2016 16:54:46 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHZo5-0005tq-8A for xen-devel@lists.xen.org; Mon, 27 Jun 2016 16:54:45 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 5A/54-09256-45A51775; Mon, 27 Jun 2016 16:54:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTTckqjD c4OFjFoslHxezODB6HN39mymAMYo1My8pvyKBNeND2172gtuyFU/W9LM3MPaLdTFycQgJbGKU OHvqOyuEc5pRYu+pLqYuRk4ONgFNiTufP4HZIgLSEtc+X2YEsZkFwiRuv9kFZgsLhEjcufeUG cRmEVCVeP/kCRuIzSvgIrF6+2awuISAnMTJY5NZQWxOoPjeC0vB4kICzhIHp31nn8DIvYCRYR WjenFqUVlqka6xXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGoH8ZgGAHY8c/p0O MkhxMSqK82x7lhgvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4H0eURguJFiUmp5akZaZAww0mLQE B4+SCK9JJFCat7ggMbc4Mx0idYpRUUqcVwkkIQCSyCjNg2uDBfclRlkpYV5GoEOEeApSi3IzS 1DlXzGKczAqCfNygEzhycwrgZv+CmgxE9Bi1up8kMUliQgpqQZGxVV/H1uYerrtqi1+PaM5I9 bBau5XfsVlaf2BZp8eXCuq9zohp59S9PLuxpL312fNn7mD/a1d094DfEmfru3x5J/6f6qt+6v FERkCM3745r2t3+Rn/3pWnXQ0x+5zM6J/sOxtXaBRInDifbXP1TOT59+xrvq7S7tFifkxT6Ti 5NKEj+9uKvMKKrEUZyQaajEXFScCAPStcVRpAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1467046483!21107919!1 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 38905 invoked from network); 27 Jun 2016 16:54:43 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-21.messagelabs.com with SMTP; 27 Jun 2016 16:54:43 -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 928943A8; Mon, 27 Jun 2016 09:55:31 -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 6405E3F246; Mon, 27 Jun 2016 09:54:39 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 27 Jun 2016 17:54:11 +0100 Message-Id: <1467046452-1261-16-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467046452-1261-1-git-send-email-julien.grall@arm.com> References: <1467046452-1261-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, wei.chen@linaro.org Subject: [Xen-devel] [PATCH v4 15/16] 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 --- 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 3a50787..3d076de 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(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 {