diff options
author | Ard Biesheuvel <ardb@kernel.org> | 2023-04-18 16:49:50 +0300 |
---|---|---|
committer | Ard Biesheuvel <ardb@kernel.org> | 2023-04-20 16:44:35 +0300 |
commit | bca2f3a9406b89961fbc6c92c52c6fc1fd91d35f (patch) | |
tree | 3554f33a89364b36b27920fc188bb16e2e894d46 /drivers/firmware/efi/libstub/zboot.c | |
parent | 8358098b9787caab8bbc93fd78d046afaed43c16 (diff) | |
download | linux-bca2f3a9406b89961fbc6c92c52c6fc1fd91d35f.tar.xz |
efi/zboot: Add BSS padding before compression
We don't really care about the size of the decompressed image - what
matters is how much space needs to be allocated for the image to
execute, and this includes space for BSS that is not part of the
loadable image and so it is not accounted for in the decompressed size.
So let's add some zero padding to the end of the image: this compresses
well, and it ensures that BSS is accounted for, and as a bonus, it will
be zeroed before launching the image.
Since all architectures that implement support for EFI zboot carry this
value in the header in the same location, we can just grab it from the
binary that is being compressed.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'drivers/firmware/efi/libstub/zboot.c')
-rw-r--r-- | drivers/firmware/efi/libstub/zboot.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/firmware/efi/libstub/zboot.c b/drivers/firmware/efi/libstub/zboot.c index 6105e5e2eda4..63ece4800900 100644 --- a/drivers/firmware/efi/libstub/zboot.c +++ b/drivers/firmware/efi/libstub/zboot.c @@ -91,12 +91,12 @@ efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab) efi_info("Decompressing Linux Kernel...\n"); // SizeOfImage from the compressee's PE/COFF header - alloc_size = round_up(get_unaligned_le32(_gzdata_end - 4), + alloc_size = round_up(get_unaligned_le32(_gzdata_end - 12), EFI_ALLOC_ALIGN); // SizeOfHeaders and SizeOfCode from the compressee's PE/COFF header - code_size = get_unaligned_le32(_gzdata_end - 8) + - get_unaligned_le32(_gzdata_end - 12); + code_size = get_unaligned_le32(_gzdata_end - 4) + + get_unaligned_le32(_gzdata_end - 8); // If the architecture has a preferred address for the image, // try that first. |