[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Relocation overflow on RISC-V with multi-range memory layout
From: |
Wu, Fei |
Subject: |
Relocation overflow on RISC-V with multi-range memory layout |
Date: |
Mon, 25 Sep 2023 16:51:46 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.15.1 |
Hi All,
I'm enabling PCIe passthrough on qemu riscv, the physical memory
range between 3GB and 4GB is reserved. Therefore if guest has 4GB ram,
two ranges are created as [2G, 3G) and [4G, 7G). More details can be
found here:
https://lore.kernel.org/all/CAKmqyKMtAzt5saCUMd4vXYfgAQibpzQJAhtTSuSb+yeKhcYpfw@mail.gmail.com/T/
When run grub.efi from uefi shell, a relocation problem happened in
grub_arch_dl_relocate_symbols() of grub-core/kern/riscv/dl.c:
case R_RISCV_CALL:
case R_RISCV_CALL_PLT:
{
grub_uint32_t *abs_place = place;
grub_ssize_t off = sym_addr - (grub_addr_t) place;
grub_uint32_t hi20, lo12;
if (off != (grub_int32_t) off)
return grub_error (GRUB_ERR_BAD_MODULE, "relocation
overflow");
It requires `off' in the range of int32, but it's not enforced since the
>4GB memory can be used. I'm not familiar with grub, but this patch does
work for me:
--- a/include/grub/riscv64/efi/memory.h
+++ b/include/grub/riscv64/efi/memory.h
@@ -1,6 +1,6 @@
#ifndef GRUB_MEMORY_CPU_HEADER
#include <grub/efi/memory.h>
-#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffULL
Any comments?
Thanks,
Fei.
- Relocation overflow on RISC-V with multi-range memory layout,
Wu, Fei <=