Support kexec_file on 32-bit RISC-V
Subsystems (6)
v2 cover Support kexec_file on 32-bit RISC-V
This rolled itself back to the top of my inbox, so I figured I'd send it again as Rob's review landed. IMO the security/integrity/ima/ change is sufficiently trivial that it's fine to take it through the RISC-V tree but I don't have an Review/Ack so I'll wait until this loops back again to give the security/integrity/ folks a chance to chime in.
If this loops back to the top of my queue (which looks about a month deep right now) without any comments then I'll put it in riscv/for-next.
Thanks!
Changes since v1
<https://lore.kernel.org/all/[email protected]/>
* Collected reviews for drivers/of/kexec.c.
PATCH v2 1/5 drivers: of: kexec ima: Support 32-bit platforms
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.
--- drivers/of/kexec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/of/kexec.c +2 -2
@@ -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 ; }
Signature · 1 line
2.34.1
Re: [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms
Quoted 6 lines · Palmer Dabbelt
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.Acked-by Rob Herring <[email protected]>Signed-off-by Palmer Dabbelt <[email protected]>
Re: [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms
In reply to Palmer DabbeltQuoted 6 lines · Palmer Dabbelt
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.Acked-by Rob Herring <[email protected]>Signed-off-by Palmer Dabbelt <[email protected]>
PATCH v2 2/5 ima: Fix a build issue on 32-bit platforms
In reply to Palmer Dabbeltima_dump_measurement_list() took an "unsigned long *", but was passed a size_t. This triggers build warnings on 32-bit RISC-V.
--- security/integrity/ima/ima_kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_kexec.c +1 -1
@@ -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;
Signature · 1 line
2.34.1
Re: [PATCH v2 2/5] ima: Fix a build issue on 32-bit platforms
Quoted 4 lines · Palmer Dabbelt
ima_dump_measurement_list()took an "unsigned long *", but was passed asize_t. This triggers build warnings on 32-bit RISC-V.Signed-off-by Palmer Dabbelt <[email protected]>
PATCH v2 3/5 RISC-V: kexec: Use Elf64 on 64-bit targets
In reply to Palmer DabbeltMost of the Elf macros automatically select the correct Elf type, this converts the one explicit Elf64 usage to depend on XLEN.
--- arch/riscv/kernel/elf_kexec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/riscv/kernel/elf_kexec.c +7 -1
@@ -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;
Signature · 1 line
2.34.1
PATCH v2 4/5 RISC-V: purgatory: Use XLEN-length loads to support rv32
In reply to Palmer DabbeltThis 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.
--- arch/riscv/purgatory/entry.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/riscv/purgatory/entry.S +4 -2
@@ -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
Signature · 1 line
2.34.1
PATCH v2 5/5 RISC-V: Allow kexec_file() on 32-bit platforms
In reply to Palmer DabbeltWith the build issues now sorted out we can enable kexec_file() on 32-bit platforms as well.
--- arch/riscv/Kconfig | 1 - 1 file changed, 1 deletion(-)
arch/riscv/Kconfig +0 -1
@@ -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
Signature · 1 line
2.34.1
Mimi Zohar
maintainerHi Palmer,
Quoted 6 lines · Palmer Dabbelt
This rolled itself back to the top of my inbox, so I figured I'd send it again as Rob's review landed. IMO the
security/integrity/ima/change is sufficiently trivial that it's fine to take it through the RISC-V tree but I don't have an Review/Ack so I'll wait until this loops back again to give thesecurity/integrity/folks a chance to chime in.
Quoted 8 lines
If this loops back to the top of my queue (which looks about a month deep right now) without any comments then I'll put it in riscv/for-next.
Thanks!
Changes since v1
<https://lore.kernel.org/all/[email protected]/>
* Collected reviews fordrivers/of/kexec.c.
Maybe better that you upstream the RISC-V changes. So far there aren't any merge conflicts with this patchset, but a number of other kexec patch sets will hopefully be upstreamed in the coming open window. I'd appreciate if you could create a topic branch for the first two patches.
thanks,
Mimi