代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/grub2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 062741f3d9878bcbd4556f3bfe73d1bead458255 Mon Sep 17 00:00:00 2001
From: mengyingkun <mengyingkun@loongson.cn>
Date: Thu, 2 Feb 2023 20:32:17 +0800
Subject: [PATCH] loongarch: Modify the location where initrd is loaded into
memory
Try to allocate memory from higher than 256MB to
avoid kernel relocation overlaying initrd. If failed,
allocate memory in range 0~256MB, and high address
takes precedence.
Signed-off-by: mengyingkun <mengyingkun@loongson.cn>
---
grub-core/loader/loongarch64/linux-elf.c | 21 +++++++++++++++++++++
grub-core/loader/loongarch64/linux.c | 2 +-
include/grub/loongarch64/linux.h | 5 +++++
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/grub-core/loader/loongarch64/linux-elf.c b/grub-core/loader/loongarch64/linux-elf.c
index 85585b4..8260e4c 100644
--- a/grub-core/loader/loongarch64/linux-elf.c
+++ b/grub-core/loader/loongarch64/linux-elf.c
@@ -304,6 +304,27 @@ grub_linux_loongarch_alloc_virtual_mem_align (grub_size_t size,
return get_virtual_current_address (ch);
}
+void*
+grub_linux_loongarch_alloc_initrd_mem_align (grub_size_t size,
+ grub_size_t align,
+ grub_err_t *err)
+{
+ grub_relocator_chunk_t ch;
+
+ /* Firstly try to allocate from memory higher than 256MB */
+ *err = grub_relocator_alloc_chunk_align (relocator, &ch,
+ 0x10000000, (0xffffffff - size) + 1, size, align,
+ GRUB_RELOCATOR_PREFERENCE_LOW, 0);
+ if (*err != GRUB_ERR_NONE)
+ {
+ /* Failed, try to allocate in range 0 ~ 256MB */
+ *err = grub_relocator_alloc_chunk_align (relocator, &ch,
+ 0, (0xfffffff - size) + 1, size, align,
+ GRUB_RELOCATOR_PREFERENCE_HIGH, 0);
+ }
+ return get_virtual_current_address (ch);
+}
+
int
grub_linux_loongarch_elf_get_boot_params (struct boot_params_interface **boot_params)
{
diff --git a/grub-core/loader/loongarch64/linux.c b/grub-core/loader/loongarch64/linux.c
index 783054b..4c02194 100644
--- a/grub-core/loader/loongarch64/linux.c
+++ b/grub-core/loader/loongarch64/linux.c
@@ -351,7 +351,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
initrd_mem = allocate_initrd_mem (initrd_pages);
} else {
grub_err_t err;
- initrd_mem = grub_linux_loongarch_alloc_virtual_mem_align (initrd_size, 0x10000, &err);
+ initrd_mem = grub_linux_loongarch_alloc_initrd_mem_align (initrd_size, 0x10000, &err);
if (err)
goto fail;
}
diff --git a/include/grub/loongarch64/linux.h b/include/grub/loongarch64/linux.h
index af1f51d..f4b198a 100644
--- a/include/grub/loongarch64/linux.h
+++ b/include/grub/loongarch64/linux.h
@@ -129,6 +129,11 @@ grub_linux_loongarch_alloc_virtual_mem_align (grub_size_t size,
grub_size_t align,
grub_err_t *err);
+void*
+grub_linux_loongarch_alloc_initrd_mem_align (grub_size_t size,
+ grub_size_t align,
+ grub_err_t *err);
+
void
grub_linux_loongarch_elf_relocator_unload (void);
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。