From patchwork Mon Jun 20 13:37:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9187435 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 F00996075E for ; Mon, 20 Jun 2016 13:42:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAAB322B1F for ; Mon, 20 Jun 2016 13:42:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF73A276AE; Mon, 20 Jun 2016 13:42:31 +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 32D1522B1F for ; Mon, 20 Jun 2016 13:42:31 +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 1bEzRO-0006nk-R3; Mon, 20 Jun 2016 13:40:38 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEzRN-0006nK-GJ for xen-devel@lists.xen.org; Mon, 20 Jun 2016 13:40:37 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 6C/2B-00606-452F7675; Mon, 20 Jun 2016 13:40:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTdf+U3q 4wYIAiyUfF7M4MHoc3f2bKYAxijUzLym/IoE1Y9qtq0wFCw0qnrTfYGtg7FHuYuTiEBLYxCjx 6tF5dgjnNKPE869fmLsYOTnYBDQl7nz+xARiiwhIS1z7fJkRxGYWuMQk8XEKL4gtLOAlseP3O nYQm0VAVaL760Iwm1fAReLGzcusILaEgJzEyWOTwWxOAVeJg89+gNUIAdX0/9rFNIGRewEjwy pG9eLUorLUIl0zvaSizPSMktzEzBxdQwNTvdzU4uLE9NScxKRiveT83E2MQO8yAMEOxqkNzoc YJTmYlER5bYrTw4X4kvJTKjMSizPii0pzUosPMcpwcChJ8DZfBMoJFqWmp1akZeYAwwwmLcHB oyTCWwaS5i0uSMwtzkyHSJ1iVJQS560CSQiAJDJK8+DaYKF9iVFWSpiXEegQIZ6C1KLczBJU+ VeM4hyMSsK8niBTeDLzSuCmvwJazAS0eFk/2OKSRISUVAOjZdi9U8GeqbuNv709/tl2w4mfZY +5N+VvOuaewG+vxLVtZ0lTfY557gO7KWVtZQsOW/6Le8103djOKeKCTLJIWNbT90XpEjMkA+S l+qJ2xvI2v6mKfu4pq65jq37c4uHFfes+5xllf7v0YPoU7YyDPjtDw234bmyZ45tqd2BVxjT2 M9+EHcWUWIozEg21mIuKEwHJ2uVMaAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-206.messagelabs.com!1466429892!9362086!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 26885 invoked from network); 20 Jun 2016 13:39:08 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-206.messagelabs.com with SMTP; 20 Jun 2016 13:39:08 -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 2FE51BA9; Mon, 20 Jun 2016 06:38:27 -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 38E583F246; Mon, 20 Jun 2016 06:37:40 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 20 Jun 2016 14:37:21 +0100 Message-Id: <1466429845-28240-5-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466429845-28240-1-git-send-email-julien.grall@arm.com> References: <1466429845-28240-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 4/8] xen: Use typesafe gfn in xenmem_add_to_physmap_one 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 The x86 version of the function xenmem_add_to_physmap_one contains variable name gpfn and gfn which make the code very confusing. I have left unchanged for now. Also, rename gpfn to gfn in the ARM version as the latter is the correct acronym for a guest physical frame. Finally, remove the trailing whitespace around the changes. Signed-off-by: Julien Grall Acked-by: Jan Beulich --- Cc: Stefano Stabellini Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Konrad Rzeszutek Wilk Cc: Tim Deegan Cc: Wei Liu --- xen/arch/arm/mm.c | 10 +++++----- xen/arch/x86/mm.c | 15 +++++++-------- xen/common/memory.c | 6 +++--- xen/include/xen/mm.h | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 5ab9b75..6882d54 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1046,7 +1046,7 @@ int xenmem_add_to_physmap_one( unsigned int space, union xen_add_to_physmap_batch_extra extra, unsigned long idx, - xen_pfn_t gpfn) + gfn_t gfn) { unsigned long mfn = 0; int rc; @@ -1081,8 +1081,8 @@ int xenmem_add_to_physmap_one( else return -EINVAL; } - - d->arch.grant_table_gpfn[idx] = gpfn; + + d->arch.grant_table_gpfn[idx] = gfn_x(gfn); t = p2m_ram_rw; @@ -1145,7 +1145,7 @@ int xenmem_add_to_physmap_one( if ( extra.res0 ) return -EOPNOTSUPP; - rc = map_dev_mmio_region(d, gpfn, 1, idx); + rc = map_dev_mmio_region(d, gfn_x(gfn), 1, idx); return rc; default: @@ -1153,7 +1153,7 @@ int xenmem_add_to_physmap_one( } /* Map at new location. */ - rc = guest_physmap_add_entry(d, _gfn(gpfn), _mfn(mfn), 0, t); + rc = guest_physmap_add_entry(d, gfn, _mfn(mfn), 0, t); /* If we fail to add the mapping, we need to drop the reference we * took earlier on foreign pages */ diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 7fbc94e..dbcf6cb 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4775,7 +4775,7 @@ int xenmem_add_to_physmap_one( unsigned int space, union xen_add_to_physmap_batch_extra extra, unsigned long idx, - xen_pfn_t gpfn) + gfn_t gpfn) { struct page_info *page = NULL; unsigned long gfn = 0; /* gcc ... */ @@ -4834,7 +4834,7 @@ int xenmem_add_to_physmap_one( break; } case XENMAPSPACE_gmfn_foreign: - return p2m_add_foreign(d, idx, gpfn, extra.foreign_domid); + return p2m_add_foreign(d, idx, gfn_x(gpfn), extra.foreign_domid); default: break; } @@ -4849,19 +4849,18 @@ int xenmem_add_to_physmap_one( } /* Remove previously mapped page if it was present. */ - prev_mfn = mfn_x(get_gfn(d, gpfn, &p2mt)); + prev_mfn = mfn_x(get_gfn(d, gfn_x(gpfn), &p2mt)); if ( mfn_valid(prev_mfn) ) { if ( is_xen_heap_mfn(prev_mfn) ) /* Xen heap frames are simply unhooked from this phys slot. */ - guest_physmap_remove_page(d, _gfn(gpfn), _mfn(prev_mfn), - PAGE_ORDER_4K); + guest_physmap_remove_page(d, gpfn, _mfn(prev_mfn), PAGE_ORDER_4K); else /* Normal domain memory is freed, to avoid leaking memory. */ - guest_remove_page(d, gpfn); + guest_remove_page(d, gfn_x(gpfn)); } /* In the XENMAPSPACE_gmfn case we still hold a ref on the old page. */ - put_gfn(d, gpfn); + put_gfn(d, gfn_x(gpfn)); /* Unmap from old location, if any. */ old_gpfn = get_gpfn_from_mfn(mfn); @@ -4872,7 +4871,7 @@ int xenmem_add_to_physmap_one( guest_physmap_remove_page(d, _gfn(old_gpfn), _mfn(mfn), PAGE_ORDER_4K); /* Map at new location. */ - rc = guest_physmap_add_page(d, _gfn(gpfn), _mfn(mfn), PAGE_ORDER_4K); + rc = guest_physmap_add_page(d, gpfn, _mfn(mfn), PAGE_ORDER_4K); /* In the XENMAPSPACE_gmfn, we took a ref of the gfn at the top */ if ( space == XENMAPSPACE_gmfn || space == XENMAPSPACE_gmfn_range ) diff --git a/xen/common/memory.c b/xen/common/memory.c index a8a75e0..812334b 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -649,7 +649,7 @@ static int xenmem_add_to_physmap(struct domain *d, if ( xatp->space != XENMAPSPACE_gmfn_range ) return xenmem_add_to_physmap_one(d, xatp->space, extra, - xatp->idx, xatp->gpfn); + xatp->idx, _gfn(xatp->gpfn)); if ( xatp->size < start ) return -EILSEQ; @@ -666,7 +666,7 @@ static int xenmem_add_to_physmap(struct domain *d, while ( xatp->size > done ) { rc = xenmem_add_to_physmap_one(d, xatp->space, extra, - xatp->idx, xatp->gpfn); + xatp->idx, _gfn(xatp->gpfn)); if ( rc < 0 ) break; @@ -735,7 +735,7 @@ static int xenmem_add_to_physmap_batch(struct domain *d, rc = xenmem_add_to_physmap_one(d, xatpb->space, xatpb->u, - idx, gpfn); + idx, _gfn(gpfn)); if ( unlikely(__copy_to_guest_offset(xatpb->errs, 0, &rc, 1)) ) { diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 10f2580..408f78e 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -517,7 +517,7 @@ void scrub_one_page(struct page_info *); int xenmem_add_to_physmap_one(struct domain *d, unsigned int space, union xen_add_to_physmap_batch_extra extra, - unsigned long idx, xen_pfn_t gpfn); + unsigned long idx, gfn_t gfn); /* Returns 1 on success, 0 on error, negative if the ring * for event propagation is full in the presence of paging */