[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] xen/device-tree: move discard_initial_modules() to common code


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Thu, 8 Oct 2026 13:19:18 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qLSse4rAU+6PCtYi9uC8Lbii33l9MhxK/pNybWLbHno=; b=cCV22iE0kJput2j09kEiQaqasZIo7ik6kkvvwouXUbeGcl5L2c7JuDnqTAKbREH3V4/YwtNJUDMx0ZxDFPoiZPaSKRv2c8d7HSwF9KtaRvx1D2yYNGEOKLjpYGtCcN0/DUPfcj2/3G/8bBLiMiZT8YG2RI15xVyzusavvXHHdB/6630aa5eU5fwmGMJrrBe4Ki2ULXIQYDx+nplgw053puEEQFdpK+gKZBNLLbco+S/HyoS7tL0uhAd5E3C5GdfU937tfkMk9TWlBkGt2Il2JO290U2eVn+dbp4huH0tRJ0v2PphmRBVzIU6KCzjHLxZclDYitUZf1pxYHKdeuSZ6A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LBzXqK7UmbICItDxpd8o7hvmQRgOion1d1w6l8CHuA9LXqhmLCqlzMnAXd7jDcbE3gG/pWYK3QaI4Vvtvo6H4hO2flcmivmp3dmsIuLjudrSDeXjhhX7wfu+pfAOAe/NXuOaPTKM0JTnEOam8NmP+8It5VYtXpYaKoapKhYI8Zf3uWnzD/jqzQOV5gL6WukDnpfcekMwpPVGOtgunRIpNgZvuLVlmatR56i4XkhbILzT7luDJxJQj718A22TB94YjHPCkNkyKtXqBp8tkas3FuRHqMOfJyVz3V9MOGLKz6+jChxtKNW9kna/oPYMkb4tZ7VVVcWq5OGCSkyPKQsY/A==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>
  • Delivery-date: Thu, 08 Oct 2026 11:19:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 01-Oct-26 13:16, Oleksii Kurochko wrote:
> Everything discard_initial_modules() touches is already common code:
> bootinfo.modules, using_static_heap and fw_unreserved_regions(). Move it
> out of Arm into common/device-tree/bootinfo.c, next to the boot allocator
> handling of the same memory, and declare it in xen/bootinfo.h, so that
> other device-tree based architectures can reuse it instead of growing a
> copy of their own.
> 
> The arch-specific remove_early_mappings() is not moved along with it:
> how the early FDT mapping is torn down is up to the architecture. As the
> DTB is one of the boot modules being released, the mapping has to go once
> they are discarded, so call it from start_xen() right after
> discard_initial_modules(), which keeps the common function free of any
> arch dependency.
> 
> While moving it, use unsigned int for the loop counter and replace the
> "goto out" by a plain return, as there is nothing left to do at the label.
> 
> No functional change.
> 
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
> ---
>  xen/arch/arm/include/asm/setup.h  |  2 --
>  xen/arch/arm/setup.c              | 35 ++-----------------------------
>  xen/common/device-tree/bootinfo.c | 30 ++++++++++++++++++++++++++
>  xen/include/xen/bootinfo.h        |  8 +++++++
>  4 files changed, 40 insertions(+), 35 deletions(-)
> 
> diff --git a/xen/arch/arm/include/asm/setup.h 
> b/xen/arch/arm/include/asm/setup.h
> index c491c567298f..02fdf2b56c9c 100644
> --- a/xen/arch/arm/include/asm/setup.h
> +++ b/xen/arch/arm/include/asm/setup.h
> @@ -40,8 +40,6 @@ int acpi_make_efi_nodes(void *fdt, struct membank 
> tbl_add[]);
>  
>  void create_dom0(void);
>  
> -void discard_initial_modules(void);
> -
>  void init_pdx(void);
>  void setup_mm(void);
>  
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 16f899dff57b..a65c3d2a655e 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -210,39 +210,6 @@ static void __init processor_id(void)
>      processor_setup();
>  }
>  
> -void __init discard_initial_modules(void)
> -{
> -    struct boot_modules *mi = &bootinfo.modules;
> -    int i;
> -
> -    /*
> -     * When using static heap feature, don't give boot_modules memory back to
> -     * the heap allocator
> -     */
> -    if ( using_static_heap )
> -        goto out;
> -
> -    for ( i = 0; i < mi->nr_mods; i++ )
> -    {
> -        paddr_t s = mi->module[i].start;
> -        paddr_t e = s + PAGE_ALIGN(mi->module[i].size);
> -
> -        if ( mi->module[i].kind == BOOTMOD_XEN )
> -            continue;
> -
> -        if ( !mfn_valid(maddr_to_mfn(s)) ||
> -             !mfn_valid(maddr_to_mfn(e)) )
> -            continue;
> -
> -        fw_unreserved_regions(s, e, init_domheap_pages, 0);
> -    }
> -
> -    mi->nr_mods = 0;
> -
> - out:
> -    remove_early_mappings();
> -}
> -
>  /* Relocate the FDT in Xen heap */
>  static void __init relocate_fdt(const void **dtb_vaddr, size_t dtb_size)
>  {
> @@ -509,6 +476,8 @@ void asmlinkage __init noreturn start_xen(unsigned long 
> fdt_paddr)
>       */
>      discard_initial_modules();
The comment above is now duplicated with the one you added in xen/bootinfo.h.
I'd drop it from here (can be done on commit).

Other than that:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

NIT for the future: if you send a series of patches, please move the fixes/code
movement changes at the beginning of the series.

~Michal




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.