From patchwork Mon Jun 27 16:54:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 70943 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1167645qgy; Mon, 27 Jun 2016 09:56:44 -0700 (PDT) X-Received: by 10.107.52.133 with SMTP id b127mr1893647ioa.6.1467046593179; Mon, 27 Jun 2016 09:56:33 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id l140si8381244ita.107.2016.06.27.09.56.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jun 2016 09:56:33 -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 1bHZo1-0005mO-EJ; Mon, 27 Jun 2016 16:54:41 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHZo0-0005kF-Ib for xen-devel@lists.xen.org; Mon, 27 Jun 2016 16:54:40 +0000 Received: from [193.109.254.147] by server-6.bemta-14.messagelabs.com id A9/CA-30934-F4A51775; Mon, 27 Jun 2016 16:54:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTdc/qjD cYOt/foslHxezODB6HN39mymAMYo1My8pvyKBNWPjgq+MBRtUKj41PWZvYHwu2sXIySEksIlR 4sA7cwj7NKPEvI+sIDabgKbEnc+fmEBsEQFpiWufLzOC2MwCYRK33+wCs4UFYiSmPtgBVs8io Crxd9FGFhCbV8BFYt7WH+wgtoSAnMTJY5PBajiB4nsvLGWG2OUscXDad/YJjNwLGBlWMaoXpx aVpRbpmuklFWWmZ5TkJmbm6BoamujlphYXJ6an5iQmFesl5+duYgT6lgEIdjD+neB8iFGSg0l JlHfbo9xwIb6k/JTKjMTijPii0pzU4kOMMhwcShK8zyMKw4UEi1LTUyvSMnOAQQaTluDgURLh NYkESvMWFyTmFmemQ6ROMSpKifMqgSQEQBIZpXlwbbDAvsQoKyXMywh0iBBPQWpRbmYJqvwrR nEORiVhXk+QKTyZeSVw018BLWYCWsxanQ+yuCQRISXVwLi0y+fO+S3ruNwNH/V7LCl067grwe NrfDzu2eKpNTapE2LTrmkty5j57vy17eXL3yekfk4JVS6fkTChzoJ5ffTeytS76cpOC+vM/5j xXZsQwXuaZ46uH9Oj5Qnn/+lsVptfk3f4yveKbzX+UZlXcx6ymnw1zZ1w1SFApSpQznXetc1+ m+ewzlFiKc5INNRiLipOBABdwP/8ZwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1467046478!50377789!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 24145 invoked from network); 27 Jun 2016 16:54:38 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-27.messagelabs.com with SMTP; 27 Jun 2016 16:54:38 -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 7FE483A8; Mon, 27 Jun 2016 09:55:29 -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 503CA3F246; Mon, 27 Jun 2016 09:54:37 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 27 Jun 2016 17:54:09 +0100 Message-Id: <1467046452-1261-14-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 13/16] xen/arm: Use the typesafes mfn and gfn in map_regions_rw_cache ... 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" to avoid mixing machine frame with guest frame. Also rename the parameters of the function and drop pointless PAGE_MASK in the caller. Signed-off-by: Julien Grall --- Changes in v4: - Patch added --- xen/arch/arm/domain_build.c | 8 ++++---- xen/arch/arm/p2m.c | 20 ++++++++++---------- xen/include/asm-arm/p2m.h | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 923f48a..60db9e4 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1522,9 +1522,9 @@ static void acpi_map_other_tables(struct domain *d) addr = acpi_gbl_root_table_list.tables[i].address; size = acpi_gbl_root_table_list.tables[i].length; res = map_regions_rw_cache(d, - paddr_to_pfn(addr & PAGE_MASK), + _gfn(paddr_to_pfn(addr)), DIV_ROUND_UP(size, PAGE_SIZE), - paddr_to_pfn(addr & PAGE_MASK)); + _mfn(paddr_to_pfn(addr))); if ( res ) { panic(XENLOG_ERR "Unable to map ACPI region 0x%"PRIx64 @@ -1878,9 +1878,9 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) /* Map the EFI and ACPI tables to Dom0 */ rc = map_regions_rw_cache(d, - paddr_to_pfn(d->arch.efi_acpi_gpa), + _gfn(paddr_to_pfn(d->arch.efi_acpi_gpa)), PFN_UP(d->arch.efi_acpi_len), - paddr_to_pfn(virt_to_maddr(d->arch.efi_acpi_table))); + _mfn(paddr_to_pfn(virt_to_maddr(d->arch.efi_acpi_table)))); if ( rc != 0 ) { printk(XENLOG_ERR "Unable to map EFI/ACPI table 0x%"PRIx64 diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index faadebf..36ee0fe 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1159,27 +1159,27 @@ out: } int map_regions_rw_cache(struct domain *d, - unsigned long start_gfn, + gfn_t gfn, unsigned long nr, - unsigned long mfn) + mfn_t mfn) { return apply_p2m_changes(d, INSERT, - pfn_to_paddr(start_gfn), - pfn_to_paddr(start_gfn + nr), - pfn_to_paddr(mfn), + pfn_to_paddr(gfn_x(gfn)), + pfn_to_paddr(gfn_x(gfn) + nr), + pfn_to_paddr(mfn_x(mfn)), MATTR_MEM, 0, p2m_mmio_direct, d->arch.p2m.default_access); } int unmap_regions_rw_cache(struct domain *d, - unsigned long start_gfn, + gfn_t gfn, unsigned long nr, - unsigned long mfn) + mfn_t mfn) { return apply_p2m_changes(d, REMOVE, - pfn_to_paddr(start_gfn), - pfn_to_paddr(start_gfn + nr), - pfn_to_paddr(mfn), + pfn_to_paddr(gfn_x(gfn)), + pfn_to_paddr(gfn_x(gfn) + nr), + pfn_to_paddr(mfn_x(mfn)), MATTR_MEM, 0, p2m_invalid, d->arch.p2m.default_access); } diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 8d29eda..6e258b9 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -142,14 +142,14 @@ mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t *t); int p2m_cache_flush(struct domain *d, gfn_t start, unsigned long nr); int map_regions_rw_cache(struct domain *d, - unsigned long start_gfn, - unsigned long nr_mfns, - unsigned long mfn); + gfn_t gfn, + unsigned long nr, + mfn_t mfn); int unmap_regions_rw_cache(struct domain *d, - unsigned long start_gfn, - unsigned long nr_mfns, - unsigned long mfn); + gfn_t gfn, + unsigned long nr, + mfn_t mfn); int map_dev_mmio_region(struct domain *d, gfn_t gfn,