From patchwork Tue Mar 12 13:03:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13589966 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95C9DC54E5D for ; Tue, 12 Mar 2024 13:04:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.691814.1078248 (Exim 4.92) (envelope-from ) id 1rk1nT-0005mp-Om; Tue, 12 Mar 2024 13:03:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 691814.1078248; Tue, 12 Mar 2024 13:03:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rk1nT-0005me-K8; Tue, 12 Mar 2024 13:03:59 +0000 Received: by outflank-mailman (input) for mailman id 691814; Tue, 12 Mar 2024 13:03:57 +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 1rk1nR-0004WU-TL for xen-devel@lists.xenproject.org; Tue, 12 Mar 2024 13:03:57 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id fbd26df8-e070-11ee-a1ee-f123f15fe8a2; Tue, 12 Mar 2024 14:03:56 +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 01ADE15A1; Tue, 12 Mar 2024 06:04:33 -0700 (PDT) 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 B16933F762; Tue, 12 Mar 2024 06:03:54 -0700 (PDT) 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: fbd26df8-e070-11ee-a1ee-f123f15fe8a2 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH 05/11] xen/arm: Introduce helper for static memory pages Date: Tue, 12 Mar 2024 13:03:25 +0000 Message-Id: <20240312130331.78418-6-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312130331.78418-1-luca.fancellu@arm.com> References: <20240312130331.78418-1-luca.fancellu@arm.com> MIME-Version: 1.0 Introduce a new helper function in the static-memory module that can be called to manage static memory banks, this is done to reuse the code when other modules would like to manage static memory banks that are not part of the reserved_mem structure. Signed-off-by: Luca Fancellu Reviewed-by: Michal Orzel --- xen/arch/arm/include/asm/static-memory.h | 12 ++++++++++++ xen/arch/arm/static-memory.c | 12 +----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/include/asm/static-memory.h b/xen/arch/arm/include/asm/static-memory.h index 3e3efd70c38d..665d4df50eda 100644 --- a/xen/arch/arm/include/asm/static-memory.h +++ b/xen/arch/arm/include/asm/static-memory.h @@ -7,6 +7,18 @@ #ifdef CONFIG_STATIC_MEMORY +static inline void init_staticmem_bank(const struct membank *bank) +{ + mfn_t bank_start = _mfn(PFN_UP(bank->start)); + unsigned long bank_pages = PFN_DOWN(bank->size); + mfn_t bank_end = mfn_add(bank_start, bank_pages); + + if ( mfn_x(bank_end) <= mfn_x(bank_start) ) + return; + + unprepare_staticmem_pages(mfn_to_page(bank_start), bank_pages, false); +} + void allocate_static_memory(struct domain *d, struct kernel_info *kinfo, const struct dt_device_node *node); void assign_static_memory_11(struct domain *d, struct kernel_info *kinfo, diff --git a/xen/arch/arm/static-memory.c b/xen/arch/arm/static-memory.c index 34bd12696a53..d4585c5a0633 100644 --- a/xen/arch/arm/static-memory.c +++ b/xen/arch/arm/static-memory.c @@ -265,17 +265,7 @@ void __init init_staticmem_pages(void) for ( bank = 0 ; bank < reserved_mem->nr_banks; bank++ ) { if ( reserved_mem->bank[bank].type == MEMBANK_STATIC_DOMAIN ) - { - mfn_t bank_start = _mfn(PFN_UP(reserved_mem->bank[bank].start)); - unsigned long bank_pages = PFN_DOWN(reserved_mem->bank[bank].size); - mfn_t bank_end = mfn_add(bank_start, bank_pages); - - if ( mfn_x(bank_end) <= mfn_x(bank_start) ) - return; - - unprepare_staticmem_pages(mfn_to_page(bank_start), - bank_pages, false); - } + init_staticmem_bank(&reserved_mem->bank[bank]); } }