lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAhV-H5xc_Lp2=71goHF1nT4gHoavVKHPLuXRykU=7EMPS_QfQ@mail.gmail.com>
Date: Thu, 26 Jun 2025 20:34:21 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Ming Wang <wangming01@...ngson.cn>
Cc: Ard Biesheuvel <ardb@...nel.org>, WANG Xuerui <kernel@...0n.name>, linux-efi@...r.kernel.org, 
	loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org, 
	lixuefeng@...ngson.cn, chenhuacai@...ngson.cn, gaojuxin@...ngson.cn
Subject: Re: [PATCH] efi/loongarch: Reserve EFI memory map region

Applied with some modifications, thanks.

https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git/commit/?h=loongarch-next&id=39503fc84b4ea94f2bedca481de5e225e0df729d

Huacai

On Tue, Jun 24, 2025 at 4:19 PM Ming Wang <wangming01@...ngson.cn> wrote:
>
> The EFI memory map at 'boot_memmap' is crucial for kdump to understand
> the primary kernel's memory layout. This memory region, typically part
> of EFI Boot Services (BS) data, can be overwritten after ExitBootServices
> if not explicitly preserved by the kernel.
>
> This commit addresses this by:
> 1. Calling memblock_reserve() to reserve the entire physical region
>    occupied by the EFI memory map (header + descriptors). This prevents
>    the primary kernel from reallocating and corrupting this area.
> 2. Setting the EFI_PRESERVE_BS_REGIONS flag in efi.flags. This indicates
>    that efforts have been made to preserve critical BS data regions,
>    which can be useful for other kernel subsystems or debugging.
>
> These changes ensure the original EFI memory map data remains intact,
> improving kdump reliability and potentially aiding other EFI-related
> functionalities that might rely on preserved BS data.
>
> Signed-off-by: Ming Wang <wangming01@...ngson.cn>
> ---
>  arch/loongarch/kernel/efi.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c
> index de21e72759ee..98b1f0c030fc 100644
> --- a/arch/loongarch/kernel/efi.c
> +++ b/arch/loongarch/kernel/efi.c
> @@ -135,6 +135,7 @@ void __init efi_init(void)
>         tbl = early_memremap_ro(boot_memmap, sizeof(*tbl));
>         if (tbl) {
>                 struct efi_memory_map_data data;
> +               phys_addr_t reserve_size = sizeof(*tbl) + tbl->map_size;
>
>                 data.phys_map           = boot_memmap + sizeof(*tbl);
>                 data.size               = tbl->map_size;
> @@ -144,6 +145,18 @@ void __init efi_init(void)
>                 if (efi_memmap_init_early(&data) < 0)
>                         panic("Unable to map EFI memory map.\n");
>
> +               /*
> +                * Reserve the physical memory region occupied by the EFI
> +                * memory map table (header + descriptors). This is crucial
> +                * for kdump, as the kdump kernel relies on this original
> +                * memmap passed by the bootloader. Without reservation,
> +                * this region could be overwritten by the primary kernel.
> +                * Also, set the EFI_PRESERVE_BS_REGIONS flag to indicate that
> +                * critical boot services data regions like this are preserved.
> +                */
> +               memblock_reserve((phys_addr_t)boot_memmap, reserve_size);
> +               set_bit(EFI_PRESERVE_BS_REGIONS, &efi.flags);
> +
>                 early_memunmap(tbl, sizeof(*tbl));
>         }
>
> --
> 2.43.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ