[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <f75c763d86529a47eb23d46c5ef9bcbaaf118200.1690274483.git.petr.tesarik.ext@huawei.com>
Date: Tue, 25 Jul 2023 10:44:26 +0200
From: Petr Tesarik <petrtesarik@...weicloud.com>
To: Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Conor Dooley <conor.dooley@...rochip.com>,
Li Huafei <lihuafei1@...wei.com>,
Liao Chang <liaochang1@...wei.com>,
Masahiro Yamada <masahiroy@...nel.org>,
Alyssa Ross <hi@...ssa.is>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Ricardo Ribalda <ribalda@...omium.org>,
Kees Cook <keescook@...omium.org>,
Heiko Stuebner <heiko@...ech.de>,
Li Zhengyu <lizhengyu3@...wei.com>,
linux-riscv@...ts.infradead.org (open list:RISC-V ARCHITECTURE),
linux-kernel@...r.kernel.org (open list)
Cc: Roberto Sassu <roberto.sassu@...weicloud.com>, petr@...arici.cz
Subject: [PATCH v1 2/3] riscv/kexec: handle R_RISCV_ADD16 and R_RISCV_SUB16 relocation types
From: Petr Tesarik <petr.tesarik.ext@...wei.com>
16-bit add and subtract relocation types are used by the purgatory code
when the kernel is built with CONFIG_RISCV_ALTERNATIVES. If they are not
handled, kexec_file_load(2) fails with:
Unknown rela relocation: 34
kexec_image: Error loading purgatory ret=-8
or later with:
Unknown rela relocation: 38
kexec_image: Error loading purgatory ret=-8
Note that alternatives are not yet handled in purgatory code; this patch
merely allows to load it.
Fixes: 838b3e28488f ("RISC-V: Load purgatory in kexec_file")
Signed-off-by: Petr Tesarik <petr.tesarik.ext@...wei.com>
Cc: Li Zhengyu <lizhengyu3@...wei.com>
Cc: stable@...r.kernel.org
---
arch/riscv/kernel/elf_kexec.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c
index 38390d3bdcac..f23fd419c402 100644
--- a/arch/riscv/kernel/elf_kexec.c
+++ b/arch/riscv/kernel/elf_kexec.c
@@ -444,6 +444,12 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
case R_RISCV_SUB32:
*(u32 *)loc -= val;
break;
+ case R_RISCV_ADD16:
+ *(u16 *)loc += val;
+ break;
+ case R_RISCV_SUB16:
+ *(u16 *)loc -= val;
+ break;
/* It has been applied by R_RISCV_PCREL_HI20 sym */
case R_RISCV_PCREL_LO12_I:
case R_RISCV_ALIGN:
--
2.25.1
Powered by blists - more mailing lists