From patchwork Tue Jun 28 16:17:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 71118 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1681881qgy; Tue, 28 Jun 2016 09:20:06 -0700 (PDT) X-Received: by 10.107.129.18 with SMTP id c18mr4557571iod.102.1467130795369; Tue, 28 Jun 2016 09:19:55 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id d135si2653628ith.18.2016.06.28.09.19.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2016 09:19:55 -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 1bHvi1-0007Jw-4B; Tue, 28 Jun 2016 16:17:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHvhz-0007Ft-TI for xen-devel@lists.xen.org; Tue, 28 Jun 2016 16:17:56 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 29/95-03403-333A2775; Tue, 28 Jun 2016 16:17:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTddocVG 4wd21ChZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b0z41MBRtUKnp2X2BrYHwu2sXIxSEksIlR ouFCCzOEc5pR4t+yJaxdjJwcbAKaEnc+f2ICsUUEpCWufb7MCGIzCzhIvPl4jwXEFhaIkfjav 5G9i5GDg0VAVaLlUShImFfAVeJ/22KwcgkBOYmTxyaDjeQEim+Z8pMNxBYScJG4cOIGywRG7g WMDKsYNYpTi8pSi3QNzfWSijLTM0pyEzNzdA0NjPVyU4uLE9NTcxKTivWS83M3MQL9ywAEOxh fnvY8xCjJwaQkyvuttyhciC8pP6UyI7E4I76oNCe1+BCjDAeHkgSv7CKgnGBRanpqRVpmDjDQ YNISHDxKIryuIGne4oLE3OLMdIjUKUZFKXHe3QuBEgIgiYzSPLg2WHBfYpSVEuZlBDpEiKcgt Sg3swRV/hWjOAejkjCvH8h4nsy8Erjpr4AWMwEtZq3OB1lckoiQkmpg3P322MkJpcVWorlH4h 6+X/bTcEnYdsme6neTsh5VnJ2QIfS18O4ZmzlrHcwVFrWtX6nyXGRqW/Yy5TWJ9TMOqXJ/XdL 1KULgQX5QlYDSr5Xup/4fnu7eapA59wjjT8fszusZM/peVG3jtvcRt3RiSP3d8iL25ycLDScu n4vu4bLzAxsnvcjnV2Ipzkg01GIuKk4EANTmuUhpAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1467130669!47102581!4 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 55401 invoked from network); 28 Jun 2016 16:17:54 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-31.messagelabs.com with SMTP; 28 Jun 2016 16:17:54 -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 2C59C226; Tue, 28 Jun 2016 09:18:46 -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 4BB0F3F21A; Tue, 28 Jun 2016 09:17:53 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 28 Jun 2016 17:17:20 +0100 Message-Id: <1467130643-23868-15-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467130643-23868-1-git-send-email-julien.grall@arm.com> References: <1467130643-23868-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v5 14/17] 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 5ffc3df..0fdd11f 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,