Skip to content

Commit 607271b

Browse files
committed
x86/efi-bgrt: Use efi_mem_reserve() to avoid copying image data
efi_mem_reserve() allows us to permanently mark EFI boot services regions as reserved, which means we no longer need to copy the image data out and into a separate buffer. Leaving the data in the original boot services region has the added benefit that BGRT images can now be passed across kexec reboot. Reviewed-by: Josh Triplett <josh@joshtriplett.org> Tested-by: Dave Young <dyoung@redhat.com> [kexec/kdump] Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> [arm] Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Peter Jones <pjones@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Josh Boyer <jwboyer@fedoraproject.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Môshe van der Sterre <me@moshe.nl> Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
1 parent 8c8a2e8 commit 607271b

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

arch/x86/platform/efi/efi-bgrt.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,12 @@ void __init efi_bgrt_init(void)
8282
}
8383
bgrt_image_size = bmp_header.size;
8484

85-
bgrt_image = kmalloc(bgrt_image_size, GFP_KERNEL | __GFP_NOWARN);
85+
bgrt_image = memremap(bgrt_tab->image_address, bmp_header.size, MEMREMAP_WB);
8686
if (!bgrt_image) {
87-
pr_notice("Ignoring BGRT: failed to allocate memory for image (wanted %zu bytes)\n",
88-
bgrt_image_size);
89-
return;
90-
}
91-
92-
image = memremap(bgrt_tab->image_address, bmp_header.size, MEMREMAP_WB);
93-
if (!image) {
9487
pr_notice("Ignoring BGRT: failed to map image memory\n");
95-
kfree(bgrt_image);
9688
bgrt_image = NULL;
9789
return;
9890
}
9991

100-
memcpy(bgrt_image, image, bgrt_image_size);
101-
memunmap(image);
92+
efi_mem_reserve(bgrt_tab->image_address, bgrt_image_size);
10293
}

0 commit comments

Comments
 (0)