* [PATCH] efi/x86: Only copy the compressed kernel image in efi_relocate_kernel()
@ 2020-10-11 14:20 Arvind Sankar
2020-10-25 16:19 ` Arvind Sankar
0 siblings, 1 reply; 4+ messages in thread
From: Arvind Sankar @ 2020-10-11 14:20 UTC (permalink / raw)
To: linux-efi; +Cc: linux-kernel
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>
---
drivers/firmware/efi/libstub/x86-stub.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index 3672539cb96e..f14c4ff5839f 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -715,8 +715,11 @@ unsigned long efi_main(efi_handle_t handle,
(IS_ENABLED(CONFIG_X86_32) && buffer_end > KERNEL_IMAGE_SIZE) ||
(IS_ENABLED(CONFIG_X86_64) && buffer_end > MAXMEM_X86_64_4LEVEL) ||
(image_offset == 0)) {
+ extern char _bss[];
+
status = efi_relocate_kernel(&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.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] efi/x86: Only copy the compressed kernel image in efi_relocate_kernel()
2020-10-11 14:20 [PATCH] efi/x86: Only copy the compressed kernel image in efi_relocate_kernel() Arvind Sankar
@ 2020-10-25 16:19 ` Arvind Sankar
2020-10-25 16:28 ` Ard Biesheuvel
0 siblings, 1 reply; 4+ messages in thread
From: Arvind Sankar @ 2020-10-25 16:19 UTC (permalink / raw)
To: Arvind Sankar; +Cc: linux-efi, linux-kernel
On Sun, Oct 11, 2020 at 10:20:12AM -0400, Arvind Sankar wrote:
> 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>
Ping
> ---
> drivers/firmware/efi/libstub/x86-stub.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> index 3672539cb96e..f14c4ff5839f 100644
> --- a/drivers/firmware/efi/libstub/x86-stub.c
> +++ b/drivers/firmware/efi/libstub/x86-stub.c
> @@ -715,8 +715,11 @@ unsigned long efi_main(efi_handle_t handle,
> (IS_ENABLED(CONFIG_X86_32) && buffer_end > KERNEL_IMAGE_SIZE) ||
> (IS_ENABLED(CONFIG_X86_64) && buffer_end > MAXMEM_X86_64_4LEVEL) ||
> (image_offset == 0)) {
> + extern char _bss[];
> +
> status = efi_relocate_kernel(&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.26.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] efi/x86: Only copy the compressed kernel image in efi_relocate_kernel()
2020-10-25 16:19 ` Arvind Sankar
@ 2020-10-25 16:28 ` Ard Biesheuvel
2020-10-25 17:24 ` Arvind Sankar
0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2020-10-25 16:28 UTC (permalink / raw)
To: Arvind Sankar; +Cc: linux-efi, Linux Kernel Mailing List
On Sun, 25 Oct 2020 at 17:19, Arvind Sankar <nivedita@alum.mit.edu> wrote:
>
> On Sun, Oct 11, 2020 at 10:20:12AM -0400, Arvind Sankar wrote:
> > 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>
>
> Ping
>
I'll pick this up as a fix once the merge window closes.
> > ---
> > drivers/firmware/efi/libstub/x86-stub.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> > index 3672539cb96e..f14c4ff5839f 100644
> > --- a/drivers/firmware/efi/libstub/x86-stub.c
> > +++ b/drivers/firmware/efi/libstub/x86-stub.c
> > @@ -715,8 +715,11 @@ unsigned long efi_main(efi_handle_t handle,
> > (IS_ENABLED(CONFIG_X86_32) && buffer_end > KERNEL_IMAGE_SIZE) ||
> > (IS_ENABLED(CONFIG_X86_64) && buffer_end > MAXMEM_X86_64_4LEVEL) ||
> > (image_offset == 0)) {
> > + extern char _bss[];
> > +
> > status = efi_relocate_kernel(&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.26.2
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] efi/x86: Only copy the compressed kernel image in efi_relocate_kernel()
2020-10-25 16:28 ` Ard Biesheuvel
@ 2020-10-25 17:24 ` Arvind Sankar
0 siblings, 0 replies; 4+ messages in thread
From: Arvind Sankar @ 2020-10-25 17:24 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: Arvind Sankar, linux-efi, Linux Kernel Mailing List
On Sun, Oct 25, 2020 at 05:28:06PM +0100, Ard Biesheuvel wrote:
> On Sun, 25 Oct 2020 at 17:19, Arvind Sankar <nivedita@alum.mit.edu> wrote:
> >
> > On Sun, Oct 11, 2020 at 10:20:12AM -0400, Arvind Sankar wrote:
> > > 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>
> >
> > Ping
> >
>
> I'll pick this up as a fix once the merge window closes.
Thanks!
>
> > > ---
> > > drivers/firmware/efi/libstub/x86-stub.c | 5 ++++-
> > > 1 file changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> > > index 3672539cb96e..f14c4ff5839f 100644
> > > --- a/drivers/firmware/efi/libstub/x86-stub.c
> > > +++ b/drivers/firmware/efi/libstub/x86-stub.c
> > > @@ -715,8 +715,11 @@ unsigned long efi_main(efi_handle_t handle,
> > > (IS_ENABLED(CONFIG_X86_32) && buffer_end > KERNEL_IMAGE_SIZE) ||
> > > (IS_ENABLED(CONFIG_X86_64) && buffer_end > MAXMEM_X86_64_4LEVEL) ||
> > > (image_offset == 0)) {
> > > + extern char _bss[];
> > > +
> > > status = efi_relocate_kernel(&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.26.2
> > >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-25 17:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-11 14:20 [PATCH] efi/x86: Only copy the compressed kernel image in efi_relocate_kernel() Arvind Sankar
2020-10-25 16:19 ` Arvind Sankar
2020-10-25 16:28 ` Ard Biesheuvel
2020-10-25 17:24 ` Arvind Sankar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).