From 1ba4b166834e7745b8b6bcc961e8873c586fff0b Mon Sep 17 00:00:00 2001 From: mengyingkun Date: Fri, 10 Mar 2023 11:19:44 +0800 Subject: [PATCH] LoongArch: Add support for new efi screen info GUID Signed-off-by: mengyingkun (cherry picked from commit 722a77ccf7c3d61301d934b3347b8938ba54d033) --- grub.patches | 1 + grub2.spec | 8 ++- ...support-for-new-EFI-screen-info-GUID.patch | 62 +++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 loongarch-Add-support-for-new-EFI-screen-info-GUID.patch diff --git a/grub.patches b/grub.patches index c08de25..4c6b329 100644 --- a/grub.patches +++ b/grub.patches @@ -307,4 +307,5 @@ Patch0303: backport-fs-iso9660-Fix-memory-leaks-in-grub_iso9660_susp_ite.patch %ifarch loongarch64 Patch0304: loongarch-Add-EFI-frame-buffer-support.patch Patch0305: loongarch-Add-support-for-v4.0-interface.patch +Patch0306: loongarch-Add-support-for-new-EFI-screen-info-GUID.patch %endif diff --git a/grub2.spec b/grub2.spec index 2974f3b..a4e20d3 100644 --- a/grub2.spec +++ b/grub2.spec @@ -14,7 +14,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 23 +Release: 24 Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -439,6 +439,12 @@ fi %{_datadir}/man/man* %changelog +* Fri Mar 10 2023 mengyingkun - 1:2.06-24 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:loongarch: Add support for new EFI screen info GUID + * Mon Feb 13 2023 mengyingkun - 1:2.06-23 - Type:bugfix - CVE:NA diff --git a/loongarch-Add-support-for-new-EFI-screen-info-GUID.patch b/loongarch-Add-support-for-new-EFI-screen-info-GUID.patch new file mode 100644 index 0000000..de359aa --- /dev/null +++ b/loongarch-Add-support-for-new-EFI-screen-info-GUID.patch @@ -0,0 +1,62 @@ +From dc3d6e1b080e61a02a8e02e090e3910ca168e616 Mon Sep 17 00:00:00 2001 +From: mengyingkun +Date: Fri, 10 Mar 2023 11:00:51 +0800 +Subject: [PATCH] loongarch: Add support for new EFI screen info GUID + +Support new screen info GUID defined by upstream kernel, and +keep compatible with old GUID defined by loongson. + +Signed-off-by: mengyingkun +--- + grub-core/loader/loongarch64/linux-elf.c | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/grub-core/loader/loongarch64/linux-elf.c b/grub-core/loader/loongarch64/linux-elf.c +index 15f9984..86a90e7 100644 +--- a/grub-core/loader/loongarch64/linux-elf.c ++++ b/grub-core/loader/loongarch64/linux-elf.c +@@ -58,8 +58,14 @@ + { 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68 } \ + } + ++#define GRUB_EFI_SCREEN_INFO_GUID \ ++ { 0xe03fc20a, 0x85dc, 0x406e, \ ++ { 0xb9, 0x0e, 0x4a, 0xb5, 0x02, 0x37, 0x1d, 0x95 } \ ++ } ++ + static struct grub_relocator *relocator; +-static grub_efi_guid_t screen_info_guid = GRUB_EFI_LARCH_SCREEN_INFO_GUID; ++static grub_efi_guid_t compat_screen_info_guid = GRUB_EFI_LARCH_SCREEN_INFO_GUID; ++static grub_efi_guid_t screen_info_guid = GRUB_EFI_SCREEN_INFO_GUID; + + void grub_linux_loongarch_elf_relocator_unload (void) + { +@@ -161,10 +167,17 @@ alloc_screen_info (void) + if (status != GRUB_EFI_SUCCESS) + return NULL; + ++ status = b->install_configuration_table (&compat_screen_info_guid, si); ++ if (status != GRUB_EFI_SUCCESS) ++ goto free_mem; ++ + status = b->install_configuration_table (&screen_info_guid, si); + if (status == GRUB_EFI_SUCCESS) + return si; + ++free_table: ++ b->install_configuration_table (&compat_screen_info_guid, NULL); ++free_mem: + efi_call_1 (b->free_pool, si); + + return NULL; +@@ -276,6 +289,7 @@ setup_screen_info (void) + + free_screen_info: + b = grub_efi_system_table->boot_services; ++ b->install_configuration_table (&compat_screen_info_guid, NULL); + b->install_configuration_table (&screen_info_guid, NULL); + if (si) + efi_call_1 (b->free_pool, si); +-- +2.33.0 +