kexec_file() support was recently added for RISC-V [1], which triggered
a handful of build issues on rv32. These all seemed pretty minor, but
it looks like this is the only 32-bit platform that has attempted to
build the kexec IMA support before so I'm not sure if there's something
more complicated going on that I'm missing (I haven't tested any of
this).
The rv64 support was just merged into kernel.org/riscv/linux/for-next as
83a7a614ce58 ("riscv: kexec: add kexec_file_load() support"). I've put
these on top of the pre-merged version at
kernel.org/palmer/linux/riscv-kexec_file-rv32 if that helps anyone.
1: https://lore.kernel.org/all/[email protected]/
From: Palmer Dabbelt <[email protected]>
This uses an explicit "ld" to load up target address, which dosn't work
on rv32. Convert it to a REG_L macro, like everywhere else.
Signed-off-by: Palmer Dabbelt <[email protected]>
---
arch/riscv/purgatory/entry.S | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/purgatory/entry.S b/arch/riscv/purgatory/entry.S
index 0194f4554130..71c50fef051c 100644
--- a/arch/riscv/purgatory/entry.S
+++ b/arch/riscv/purgatory/entry.S
@@ -8,6 +8,8 @@
*
*/
+#include <asm/asm.h>
+
.macro size, sym:req
.size \sym, . - \sym
.endm
@@ -26,7 +28,7 @@ purgatory_start:
/* Start new image. */
mv a0, s0
mv a1, s1
- ld a2, riscv_kernel_entry
+ REG_L a2, riscv_kernel_entry
jr a2
size purgatory_start
@@ -41,7 +43,7 @@ size purgatory_start
.globl riscv_kernel_entry
riscv_kernel_entry:
- .quad 0
+ REG_ASM 0
size riscv_kernel_entry
.end
--
2.34.1
From: Palmer Dabbelt <[email protected]>
ima_dump_measurement_list() took an "unsigned long *", but was passed a
size_t. This triggers build warnings on 32-bit RISC-V.
Signed-off-by: Palmer Dabbelt <[email protected]>
---
security/integrity/ima/ima_kexec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c
index 13753136f03f..f2a94ec3002a 100644
--- a/security/integrity/ima/ima_kexec.c
+++ b/security/integrity/ima/ima_kexec.c
@@ -15,7 +15,7 @@
#include "ima.h"
#ifdef CONFIG_IMA_KEXEC
-static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
+static int ima_dump_measurement_list(size_t *buffer_size, void **buffer,
unsigned long segment_size)
{
struct ima_queue_entry *qe;
--
2.34.1
From: Palmer Dabbelt <[email protected]>
Most of the Elf macros automatically select the correct Elf type, this
converts the one explicit Elf64 usage to depend on XLEN.
Signed-off-by: Palmer Dabbelt <[email protected]>
---
arch/riscv/kernel/elf_kexec.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c
index 9cb85095fd45..4532e3cf17a5 100644
--- a/arch/riscv/kernel/elf_kexec.c
+++ b/arch/riscv/kernel/elf_kexec.c
@@ -342,6 +342,12 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf,
#define CLEAN_IMM(type, x) \
((~ENCODE_##type##_IMM((uint64_t)(-1))) & (x))
+#if __riscv_xlen == 32
+#define ELFN(T) ELF32 ## T
+#else
+#define ELFN(T) ELF64 ## T
+#endif
+
int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
Elf_Shdr *section,
const Elf_Shdr *relsec,
@@ -367,7 +373,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
void *loc; /* tmp location to modify */
sym = (void *)pi->ehdr + symtab->sh_offset;
- sym += ELF64_R_SYM(relas[i].r_info);
+ sym += ELFN(_R_SYM)(relas[i].r_info);
if (sym->st_name)
name = strtab + sym->st_name;
--
2.34.1
From: Palmer Dabbelt <[email protected]>
RISC-V recently added kexec_file() support, which uses enables kexec
IMA. We're the first 32-bit platform to support this, so we found a
build bug.
Signed-off-by: Palmer Dabbelt <[email protected]>
---
drivers/of/kexec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/of/kexec.c b/drivers/of/kexec.c
index b9bd1cff1793..ed3451ec2b24 100644
--- a/drivers/of/kexec.c
+++ b/drivers/of/kexec.c
@@ -236,8 +236,8 @@ static int setup_ima_buffer(const struct kimage *image, void *fdt,
if (ret)
return -EINVAL;
- pr_debug("IMA buffer at 0x%llx, size = 0x%zx\n",
- image->ima_buffer_addr, image->ima_buffer_size);
+ pr_debug("IMA buffer at 0x%pa, size = 0x%zx\n",
+ &image->ima_buffer_addr, image->ima_buffer_size);
return 0;
}
--
2.34.1
On Fri, May 20, 2022 at 08:44:27AM -0700, Palmer Dabbelt wrote:
> From: Palmer Dabbelt <[email protected]>
>
> RISC-V recently added kexec_file() support, which uses enables kexec
> IMA. We're the first 32-bit platform to support this, so we found a
> build bug.
>
> Signed-off-by: Palmer Dabbelt <[email protected]>
> ---
> drivers/of/kexec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Assuming you don't want me to apply it:
Acked-by: Rob Herring <[email protected]>
From: Palmer Dabbelt <[email protected]>
With the build issues now sorted out we can enable kexec_file() on
32-bit platforms as well.
Signed-off-by: Palmer Dabbelt <[email protected]>
---
arch/riscv/Kconfig | 1 -
1 file changed, 1 deletion(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 898052ff743e..a246f2fe60c2 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -388,7 +388,6 @@ config KEXEC_FILE
select KEXEC_CORE
select KEXEC_ELF
select HAVE_IMA_KEXEC if IMA
- depends on 64BIT
help
This is new version of kexec system call. This system call is
file based and takes file descriptors as system call argument
--
2.34.1