LoongArch: Add support for new efi screen info GUID

Signed-off-by: mengyingkun <mengyingkun@loongson.cn>
(cherry picked from commit 722a77ccf7c3d61301d934b3347b8938ba54d033)
This commit is contained in:
mengyingkun 2023-03-10 11:19:44 +08:00 committed by openeuler-sync-bot
parent 92c0af426f
commit 1ba4b16683
3 changed files with 70 additions and 1 deletions

View File

@ -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

View File

@ -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 <mengyingkun@loongson.cn> - 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 <mengyingkun@loongson.cn> - 1:2.06-23
- Type:bugfix
- CVE:NA

View File

@ -0,0 +1,62 @@
From dc3d6e1b080e61a02a8e02e090e3910ca168e616 Mon Sep 17 00:00:00 2001
From: mengyingkun <mengyingkun@loongson.cn>
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 <mengyingkun@loongson.cn>
---
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