From nobody Thu Oct 30 23:13:05 2025 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 175386517875940.27832979365803; Wed, 30 Jul 2025 01:46:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1063530.1429233 (Exim 4.92) (envelope-from ) id 1uh2Rd-0007DE-05; Wed, 30 Jul 2025 08:45:53 +0000 Received: by outflank-mailman (output) from mailman id 1063530.1429233; Wed, 30 Jul 2025 08:45: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 1uh2Rc-0007D7-Sn; Wed, 30 Jul 2025 08:45:52 +0000 Received: by outflank-mailman (input) for mailman id 1063530; Wed, 30 Jul 2025 08:45:51 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uh2Rb-0006zM-JZ for xen-devel@lists.xenproject.org; Wed, 30 Jul 2025 08:45:51 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 987d4913-6d21-11f0-a320-13f23c93f187; Wed, 30 Jul 2025 10:45:51 +0200 (CEST) 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 6C0721BC0; Wed, 30 Jul 2025 01:45:42 -0700 (PDT) Received: from PWQ0QT7DJ1.arm.com (unknown [10.57.73.135]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 098FF3F66E; Wed, 30 Jul 2025 01:45:48 -0700 (PDT) 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: 987d4913-6d21-11f0-a320-13f23c93f187 From: Hari Limaye To: xen-devel@lists.xenproject.org Cc: luca.fancellu@arm.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH 1/5] arm/mpu: Implement setup_frametable_mappings for MPU systems Date: Wed, 30 Jul 2025 09:45:30 +0100 Message-ID: X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1753865181109116600 Content-Type: text/plain; charset="utf-8" From: Luca Fancellu Implement the MPU variant of `setup_frametable_mappings`. This function will be called by `setup_mm` when an implementation for MPU systems is added in a follow up commit. Signed-off-by: Luca Fancellu Signed-off-by: Hari Limaye Reviewed-by: Ayan Kumarb Halder Reviewed-by: Michal Orzel Tested-by: Ayan Kumarb Halder --- xen/arch/arm/mpu/mm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/xen/arch/arm/mpu/mm.c b/xen/arch/arm/mpu/mm.c index c6891607ec..6a16fa348d 100644 --- a/xen/arch/arm/mpu/mm.c +++ b/xen/arch/arm/mpu/mm.c @@ -168,6 +168,25 @@ int mpumap_contains_region(pr_t *table, uint8_t nr_reg= ions, paddr_t base, return MPUMAP_REGION_NOTFOUND; } =20 +/* Map a frame table to cover physical addresses ps through pe */ +void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) +{ + mfn_t base_mfn; + 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); + + frametable_base_pdx =3D paddr_to_pdx(ps); + frametable_size =3D ROUNDUP(frametable_size, PAGE_SIZE); + + base_mfn =3D alloc_boot_pages(frametable_size >> PAGE_SHIFT, 1); + frame_table =3D (struct page_info *)mfn_to_virt(mfn_x(base_mfn)); + + 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))); +} + /* * Allocate an entry for a new EL2 MPU region in the bitmap xen_mpumap_mas= k. * @param idx Set to the index of the allocated EL2 MPU region on succes= s. --=20 2.34.1