From patchwork Thu Sep 21 12:40:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113240 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1845836edb; Thu, 21 Sep 2017 05:42:44 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA2ZCyQPvkR4B+wjDu+RgYEhmN+Phk1n9rA9bTpqE12txtWXHYOS3erXVUpQu8zFfyOgPYa X-Received: by 10.36.117.150 with SMTP id y144mr1308771itc.60.1505997764302; Thu, 21 Sep 2017 05:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997764; cv=none; d=google.com; s=arc-20160816; b=f0iXjCEzu0UsWe+fJeGnwdzkwxkfe0wvFwZq5vwanFDckE7RfFq14FyQaTrfifADOV i4bzyXiO5r+1kvirnL25TzcLbEhRFpvQA489acUURqRVmtQB+fWc5+IydWAWSeniqYYy QyXeMTRcaVxA0MAB8M8Mps5gwah+kUF0J0zdiUjcJMn20Br9bieg4eYw6sb87tAkbH3w 52iRk6niBjfaOZ+Vmt8cGSq9EqD/3HMNo30gtVsxziW0xJLxB31x7i0RV6z+mltBjXe6 HgPip8EhbCOZJoH1C91ERyPpBqp2HHpFqBPeia/8UI8WVtmYdhXFZ+sPu24Q3BfHQvMk pDYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=YIUPPcqpzizVjGsPZ6uExuYmXDwa2Q57/KL+RBVZ1c8=; b=XWLw8xcec/2gogiIRoEZQD9zjAJj1TTAj46IEx5Hw7stZxdLS7kNh6nXQlHfCdx5Sr Eq194c0gPnIrH49FXU65WbXaG0G34YD9fc/Av28ZjUY7MfW1wDrxLtMZFLCBSWg58J3p Ji5PN4esnYQ2l4nIrE1KKYskBI1IfrbprHF48keoKBVnboIwkk6NDGyjtq/KSTFe4NZ5 0GJjGlMZr1suqdzHMY3sVN5UAsvrMXRE4W9UIiBVS2rOl2L9bRfCaNInNrx5yC/Mcv3o p3nPPYzBbOiFaeE1EGmVc/cXEp0y9e4UK1K9HVPR6XppNw0yLMuwswo19g0O/kKqcKRS f6WQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f130si1110712ioe.397.2017.09.21.05.42.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:44 -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 1dv0n0-0001cq-1b; Thu, 21 Sep 2017 12:41: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 1dv0my-0001ad-V4 for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:09 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 9F/25-17770-463B3C95; Thu, 21 Sep 2017 12:41:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTd28+F Ig/Xv9C2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ox9H06zFZxQr1g76xVzA+NMmS5GLg4hgc2M Eh/OrWWCcE4zSty83c3WxcjJwSagKXHn8ycmEFtEQFri2ufLjCBFzAKLGSU+7+9lBkkIC4RLv Ln6E6yBRUBV4vmlTSwgNq+ApcSUdV/B4hIC8hK72i6ygticQPG2w9/AbCEBC4lfE06wTmDkXs DIsIpRozi1qCy1SNfIUC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTI9DHDECwg/H PsoBDjJIcTEqivO/WHY4U4kvKT6nMSCzOiC8qzUktPsQow8GhJMHLuQkoJ1iUmp5akZaZAww2 mLQEB4+SCK8rSJq3uCAxtzgzHSJ1ilGXo+Pm3T9MQix5+XmpUuK85iBFAiBFGaV5cCNggX+JU VZKmJcR6CghnoLUotzMElT5V4ziHIxKwrzPNwJN4cnMK4Hb9AroCCagI7I3HAA5oiQRISXVwM ig8tn3gsGEzFd9aaxzXmdx2tUanj69Ubk8o23/s3/vF3ieP1Rq86rG/e7fm//0+haJbZ9RnZG cdFZ4hx5/47+8o6FPckxrTXZeZxXI/OdywKLcwIPXhyfj1VPte2tbF2U4L33I9sNKT7jmtVT6 R5WiulvOggybr8n/CtQuyV2qm7IsxrbYSomlOCPRUIu5qDgRAJv57K53AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1505997661!117568586!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 49746 invoked from network); 21 Sep 2017 12:41:01 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-27.messagelabs.com with SMTP; 21 Sep 2017 12:41:01 -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 EADE41529; Thu, 21 Sep 2017 05:41:00 -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 DB6FF3F58C; Thu, 21 Sep 2017 05:40:59 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:32 +0100 Message-Id: <20170921124035.2410-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 13/16] 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 0dd0f0a083..5c79444d7b 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);