From nobody Fri Dec 27 00:19:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 173287164821620.822980662788154; Fri, 29 Nov 2024 01:14:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.845803.1261182 (Exim 4.92) (envelope-from ) id 1tGx4S-0006A9-DQ; Fri, 29 Nov 2024 09:13:52 +0000 Received: by outflank-mailman (output) from mailman id 845803.1261182; Fri, 29 Nov 2024 09:13:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tGx4S-00069y-AI; Fri, 29 Nov 2024 09:13:52 +0000 Received: by outflank-mailman (input) for mailman id 845803; Fri, 29 Nov 2024 09:13:50 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tGx4Q-0004tF-8g for xen-devel@lists.xenproject.org; Fri, 29 Nov 2024 09:13:50 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 3cf176b8-ae32-11ef-99a3-01e77a169b0f; Fri, 29 Nov 2024 10:13:46 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CFAF41424; Fri, 29 Nov 2024 01:14:15 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 70AE93F58B; Fri, 29 Nov 2024 01:13:45 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3cf176b8-ae32-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjIxNy4xNDAuMTEwLjE3MiIsImhlbG8iOiJmb3NzLmFybS5jb20ifQ== X-Custom-Transaction: eyJpZCI6IjNjZjE3NmI4LWFlMzItMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyODcxNjI3LjEzMjUwMywic2VuZGVyIjoibHVjYS5mYW5jZWxsdUBhcm0uY29tIiwicmVjaXBpZW50IjoieGVuLWRldmVsQGxpc3RzLnhlbnByb2plY3Qub3JnIn0= From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v3 5/5] xen/arm: Move setup_frametable_mappings to arm/mmu Date: Fri, 29 Nov 2024 09:12:37 +0000 Message-Id: <20241129091237.3409304-6-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241129091237.3409304-1-luca.fancellu@arm.com> References: <20241129091237.3409304-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1732871650319019100 Content-Type: text/plain; charset="utf-8" Move the current setup_frametable_mappings implementation to arm/mmu under a new file mm.c, this implementation depends on virtual memory and won't be used as it is for MPU systems. Take the occasion to fix code style issues related to the line length. Moved also frametable_virt_end since it is used only on MMU systems. Signed-off-by: Luca Fancellu --- Changes to v2: - New patch --- --- xen/arch/arm/mm.c | 40 ------------------------- xen/arch/arm/mmu/Makefile | 1 + xen/arch/arm/mmu/mm.c | 61 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 40 deletions(-) create mode 100644 xen/arch/arm/mmu/mm.c diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index def939172cc5..a56e20ba2bdc 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -22,7 +22,6 @@ #define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) =20 unsigned long frametable_base_pdx __read_mostly; -unsigned long frametable_virt_end __read_mostly; =20 void flush_page_to_ram(unsigned long mfn, bool sync_icache) { @@ -43,45 +42,6 @@ void flush_page_to_ram(unsigned long mfn, bool sync_icac= he) invalidate_icache(); } =20 -/* Map a frame table to cover physical addresses ps through pe */ -void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) -{ - unsigned long nr_pdxs =3D mfn_to_pdx(mfn_add(maddr_to_mfn(pe), -1)) - - mfn_to_pdx(maddr_to_mfn(ps)) + 1; - unsigned long frametable_size =3D nr_pdxs * sizeof(struct page_info); - mfn_t base_mfn; - const unsigned long mapping_size =3D frametable_size < MB(32) ? MB(2) = : MB(32); - int rc; - - /* - * The size of paddr_t should be sufficient for the complete range of - * physical address. - */ - BUILD_BUG_ON((sizeof(paddr_t) * BITS_PER_BYTE) < PADDR_BITS); - BUILD_BUG_ON(sizeof(struct page_info) !=3D PAGE_INFO_SIZE); - - if ( frametable_size > FRAMETABLE_SIZE ) - panic("The frametable cannot cover the physical region %#"PRIpaddr= " - %#"PRIpaddr"\n", - ps, pe); - - frametable_base_pdx =3D mfn_to_pdx(maddr_to_mfn(ps)); - /* Round up to 2M or 32M boundary, as appropriate. */ - frametable_size =3D ROUNDUP(frametable_size, mapping_size); - base_mfn =3D alloc_boot_pages(frametable_size >> PAGE_SHIFT, 32<<(20-1= 2)); - - rc =3D map_pages_to_xen(FRAMETABLE_VIRT_START, base_mfn, - frametable_size >> PAGE_SHIFT, - PAGE_HYPERVISOR_RW | _PAGE_BLOCK); - if ( rc ) - panic("Unable to setup the frametable mappings.\n"); - - memset(&frame_table[0], 0, nr_pdxs * sizeof(struct page_info)); - memset(&frame_table[nr_pdxs], -1, - frametable_size - (nr_pdxs * sizeof(struct page_info))); - - frametable_virt_end =3D FRAMETABLE_VIRT_START + (nr_pdxs * sizeof(stru= ct page_info)); -} - int steal_page( struct domain *d, struct page_info *page, unsigned int memflags) { diff --git a/xen/arch/arm/mmu/Makefile b/xen/arch/arm/mmu/Makefile index 2cb44b857dd2..1c89602947de 100644 --- a/xen/arch/arm/mmu/Makefile +++ b/xen/arch/arm/mmu/Makefile @@ -1,3 +1,4 @@ +obj-y +=3D mm.o obj-y +=3D p2m.o obj-y +=3D pt.o obj-y +=3D setup.o diff --git a/xen/arch/arm/mmu/mm.c b/xen/arch/arm/mmu/mm.c new file mode 100644 index 000000000000..aefec908b7f2 --- /dev/null +++ b/xen/arch/arm/mmu/mm.c @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include +#include +#include +#include + +unsigned long frametable_virt_end __read_mostly; + +/* Map a frame table to cover physical addresses ps through pe */ +void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) +{ + unsigned long nr_pdxs =3D mfn_to_pdx(mfn_add(maddr_to_mfn(pe), -1)) - + mfn_to_pdx(maddr_to_mfn(ps)) + 1; + unsigned long frametable_size =3D nr_pdxs * sizeof(struct page_info); + mfn_t base_mfn; + const unsigned long mapping_size =3D frametable_size < MB(32) ? MB(2) + : MB(32); + int rc; + + /* + * The size of paddr_t should be sufficient for the complete range of + * physical address. + */ + BUILD_BUG_ON((sizeof(paddr_t) * BITS_PER_BYTE) < PADDR_BITS); + BUILD_BUG_ON(sizeof(struct page_info) !=3D PAGE_INFO_SIZE); + + if ( frametable_size > FRAMETABLE_SIZE ) + panic("The frametable cannot cover the physical region %#"PRIpaddr= " - %#"PRIpaddr"\n", + ps, pe); + + frametable_base_pdx =3D mfn_to_pdx(maddr_to_mfn(ps)); + /* Round up to 2M or 32M boundary, as appropriate. */ + frametable_size =3D ROUNDUP(frametable_size, mapping_size); + base_mfn =3D alloc_boot_pages(frametable_size >> PAGE_SHIFT, 32<<(20-1= 2)); + + rc =3D map_pages_to_xen(FRAMETABLE_VIRT_START, base_mfn, + frametable_size >> PAGE_SHIFT, + PAGE_HYPERVISOR_RW | _PAGE_BLOCK); + if ( rc ) + panic("Unable to setup the frametable mappings.\n"); + + memset(&frame_table[0], 0, nr_pdxs * sizeof(struct page_info)); + memset(&frame_table[nr_pdxs], -1, + frametable_size - (nr_pdxs * sizeof(struct page_info))); + + frametable_virt_end =3D FRAMETABLE_VIRT_START + (nr_pdxs * + sizeof(struct page_info= )); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.34.1