From patchwork Tue Jul 12 13:59:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 71838 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp492705qga; Tue, 12 Jul 2016 07:03:19 -0700 (PDT) X-Received: by 10.107.173.72 with SMTP id w69mr3210738ioe.127.1468332198508; Tue, 12 Jul 2016 07:03:18 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e125si3391141ioa.224.2016.07.12.07.03.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2016 07:03:18 -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 1bMyEI-0007el-Sj; Tue, 12 Jul 2016 14:00:06 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMyEH-0007Ss-Et for xen-devel@lists.xen.org; Tue, 12 Jul 2016 14:00:05 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id E1/A4-00606-4E7F4875; Tue, 12 Jul 2016 14:00:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTffJ95Z wg2lPWC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oxVP44wFZyVq9j44DV7A+NLsS5GLg4hgU2M Ej+2P2WCcE4zShxuv8HcxcjJwSagKXHn8ycmEFtEQFri2ufLjCA2s4CDxJuP91hAbGGBEImeW 9vAalgEVCW27ZjOCmLzCrhKXL6yEGyOhICcxMljk8HinEDxr9NPgs0REnCRuLDsK+sERu4FjA yrGNWLU4vKUot0zfWSijLTM0pyEzNzdA0NTPVyU4uLE9NTcxKTivWS83M3MQL9ywAEOxiPTXY +xCjJwaQkytvM3BIuxJeUn1KZkVicEV9UmpNafIhRhoNDSYI3/BtQTrAoNT21Ii0zBxhoMGkJ Dh4lEV4jkDRvcUFibnFmOkTqFKOilDivGEhCACSRUZoH1wYL7kuMslLCvIxAhwjxFKQW5WaWo Mq/YhTnYFQS5m0GmcKTmVcCN/0V0GImoMW1Ds0gi0sSEVJSDYx+O90Cm/5/2X3uZEit098m7+ TnLG+Nrz6/zPV8nfvR9CVXV9ffOtKvnPTPPOmioFDEjsbH0psZSm6d1w1hOJngJqcV4sgaJpd 6uGr6xY8mTyU8evxT5y4N/i3y4FR3YqDwi89uGw+bx9yuYGcq8RWe83hCW+JBZl+7tDzDCtPs s7Zsjrt4S5VYijMSDbWYi4oTAdY49DNpAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1468332001!33777857!2 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41718 invoked from network); 12 Jul 2016 14:00:03 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-16.tower-206.messagelabs.com with SMTP; 12 Jul 2016 14:00:03 -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 5AD2F447; Tue, 12 Jul 2016 07:01:07 -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 D22773F213; Tue, 12 Jul 2016 07:00:02 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 12 Jul 2016 14:59:34 +0100 Message-Id: <1468331975-27331-14-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468331975-27331-1-git-send-email-julien.grall@arm.com> References: <1468331975-27331-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v7 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 dd890c2..de2ab05 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 {