!277 Revert "EFI: allocate kernel in EFI_RUNTIME_SERVICES_CODE instead of EFI_LOADER_DATA."

From: @zhangqiumiao 
Reviewed-by: @t_feng 
Signed-off-by: @t_feng
This commit is contained in:
openeuler-ci-bot 2023-06-16 01:27:24 +00:00 committed by Gitee
commit 843d18da47
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 93 additions and 2 deletions

View File

@ -0,0 +1,85 @@
From 53b5629c9402e2d504866b6934303a8f8c2a5641 Mon Sep 17 00:00:00 2001
From: Qiumiao Zhang <zhangqiumiao1@huawei.com>
Date: Wed, 10 May 2023 19:11:17 +0800
Subject: [PATCH] Revert "EFI: allocate kernel in EFI_RUNTIME_SERVICES_CODE
instead of EFI_LOADER_DATA."
Allocates the kernel code as EFI_RUNTIME_SERVICES_CODE will cause the allocated
memory to be marked as "reserved" by BIOS, which will result in this memory being
always unavailable to the kernel.
Let's fix it by reverting backport-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch.
Signed-off-by: Qiumiao Zhang <zhangqiumiao1@huawei.com>
---
grub-core/loader/i386/efi/linux.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
index 92b2fb5..9e5c11a 100644
--- a/grub-core/loader/i386/efi/linux.c
+++ b/grub-core/loader/i386/efi/linux.c
@@ -86,9 +86,7 @@ kernel_free(void *addr, grub_efi_uintn_t size)
}
static void *
-kernel_alloc(grub_efi_uintn_t size,
- grub_efi_memory_type_t memtype,
- const char * const errmsg)
+kernel_alloc(grub_efi_uintn_t size, const char * const errmsg)
{
void *addr = 0;
unsigned int i;
@@ -114,7 +112,7 @@ kernel_alloc(grub_efi_uintn_t size,
prev_max = max;
addr = grub_efi_allocate_pages_real (max, pages,
max_addresses[i].alloc_type,
- memtype);
+ GRUB_EFI_LOADER_DATA);
if (addr)
grub_dprintf ("linux", "Allocated at %p\n", addr);
}
@@ -244,8 +242,7 @@ grub_cmd_initrd (grub_command_t cmd, int argc, char *argv[])
}
}
- initrd_mem = kernel_alloc(size, GRUB_EFI_RUNTIME_SERVICES_DATA,
- N_("can't allocate initrd"));
+ initrd_mem = kernel_alloc(size, N_("can't allocate initrd"));
if (initrd_mem == NULL)
goto fail;
grub_dprintf ("linux", "initrd_mem = %p\n", initrd_mem);
@@ -396,8 +393,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
}
#endif
- params = kernel_alloc (sizeof(*params), GRUB_EFI_RUNTIME_SERVICES_DATA,
- "cannot allocate kernel parameters");
+ params = kernel_alloc (sizeof(*params), "cannot allocate kernel parameters");
if (!params)
goto fail;
grub_dprintf ("linux", "params = %p\n", params);
@@ -419,9 +415,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
grub_dprintf ("linux", "new lh is at %p\n", lh);
grub_dprintf ("linux", "setting up cmdline\n");
- cmdline = kernel_alloc (lh->cmdline_size + 1,
- GRUB_EFI_RUNTIME_SERVICES_DATA,
- N_("can't allocate cmdline"));
+ cmdline = kernel_alloc (lh->cmdline_size + 1, N_("can't allocate cmdline"));
if (!cmdline)
goto fail;
grub_dprintf ("linux", "cmdline = %p\n", cmdline);
@@ -467,8 +461,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
max_addresses[1].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS;
max_addresses[2].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS;
kernel_size = lh->init_size;
- kernel_mem = kernel_alloc (kernel_size, GRUB_EFI_RUNTIME_SERVICES_CODE,
- N_("can't allocate kernel"));
+ kernel_mem = kernel_alloc (kernel_size, N_("can't allocate kernel"));
restore_addresses();
if (!kernel_mem)
goto fail;
--
2.19.1

View File

@ -327,3 +327,4 @@ Patch0319: backport-fs-iso9660-Avoid-reading-past-the-entry-boundary.patch
Patch0320: backport-net-bootp-Fix-unchecked-return-value.patch
Patch0321: backport-osdep-linux-hostdisk-Modify-sector-by-sysfs-as-disk-sector.patch
Patch0322: backport-Read-etc-default-grub.d-.cfg-after-etc-default-grub.patch
Patch0323: Revert-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_C.patch

View File

@ -14,7 +14,7 @@
Name: grub2
Epoch: 1
Version: 2.06
Release: 29
Release: 30
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -379,7 +379,6 @@ fi
%exclude %{_sbindir}/grub2-sparc64-setup
%exclude %{_sbindir}/grub2-ofpathname
%endif
%exclude %{_sbindir}/grub2-ofpathname
%endif
@ -441,6 +440,12 @@ fi
%{_datadir}/man/man*
%changelog
* Thu Jun 15 2023 zhangqiumiao <zhangqiumiao1@huawei.com> - 1:2.06-30
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:Revert "EFI: allocate kernel in EFI_RUNTIME_SERVICES_CODE
* Sun Apr 23 2023 zhangqiumiao <zhangqiumiao1@huawei.com> - 1:2.06-29
- Type:requirement
- CVE:NA