From patchwork Mon Oct 2 12:59:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9980829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45144603FF for ; Mon, 2 Oct 2017 13:02:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37BF4201F3 for ; Mon, 2 Oct 2017 13:02:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CB8A2888C; Mon, 2 Oct 2017 13:02:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B4AAD207A7 for ; Mon, 2 Oct 2017 13:02:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KQ-0004Ft-O2; Mon, 02 Oct 2017 13:00:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KP-0004DL-FQ for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:09 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 8D/F4-03283-85832D95; Mon, 02 Oct 2017 13:00:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTfC4lK kQfcNboslHxezODB6HN39mymAMYo1My8pvyKBNaPlXCdrwWqNiknb3jM3MD6R6WLk4hAS2MQo cWf6LXYI5zSjxITfPSxdjJwcbAKaEnc+f2ICsUUEpCWufb7MCFLELLCYUeLz/l5mkISwQLjEt 5+3wIpYBFQlNv5oB7N5BawkHn64AFYjISAvsavtIiuIzQkUf3/8I5gtJGApcbx7EtMERu4FjA yrGDWKU4vKUot0jSz0kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECfcwABDsYz68 NPMQoycGkJMrLbHgpUogvKT+lMiOxOCO+qDQntfgQowwHh5IE73xzoJxgUWp6akVaZg4w2GDS Ehw8SiK8xSBp3uKCxNzizHSI1ClGXY6Om3f/MAmx5OXnpUqJ81aAFAmAFGWU5sGNgAX+JUZZK WFeRqCjhHgKUotyM0tQ5V8xinMwKgnz1oJM4cnMK4Hb9AroCCagI+Z0XQA5oiQRISXVwLiq1P D9om79gFPaD+pWM4Zwraq9pfDD4uRuI8O3CvvjWdvdAnzOnuiQWi/LFFS2yjUvce5Edfs3vGw nqn+Fx7uf2DqpQvNhiX7vohNHD7Tevz5ZvWLj+rirYWw+rPe++fl56Loanjv7YP6N30cXFc5M v7KybWoJw86y87yzp9p0eYZp/Qs5k6zEUpyRaKjFXFScCACp91qadwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1506949207!114052584!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20752 invoked from network); 2 Oct 2017 13:00:07 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-27.messagelabs.com with SMTP; 2 Oct 2017 13:00:07 -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 59EF480D; Mon, 2 Oct 2017 06:00:07 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4A9443F53D; Mon, 2 Oct 2017 06:00:06 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:39 +0100 Message-Id: <20171002125941.11274-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 13/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_demand_populate 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" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Add Andrew's acked-by - Variable gfn_t was renamed to gfn_ in a previous patch. So use the new name --- xen/arch/x86/mm/p2m-ept.c | 5 ++--- xen/arch/x86/mm/p2m-pod.c | 12 ++++++------ xen/arch/x86/mm/p2m-pt.c | 6 +++--- xen/include/asm-x86/p2m.h | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index f14d1686b7..bc25582c5a 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -965,7 +965,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m, index = gfn_remainder >> ( i * EPT_TABLE_ORDER); ept_entry = table + index; - if ( !p2m_pod_demand_populate(p2m, gfn, i * EPT_TABLE_ORDER, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_, i * EPT_TABLE_ORDER, q) ) goto retry; else goto out; @@ -987,8 +987,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m, ASSERT(i == 0); - if ( p2m_pod_demand_populate(p2m, gfn, - PAGE_ORDER_4K, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) ) goto out; } diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 668c484a75..55f2fa4f18 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -1076,13 +1076,13 @@ static void pod_eager_record(struct p2m_domain *p2m, gfn_t gfn, } int -p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, +p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, unsigned int order, p2m_query_t q) { struct domain *d = p2m->domain; struct page_info *p = NULL; /* Compiler warnings */ - gfn_t gfn_aligned = _gfn((gfn >> order) << order); + gfn_t gfn_aligned = _gfn((gfn_x(gfn) >> order) << order); mfn_t mfn; unsigned long i; @@ -1135,8 +1135,8 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, goto out_of_memory; /* Keep track of the highest gfn demand-populated by a guest fault */ - if ( gfn > p2m->pod.max_guest ) - p2m->pod.max_guest = gfn; + if ( gfn_x(gfn) > p2m->pod.max_guest ) + p2m->pod.max_guest = gfn_x(gfn); /* * Get a page f/ the cache. A NULL return value indicates that the @@ -1170,7 +1170,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, int d:16,order:16; } t; - t.gfn = gfn; + t.gfn = gfn_x(gfn); t.mfn = mfn_x(mfn); t.d = d->domain_id; t.order = order; @@ -1210,7 +1210,7 @@ remap_and_retry: int d:16; } t; - t.gfn = gfn; + t.gfn = gfn_x(gfn); t.d = d->domain_id; __trace_var(TRC_MEM_POD_SUPERPAGE_SPLINTER, 0, sizeof(t), &t); diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 4bfec4f5f0..a639a00e9c 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -802,7 +802,7 @@ pod_retry_l3: { if ( q & P2M_ALLOC ) { - if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_1G, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_1G, q) ) goto pod_retry_l3; gdprintk(XENLOG_ERR, "%s: Allocate 1GB failed!\n", __func__); } @@ -844,7 +844,7 @@ pod_retry_l2: if ( p2m_flags_to_type(flags) == p2m_populate_on_demand ) { if ( q & P2M_ALLOC ) { - if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_2M, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_2M, q) ) goto pod_retry_l2; } else *t = p2m_populate_on_demand; @@ -883,7 +883,7 @@ pod_retry_l1: if ( l1t == p2m_populate_on_demand ) { if ( q & P2M_ALLOC ) { - if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_4K, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) ) goto pod_retry_l1; } else *t = p2m_populate_on_demand; diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 07ca02a173..1ae9216404 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -720,7 +720,7 @@ extern void audit_p2m(struct domain *d, /* Called by p2m code when demand-populating a PoD page */ int -p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, +p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, unsigned int order, p2m_query_t q);