Message ID | 20220627233837.1263654-2-marcelo.cerri@canonical.com |
---|---|
State | New |
Headers | show |
Series | LP:#1980023 - Properly realocate the the kernel image | expand |
Acked-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com> On Mon, Jun 27, 2022 at 4:39 PM Marcelo Henrique Cerri < marcelo.cerri@canonical.com> wrote: > From: Arvind Sankar <nivedita@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@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@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@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@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team >
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);