linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V
@ 2022-06-24  4:48 Palmer Dabbelt
  2022-06-24  4:48 ` [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms Palmer Dabbelt
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2022-06-24  4:48 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module

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/20220520154430.18593-1-palmer@rivosinc.com/>
* Collected reviews for drivers/of/kexec.c.



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms
  2022-06-24  4:48 [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
@ 2022-06-24  4:48 ` Palmer Dabbelt
  2022-06-30 13:02   ` Mimi Zohar
  2022-06-30 13:20   ` Mimi Zohar
  2022-06-24  4:48 ` [PATCH v2 2/5] ima: Fix a build issue on " Palmer Dabbelt
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2022-06-24  4:48 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module, Palmer Dabbelt,
	Rob Herring

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 <robh@kernel.org>
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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/5] ima: Fix a build issue on 32-bit platforms
  2022-06-24  4:48 [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
  2022-06-24  4:48 ` [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms Palmer Dabbelt
@ 2022-06-24  4:48 ` Palmer Dabbelt
  2022-06-30 13:21   ` Mimi Zohar
  2022-06-24  4:48 ` [PATCH v2 3/5] RISC-V: kexec: Use Elf64 on 64-bit targets Palmer Dabbelt
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Palmer Dabbelt @ 2022-06-24  4:48 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module, Palmer Dabbelt

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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 3/5] RISC-V: kexec: Use Elf64 on 64-bit targets
  2022-06-24  4:48 [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
  2022-06-24  4:48 ` [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms Palmer Dabbelt
  2022-06-24  4:48 ` [PATCH v2 2/5] ima: Fix a build issue on " Palmer Dabbelt
@ 2022-06-24  4:48 ` Palmer Dabbelt
  2022-06-24  4:48 ` [PATCH v2 4/5] RISC-V: purgatory: Use XLEN-length loads to support rv32 Palmer Dabbelt
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2022-06-24  4:48 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module, Palmer Dabbelt

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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 4/5] RISC-V: purgatory: Use XLEN-length loads to support rv32
  2022-06-24  4:48 [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
                   ` (2 preceding siblings ...)
  2022-06-24  4:48 ` [PATCH v2 3/5] RISC-V: kexec: Use Elf64 on 64-bit targets Palmer Dabbelt
@ 2022-06-24  4:48 ` Palmer Dabbelt
  2022-06-24  4:48 ` [PATCH v2 5/5] RISC-V: Allow kexec_file() on 32-bit platforms Palmer Dabbelt
  2022-06-30 13:21 ` [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Mimi Zohar
  5 siblings, 0 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2022-06-24  4:48 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module, Palmer Dabbelt

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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 5/5] RISC-V: Allow kexec_file() on 32-bit platforms
  2022-06-24  4:48 [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
                   ` (3 preceding siblings ...)
  2022-06-24  4:48 ` [PATCH v2 4/5] RISC-V: purgatory: Use XLEN-length loads to support rv32 Palmer Dabbelt
@ 2022-06-24  4:48 ` Palmer Dabbelt
  2022-06-30 13:21 ` [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Mimi Zohar
  5 siblings, 0 replies; 10+ messages in thread
From: Palmer Dabbelt @ 2022-06-24  4:48 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module, Palmer Dabbelt

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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms
  2022-06-24  4:48 ` [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms Palmer Dabbelt
@ 2022-06-30 13:02   ` Mimi Zohar
  2022-06-30 13:20   ` Mimi Zohar
  1 sibling, 0 replies; 10+ messages in thread
From: Mimi Zohar @ 2022-06-30 13:02 UTC (permalink / raw)
  To: Palmer Dabbelt, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module, Rob Herring

On Thu, 2022-06-23 at 21:48 -0700, Palmer Dabbelt wrote:
> 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 <robh@kernel.org>
> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>

Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms
  2022-06-24  4:48 ` [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms Palmer Dabbelt
  2022-06-30 13:02   ` Mimi Zohar
@ 2022-06-30 13:20   ` Mimi Zohar
  1 sibling, 0 replies; 10+ messages in thread
From: Mimi Zohar @ 2022-06-30 13:20 UTC (permalink / raw)
  To: Palmer Dabbelt, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module, Rob Herring

On Thu, 2022-06-23 at 21:48 -0700, Palmer Dabbelt wrote:
> 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 <robh@kernel.org>
> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>

Reviewed-by:  Mimi Zohar <zohar@linux.ibm.com>


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/5] ima: Fix a build issue on 32-bit platforms
  2022-06-24  4:48 ` [PATCH v2 2/5] ima: Fix a build issue on " Palmer Dabbelt
@ 2022-06-30 13:21   ` Mimi Zohar
  0 siblings, 0 replies; 10+ messages in thread
From: Mimi Zohar @ 2022-06-30 13:21 UTC (permalink / raw)
  To: Palmer Dabbelt, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module

On Thu, 2022-06-23 at 21:48 -0700, Palmer Dabbelt wrote:
> 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>

Acked-by:  Mimi Zohar <zohar@linux.ibm.com>


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V
  2022-06-24  4:48 [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
                   ` (4 preceding siblings ...)
  2022-06-24  4:48 ` [PATCH v2 5/5] RISC-V: Allow kexec_file() on 32-bit platforms Palmer Dabbelt
@ 2022-06-30 13:21 ` Mimi Zohar
  5 siblings, 0 replies; 10+ messages in thread
From: Mimi Zohar @ 2022-06-30 13:21 UTC (permalink / raw)
  To: Palmer Dabbelt, dmitry.kasatkin, linux-integrity
  Cc: linux-riscv, linux-kernel, linux-security-module

Hi Palmer,

On Thu, 2022-06-23 at 21:48 -0700, Palmer Dabbelt wrote:
> 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/20220520154430.18593-1-palmer@rivosinc.com/>
> * Collected reviews for drivers/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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-06-30 13:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24  4:48 [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Palmer Dabbelt
2022-06-24  4:48 ` [PATCH v2 1/5] drivers: of: kexec ima: Support 32-bit platforms Palmer Dabbelt
2022-06-30 13:02   ` Mimi Zohar
2022-06-30 13:20   ` Mimi Zohar
2022-06-24  4:48 ` [PATCH v2 2/5] ima: Fix a build issue on " Palmer Dabbelt
2022-06-30 13:21   ` Mimi Zohar
2022-06-24  4:48 ` [PATCH v2 3/5] RISC-V: kexec: Use Elf64 on 64-bit targets Palmer Dabbelt
2022-06-24  4:48 ` [PATCH v2 4/5] RISC-V: purgatory: Use XLEN-length loads to support rv32 Palmer Dabbelt
2022-06-24  4:48 ` [PATCH v2 5/5] RISC-V: Allow kexec_file() on 32-bit platforms Palmer Dabbelt
2022-06-30 13:21 ` [PATCH v2 0/5] Support kexec_file on 32-bit RISC-V Mimi Zohar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).