* [PATCH v1 1/5] drivers: of: kexec ima: Support 32-bit platforms
2022-05-20 15:44 [PATCH v1 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
@ 2022-05-20 15:44 ` Palmer Dabbelt
2022-05-20 22:42 ` Rob Herring
2022-05-20 15:44 ` [PATCH v1 2/5] ima: Fix a build issue on " Palmer Dabbelt
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Palmer Dabbelt @ 2022-05-20 15:44 UTC (permalink / raw)
To: lizhengyu3
Cc: Paul Walmsley, Palmer Dabbelt, aou, robh+dt, frowand.list, zohar,
dmitry.kasatkin, jmorris, serge, liaochang1, linux-riscv,
linux-kernel, devicetree, linux-integrity, linux-security-module,
linux, Palmer Dabbelt
From: Palmer Dabbelt <palmer@rivosinc.com>
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 <palmer@rivosinc.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/5] drivers: of: kexec ima: Support 32-bit platforms
2022-05-20 15:44 ` [PATCH v1 1/5] drivers: of: kexec ima: Support 32-bit platforms Palmer Dabbelt
@ 2022-05-20 22:42 ` Rob Herring
0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2022-05-20 22:42 UTC (permalink / raw)
To: Palmer Dabbelt
Cc: lizhengyu3, Paul Walmsley, Palmer Dabbelt, aou, frowand.list,
zohar, dmitry.kasatkin, jmorris, serge, liaochang1, linux-riscv,
linux-kernel, devicetree, linux-integrity, linux-security-module,
linux
On Fri, May 20, 2022 at 08:44:27AM -0700, Palmer Dabbelt wrote:
> From: Palmer Dabbelt <palmer@rivosinc.com>
>
> 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 <palmer@rivosinc.com>
> ---
> 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 <robh@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 2/5] ima: Fix a build issue on 32-bit platforms
2022-05-20 15:44 [PATCH v1 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
2022-05-20 15:44 ` [PATCH v1 1/5] drivers: of: kexec ima: Support 32-bit platforms Palmer Dabbelt
@ 2022-05-20 15:44 ` Palmer Dabbelt
2022-05-20 15:44 ` [PATCH v1 3/5] RISC-V: kexec: Use Elf64 on 64-bit targets Palmer Dabbelt
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2022-05-20 15:44 UTC (permalink / raw)
To: lizhengyu3
Cc: Paul Walmsley, Palmer Dabbelt, aou, robh+dt, frowand.list, zohar,
dmitry.kasatkin, jmorris, serge, liaochang1, linux-riscv,
linux-kernel, devicetree, linux-integrity, linux-security-module,
linux, Palmer Dabbelt
From: Palmer Dabbelt <palmer@rivosinc.com>
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 <palmer@rivosinc.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 3/5] RISC-V: kexec: Use Elf64 on 64-bit targets
2022-05-20 15:44 [PATCH v1 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
2022-05-20 15:44 ` [PATCH v1 1/5] drivers: of: kexec ima: Support 32-bit platforms Palmer Dabbelt
2022-05-20 15:44 ` [PATCH v1 2/5] ima: Fix a build issue on " Palmer Dabbelt
@ 2022-05-20 15:44 ` Palmer Dabbelt
2022-05-20 15:44 ` [PATCH v1 4/5] RISC-V: purgatory: Use XLEN-length loads to support rv32 Palmer Dabbelt
2022-05-20 15:44 ` [PATCH v1 5/5] RISC-V: Allow kexec_file() on 32-bit platforms Palmer Dabbelt
4 siblings, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2022-05-20 15:44 UTC (permalink / raw)
To: lizhengyu3
Cc: Paul Walmsley, Palmer Dabbelt, aou, robh+dt, frowand.list, zohar,
dmitry.kasatkin, jmorris, serge, liaochang1, linux-riscv,
linux-kernel, devicetree, linux-integrity, linux-security-module,
linux, Palmer Dabbelt
From: Palmer Dabbelt <palmer@rivosinc.com>
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 <palmer@rivosinc.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 4/5] RISC-V: purgatory: Use XLEN-length loads to support rv32
2022-05-20 15:44 [PATCH v1 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
` (2 preceding siblings ...)
2022-05-20 15:44 ` [PATCH v1 3/5] RISC-V: kexec: Use Elf64 on 64-bit targets Palmer Dabbelt
@ 2022-05-20 15:44 ` Palmer Dabbelt
2022-05-20 15:44 ` [PATCH v1 5/5] RISC-V: Allow kexec_file() on 32-bit platforms Palmer Dabbelt
4 siblings, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2022-05-20 15:44 UTC (permalink / raw)
To: lizhengyu3
Cc: Paul Walmsley, Palmer Dabbelt, aou, robh+dt, frowand.list, zohar,
dmitry.kasatkin, jmorris, serge, liaochang1, linux-riscv,
linux-kernel, devicetree, linux-integrity, linux-security-module,
linux, Palmer Dabbelt
From: Palmer Dabbelt <palmer@rivosinc.com>
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 <palmer@rivosinc.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 5/5] RISC-V: Allow kexec_file() on 32-bit platforms
2022-05-20 15:44 [PATCH v1 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
` (3 preceding siblings ...)
2022-05-20 15:44 ` [PATCH v1 4/5] RISC-V: purgatory: Use XLEN-length loads to support rv32 Palmer Dabbelt
@ 2022-05-20 15:44 ` Palmer Dabbelt
4 siblings, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2022-05-20 15:44 UTC (permalink / raw)
To: lizhengyu3
Cc: Paul Walmsley, Palmer Dabbelt, aou, robh+dt, frowand.list, zohar,
dmitry.kasatkin, jmorris, serge, liaochang1, linux-riscv,
linux-kernel, devicetree, linux-integrity, linux-security-module,
linux, Palmer Dabbelt
From: Palmer Dabbelt <palmer@rivosinc.com>
With the build issues now sorted out we can enable kexec_file() on
32-bit platforms as well.
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread