ACK: [focal:linux-azure-cvm][PATCH 1/1] efi/x86: Only copy the compressed kernel image in efi_relocate_kernel()

Luke Nowakowski-Krijger luke.nowakowskikrijger at canonical.com
Tue Jun 28 01:30:36 UTC 2022


Acked-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger at canonical.com>

On Mon, Jun 27, 2022 at 4:39 PM Marcelo Henrique Cerri <
marcelo.cerri at canonical.com> wrote:

> From: Arvind Sankar <nivedita at alum.mit.edu>
>
> BugLink: https://bugs.launchpad.net/bugs/1980023
>
> The image_size argument to efi_relocate_kernel() is currently specified
> as init_size, but this is unnecessarily large. The compressed kernel is
> much smaller, in fact, its image only extends up to the start of _bss,
> since at this point, the .bss section is still uninitialized.
>
> Depending on compression level, this can reduce the amount of data
> copied by 4-5x.
>
> Signed-off-by: Arvind Sankar <nivedita at alum.mit.edu>
> Link:
> https://lore.kernel.org/r/20201011142012.96493-1-nivedita@alum.mit.edu
> Signed-off-by
> <https://lore.kernel.org/r/20201011142012.96493-1-nivedita@alum.mit.eduSigned-off-by>:
> Ard Biesheuvel <ardb at kernel.org>
> (back ported from commit 688eb28211abdf82a3f51e8997f1c8137947227d)
> [marcelo.cerri: replicate the same change in eboot.c instead because
>  it was merged into libstub in 5.7 by c2d0b470154c]
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri at canonical.com>
> ---
>  arch/x86/boot/compressed/eboot.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/boot/compressed/eboot.c
> b/arch/x86/boot/compressed/eboot.c
> index 82bc60c8acb2..59a5ea4f64f9 100644
> --- a/arch/x86/boot/compressed/eboot.c
> +++ b/arch/x86/boot/compressed/eboot.c
> @@ -810,9 +810,11 @@ efi_main(struct efi_config *c, struct boot_params
> *boot_params)
>          * address, relocate it.
>          */
>         if (hdr->pref_address != hdr->code32_start) {
> +               extern char _bss[];
>                 unsigned long bzimage_addr = hdr->code32_start;
>                 status = efi_relocate_kernel(sys_table, &bzimage_addr,
> -                                            hdr->init_size,
> hdr->init_size,
> +                                            (unsigned long)_bss -
> bzimage_addr,
> +                                            hdr->init_size,
>                                              hdr->pref_address,
>                                              hdr->kernel_alignment,
>                                              LOAD_PHYSICAL_ADDR);
> --
> 2.25.1
>
>
> --
> kernel-team mailing list
> kernel-team at lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20220627/140d25a3/attachment-0001.html>


More information about the kernel-team mailing list