Skip to contentSkip to conversation

kexec: add generic support for elf kernel images

PATCH Superseded Sven Schnelle 3 participants 15 messages Jul 10, 2019 – Jul 19, 2019

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover kexec: add generic support for elf kernel images

Hi List,

this is the same changeset as v2, but (hopefully) with git format-patch -C.

Changes to v2:
- use git format-patch -C

Changes to v1:
- split up patch into smaller pieces
- rebase onto powerpc/next
- remove unused variable in kexec_elf_load()

Changes to RFC version:
- remove unused Elf_Rel macro
- remove section header parsing
- remove PURGATORY_STACK_SIZE
- change order of elf_*_to_cpu() functions
- remove elf_addr_to_cpu macro

Sven Schnelle (7):
kexec: add KEXEC_ELF
kexec_elf: change order of elf_*_to_cpu() functions
kexec_elf: remove parsing of section headers
kexec_elf: remove PURGATORY_STACK_SIZE
kexec_elf: remove elf_addr_to_cpu macro
kexec_elf: remove Elf_Rel macro
kexec_elf: remove unused variable in kexec_elf_load()

 arch/Kconfig                       |   3 +
 arch/powerpc/Kconfig               |   1 +
 arch/powerpc/kernel/kexec_elf_64.c | 551 +----------------------------
 include/linux/kexec.h              |  23 ++
 kernel/Makefile                    |   1 +
 kernel/kexec_elf.c                 | 389 ++++++++++++++++++++
 6 files changed, 427 insertions(+), 541 deletions(-)
 create mode 100644 kernel/kexec_elf.c
Signature · 7 lines
2.20.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#5 lore raw

PATCH v3 5/7 kexec_elf: remove elf_addr_to_cpu macro

It had only one definition, so just use the function directly.

---
 kernel/kexec_elf.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
kernel/kexec_elf.c +9 -11
index 70d31b8feeae..99e6d63b5dfc 100644
@@ -8,8 +8,6 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 
-#define elf_addr_to_cpu	elf64_to_cpu
-
 #ifndef Elf_Rel
 #define Elf_Rel		Elf64_Rel
 #endif /* Elf_Rel */
@@ -143,9 +141,9 @@ static int elf_read_ehdr(const char *buf, size_t len, struct elfhdr *ehdr)
 	ehdr->e_type      = elf16_to_cpu(ehdr, buf_ehdr->e_type);
 	ehdr->e_machine   = elf16_to_cpu(ehdr, buf_ehdr->e_machine);
 	ehdr->e_version   = elf32_to_cpu(ehdr, buf_ehdr->e_version);
-	ehdr->e_entry     = elf_addr_to_cpu(ehdr, buf_ehdr->e_entry);
-	ehdr->e_phoff     = elf_addr_to_cpu(ehdr, buf_ehdr->e_phoff);
-	ehdr->e_shoff     = elf_addr_to_cpu(ehdr, buf_ehdr->e_shoff);
+	ehdr->e_entry     = elf64_to_cpu(ehdr, buf_ehdr->e_entry);
+	ehdr->e_phoff     = elf64_to_cpu(ehdr, buf_ehdr->e_phoff);
+	ehdr->e_shoff     = elf64_to_cpu(ehdr, buf_ehdr->e_shoff);
 	ehdr->e_flags     = elf32_to_cpu(ehdr, buf_ehdr->e_flags);
 	ehdr->e_phentsize = elf16_to_cpu(ehdr, buf_ehdr->e_phentsize);
 	ehdr->e_phnum     = elf16_to_cpu(ehdr, buf_ehdr->e_phnum);
@@ -190,18 +188,18 @@ static int elf_read_phdr(const char *buf, size_t len,
 	buf_phdr = (struct elf_phdr *) pbuf;
 
 	phdr->p_type   = elf32_to_cpu(elf_info->ehdr, buf_phdr->p_type);
-	phdr->p_offset = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_offset);
-	phdr->p_paddr  = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_paddr);
-	phdr->p_vaddr  = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_vaddr);
+	phdr->p_offset = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_offset);
+	phdr->p_paddr  = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_paddr);
+	phdr->p_vaddr  = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_vaddr);
 	phdr->p_flags  = elf32_to_cpu(elf_info->ehdr, buf_phdr->p_flags);
 
 	/*
 	 * The following fields have a type equivalent to Elf_Addr
 	 * both in 32 bit and 64 bit ELF.
 	 */
-	phdr->p_filesz = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_filesz);
-	phdr->p_memsz  = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_memsz);
-	phdr->p_align  = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_align);
+	phdr->p_filesz = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_filesz);
+	phdr->p_memsz  = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_memsz);
+	phdr->p_align  = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_align);
 
 	return elf_is_phdr_sane(phdr, len) ? 0 : -ENOEXEC;
 }
Signature · 7 lines
2.20.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#2 lore raw

PATCH v3 2/7 kexec_elf: change order of elf_*_to_cpu() functions

In reply to Sven Schnelle

Change the order to have a 64/32/16 order, no functional change.

---
 kernel/kexec_elf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/kexec_elf.c +6 -6
index 6e9f52171ede..76e7df64d715 100644
@@ -31,22 +31,22 @@ static uint64_t elf64_to_cpu(const struct elfhdr *ehdr, uint64_t value)
 	return value;
 }
 
-static uint16_t elf16_to_cpu(const struct elfhdr *ehdr, uint16_t value)
+static uint32_t elf32_to_cpu(const struct elfhdr *ehdr, uint32_t value)
 {
 	if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)
-		value = le16_to_cpu(value);
+		value = le32_to_cpu(value);
 	else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
-		value = be16_to_cpu(value);
+		value = be32_to_cpu(value);
 
 	return value;
 }
 
-static uint32_t elf32_to_cpu(const struct elfhdr *ehdr, uint32_t value)
+static uint16_t elf16_to_cpu(const struct elfhdr *ehdr, uint16_t value)
 {
 	if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)
-		value = le32_to_cpu(value);
+		value = le16_to_cpu(value);
 	else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
-		value = be32_to_cpu(value);
+		value = be16_to_cpu(value);
 
 	return value;
 }
Signature · 7 lines
2.20.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#3 lore raw

PATCH v3 3/7 kexec_elf: remove parsing of section headers

In reply to Sven Schnelle

We're not using them, so we can drop the parsing.

---
 include/linux/kexec.h |   1 -
 kernel/kexec_elf.c    | 137 ------------------------------------------
 2 files changed, 138 deletions(-)
include/linux/kexec.h +0 -1
index da2a6b1d69e7..f0b809258ed3 100644
@@ -226,7 +226,6 @@ struct kexec_elf_info {
 
 	const struct elfhdr *ehdr;
 	const struct elf_phdr *proghdrs;
-	struct elf_shdr *sechdrs;
 };
 
 int kexec_build_elf_info(const char *buf, size_t len, struct elfhdr *ehdr,
kernel/kexec_elf.c +0 -137

155 lines not on this page · raw message

Signature · 7 lines
2.20.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#4 lore raw

PATCH v3 4/7 kexec_elf: remove PURGATORY_STACK_SIZE

In reply to Sven Schnelle

It's not used anywhere so just drop it.

---
 kernel/kexec_elf.c | 2 --
 1 file changed, 2 deletions(-)
kernel/kexec_elf.c +0 -2
index effe9dc0b055..70d31b8feeae 100644
@@ -8,8 +8,6 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 
-#define PURGATORY_STACK_SIZE	(16 * 1024)
-
 #define elf_addr_to_cpu	elf64_to_cpu
 
 #ifndef Elf_Rel
Signature · 7 lines
2.20.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#11 lore raw

PATCH v3 6/7 kexec_elf: remove Elf_Rel macro

In reply to Sven Schnelle

It wasn't used anywhere, so lets drop it.

---
 kernel/kexec_elf.c | 4 ----
 1 file changed, 4 deletions(-)
kernel/kexec_elf.c +0 -4
index 99e6d63b5dfc..b7e47ddd7cad 100644
@@ -8,10 +8,6 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 
-#ifndef Elf_Rel
-#define Elf_Rel		Elf64_Rel
-#endif /* Elf_Rel */
-
 static inline bool elf_is_elf_file(const struct elfhdr *ehdr)
 {
 	return memcmp(ehdr->e_ident, ELFMAG, SELFMAG) == 0;
Signature · 7 lines
2.20.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#13 lore raw

PATCH v3 7/7 kexec_elf: remove unused variable in kexec_elf_load()

In reply to Sven Schnelle

base was never unsigned, so we can remove it.

---
 kernel/kexec_elf.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/kexec_elf.c +2 -5
index b7e47ddd7cad..a56ec5481e71 100644
@@ -348,7 +348,7 @@ int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
 			 struct kexec_buf *kbuf,
 			 unsigned long *lowest_load_addr)
 {
-	unsigned long base = 0, lowest_addr = UINT_MAX;
+	unsigned long lowest_addr = UINT_MAX;
 	int ret;
 	size_t i;
 
@@ -370,7 +370,7 @@ int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
 		kbuf->bufsz = size;
 		kbuf->memsz = phdr->p_memsz;
 		kbuf->buf_align = phdr->p_align;
-		kbuf->buf_min = phdr->p_paddr + base;
+		kbuf->buf_min = phdr->p_paddr;
 		ret = kexec_add_buffer(kbuf);
 		if (ret)
 			goto out;
@@ -380,9 +380,6 @@ int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
 			lowest_addr = load_addr;
 	}
 
-	/* Update entry point to reflect new load address. */
-	ehdr->e_entry += base;
-
 	*lowest_load_addr = lowest_addr;
 	ret = 0;
  out:
Signature · 7 lines
2.20.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

PATCH v3 1/7 kexec: add KEXEC_ELF

In reply to Sven Schnelle

Right now powerpc provides an implementation to read elf files with the kexec_file() syscall. Make that available as a public kexec interface so it can be re-used on other architectures.

---
 arch/Kconfig                                  |   3 +
 arch/powerpc/Kconfig                          |   1 +
 arch/powerpc/kernel/kexec_elf_64.c            | 551 +-----------------
 include/linux/kexec.h                         |  24 +
 kernel/Makefile                               |   1 +
 .../kexec_elf_64.c => kernel/kexec_elf.c      | 199 ++-----
 6 files changed, 75 insertions(+), 704 deletions(-)
 copy arch/powerpc/kernel/kexec_elf_64.c => kernel/kexec_elf.c (71%)
arch/Kconfig +3 -0
index c47b328eada0..30694aca4316 100644
@@ -18,6 +18,9 @@ config KEXEC_CORE
 	select CRASH_CORE
 	bool
 
+config KEXEC_ELF
+	bool
+
 config HAVE_IMA_KEXEC
 	bool
 
arch/powerpc/Kconfig +1 -0
index 12cee37f15c4..addc2dad78e0 100644
@@ -510,6 +510,7 @@ config KEXEC_FILE
 	select KEXEC_CORE
 	select HAVE_IMA_KEXEC
 	select BUILD_BIN2C
+	select KEXEC_ELF
 	depends on PPC64
 	depends on CRYPTO=y
 	depends on CRYPTO_SHA256=y
arch/powerpc/kernel/kexec_elf_64.c +10 -541

602 lines not on this page · raw message

include/linux/kexec.h +24 -0
index b9b1bc5f9669..da2a6b1d69e7 100644
@@ -216,6 +216,30 @@ extern int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
 				       void **addr, unsigned long *sz);
 #endif /* CONFIG_KEXEC_FILE */
 
+#ifdef CONFIG_KEXEC_ELF
+struct kexec_elf_info {
+	/*
+	 * Where the ELF binary contents are kept.
+	 * Memory managed by the user of the struct.
+	 */
+	const char *buffer;
+
+	const struct elfhdr *ehdr;
+	const struct elf_phdr *proghdrs;
+	struct elf_shdr *sechdrs;
+};
+
+int kexec_build_elf_info(const char *buf, size_t len, struct elfhdr *ehdr,
+			       struct kexec_elf_info *elf_info);
+
+int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
+			 struct kexec_elf_info *elf_info,
+			 struct kexec_buf *kbuf,
+			 unsigned long *lowest_load_addr);
+
+void kexec_free_elf_info(struct kexec_elf_info *elf_info);
+int kexec_elf_probe(const char *buf, unsigned long len);
+#endif
 struct kimage {
 	kimage_entry_t head;
 	kimage_entry_t *entry;
kernel/Makefile +1 -0
index 33824f0385b3..7062306de9b7 100644
@@ -64,6 +64,7 @@ obj-$(CONFIG_CRASH_CORE) += crash_core.o
 obj-$(CONFIG_KEXEC_CORE) += kexec_core.o
 obj-$(CONFIG_KEXEC) += kexec.o
 obj-$(CONFIG_KEXEC_FILE) += kexec_file.o
+obj-$(CONFIG_KEXEC_ELF) += kexec_elf.o
 obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
 obj-$(CONFIG_COMPAT) += compat.o
 obj-$(CONFIG_CGROUPS) += cgroup/
kernel/kexec_elf.c renamed from arch/powerpc/kernel/kexec_elf_64.c +36 -163

305 lines not on this page · raw message

Signature · 7 lines
2.20.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Reviewed-by on v3 7/7
#14 lore raw

Re: [PATCH v3 7/7] kexec_elf: remove unused variable in kexec_elf_load()

In reply to Sven Schnelle

Le 10/07/2019 à 16:29, Sven Schnelle a écrit :

Quoted 1 line

base was never unsigned, so we can remove it.

Do you mean never assigned ?

Quoted 2 lines
Quoted 28 lines
---
  kernel/kexec_elf.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
kernel/kexec_elf.c +2 -2
index b7e47ddd7cad..a56ec5481e71 100644
@@ -348,7 +348,7 @@ int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
  			 struct kexec_buf *kbuf,
  			 unsigned long *lowest_load_addr)
  {
-	unsigned long base = 0, lowest_addr = UINT_MAX;
+	unsigned long lowest_addr = UINT_MAX;
  	int ret;
  	size_t i;
 
@@ -370,7 +370,7 @@ int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
  		kbuf->bufsz = size;
  		kbuf->memsz = phdr->p_memsz;
  		kbuf->buf_align = phdr->p_align;
-		kbuf->buf_min = phdr->p_paddr + base;
+		kbuf->buf_min = phdr->p_paddr;
  		ret = kexec_add_buffer(kbuf);
  		if (ret)
  			goto out;

kernel/kexec_elf.c int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr, · line 385

Quoted 9 lines
kernel/kexec_elf.c +0 -3
@@ -380,9 +380,6 @@ int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr,
  			lowest_addr = load_addr;
  	}
 
-	/* Update entry point to reflect new load address. */
-	ehdr->e_entry += base;
-
  	*lowest_load_addr = lowest_addr;
  	ret = 0;
   out:

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reviewed-by on v3 6/7
#12 lore raw

Re: [PATCH v3 6/7] kexec_elf: remove Elf_Rel macro

In reply to Sven Schnelle

Le 10/07/2019 à 16:29, Sven Schnelle a écrit :

Quoted 1 line

It wasn't used anywhere, so lets drop it.

And also, it is already defined in asm-generic/module.h

Quoted 2 lines
Quoted 10 lines
---
  kernel/kexec_elf.c | 4 ----
  1 file changed, 4 deletions(-)
kernel/kexec_elf.c +0 -0
index 99e6d63b5dfc..b7e47ddd7cad 100644

kernel/kexec_elf.c line 13

Quoted 10 lines
kernel/kexec_elf.c +0 -4
@@ -8,10 +8,6 @@
  #include <linux/slab.h>
  #include <linux/types.h>
 
-#ifndef Elf_Rel
-#define Elf_Rel		Elf64_Rel
-#endif /* Elf_Rel */
-
  static inline bool elf_is_elf_file(const struct elfhdr *ehdr)
  {
  	return memcmp(ehdr->e_ident, ELFMAG, SELFMAG) == 0;

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw

Re: [PATCH v3 5/7] kexec_elf: remove elf_addr_to_cpu macro

In reply to Sven Schnelle

Le 10/07/2019 à 16:29, Sven Schnelle a écrit :

Quoted 1 line

It had only one definition, so just use the function directly.

It had only one definition because it was for ppc64 only.
But as far as I understand (at least from the name of the new file), you want it to be generic, don't you ? Therefore I get on 32 bits it would be elf32_to_cpu().

Christophe

Quoted 48 lines
---
  kernel/kexec_elf.c | 20 +++++++++-----------
  1 file changed, 9 insertions(+), 11 deletions(-)
kernel/kexec_elf.c +6 -8
index 70d31b8feeae..99e6d63b5dfc 100644
@@ -8,8 +8,6 @@
  #include <linux/slab.h>
  #include <linux/types.h>
 
-#define elf_addr_to_cpu	elf64_to_cpu
-
  #ifndef Elf_Rel
  #define Elf_Rel		Elf64_Rel
  #endif /* Elf_Rel */
@@ -143,9 +141,9 @@ static int elf_read_ehdr(const char *buf, size_t len, struct elfhdr *ehdr)
  	ehdr->e_type      = elf16_to_cpu(ehdr, buf_ehdr->e_type);
  	ehdr->e_machine   = elf16_to_cpu(ehdr, buf_ehdr->e_machine);
  	ehdr->e_version   = elf32_to_cpu(ehdr, buf_ehdr->e_version);
-	ehdr->e_entry     = elf_addr_to_cpu(ehdr, buf_ehdr->e_entry);
-	ehdr->e_phoff     = elf_addr_to_cpu(ehdr, buf_ehdr->e_phoff);
-	ehdr->e_shoff     = elf_addr_to_cpu(ehdr, buf_ehdr->e_shoff);
+	ehdr->e_entry     = elf64_to_cpu(ehdr, buf_ehdr->e_entry);
+	ehdr->e_phoff     = elf64_to_cpu(ehdr, buf_ehdr->e_phoff);
+	ehdr->e_shoff     = elf64_to_cpu(ehdr, buf_ehdr->e_shoff);
  	ehdr->e_flags     = elf32_to_cpu(ehdr, buf_ehdr->e_flags);
  	ehdr->e_phentsize = elf16_to_cpu(ehdr, buf_ehdr->e_phentsize);
  	ehdr->e_phnum     = elf16_to_cpu(ehdr, buf_ehdr->e_phnum);
@@ -190,18 +188,18 @@ static int elf_read_phdr(const char *buf, size_t len,
  	buf_phdr = (struct elf_phdr *) pbuf;
 
  	phdr->p_type   = elf32_to_cpu(elf_info->ehdr, buf_phdr->p_type);
-	phdr->p_offset = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_offset);
-	phdr->p_paddr  = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_paddr);
-	phdr->p_vaddr  = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_vaddr);
+	phdr->p_offset = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_offset);
+	phdr->p_paddr  = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_paddr);
+	phdr->p_vaddr  = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_vaddr);
  	phdr->p_flags  = elf32_to_cpu(elf_info->ehdr, buf_phdr->p_flags);
 
  	/*
  	 * The following fields have a type equivalent to Elf_Addr
  	 * both in 32 bit and 64 bit ELF.

kernel/kexec_elf.c static int elf_read_phdr(const char *buf, size_t len, · line 205

Quoted 10 lines
kernel/kexec_elf.c +3 -3
  	 */
-	phdr->p_filesz = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_filesz);
-	phdr->p_memsz  = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_memsz);
-	phdr->p_align  = elf_addr_to_cpu(elf_info->ehdr, buf_phdr->p_align);
+	phdr->p_filesz = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_filesz);
+	phdr->p_memsz  = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_memsz);
+	phdr->p_align  = elf64_to_cpu(elf_info->ehdr, buf_phdr->p_align);
 
  	return elf_is_phdr_sane(phdr, len) ? 0 : -ENOEXEC;
  }

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw

Re: [PATCH v3 5/7] kexec_elf: remove elf_addr_to_cpu macro

Hi Christophe,

Quoted 9 lines · Christophe Leroy

Le 10/07/2019 à 16:29, Sven Schnelle a écrit :

Quoted 1 line

It had only one definition, so just use the function directly.

It had only one definition because it was for ppc64 only.
But as far as I understand (at least from the name of the new file), you want it to be generic, don't you ? Therefore I get on 32 bits it would be elf32_to_cpu().

That brings up the question whether we need those endianess conversions. I would assume that the ELF file has always the same endianess as the running kernel. So i think we could just drop them. What do you think?

Regards
Sven

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#8 lore raw

Re: [PATCH v3 5/7] kexec_elf: remove elf_addr_to_cpu macro

Quoted 4 lines · Sven Schnelle
Quoted 3 lines · Christophe Leroy

Le 10/07/2019 à 16:29, Sven Schnelle a écrit :

Quoted 1 line

It had only one definition, so just use the function directly.

Quoted 8 lines
Quoted 4 lines

It had only one definition because it was for ppc64 only.
But as far as I understand (at least from the name of the new file), you want it to be generic, don't you ? Therefore I get on 32 bits it would be elf32_to_cpu().

That brings up the question whether we need those endianess conversions. I would assume that the ELF file has always the same endianess as the running kernel. So i think we could just drop them. What do you think?

We should be able to kexec from big to little endian or vice versa, so they are necessary.

cheers

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#9 lore raw

Re: [PATCH v3 5/7] kexec_elf: remove elf_addr_to_cpu macro

Hi Michael,

Quoted 10 lines · Michael Ellerman
Quoted 9 lines · Sven Schnelle
Quoted 7 lines · Christophe Leroy

Le 10/07/2019 à 16:29, Sven Schnelle a écrit :

Quoted 1 line

It had only one definition, so just use the function directly.

It had only one definition because it was for ppc64 only.
But as far as I understand (at least from the name of the new file), you want it to be generic, don't you ? Therefore I get on 32 bits it would be elf32_to_cpu().

Quoted 6 lines
Quoted 3 lines

That brings up the question whether we need those endianess conversions. I would assume that the ELF file has always the same endianess as the running kernel. So i think we could just drop them. What do you think?

We should be able to kexec from big to little endian or vice versa, so they are necessary.

I'll update the patch to check for a needed 32/64 bit conversion during runtime, so we can also kexec from 32 to 64 bit kernels and vice versa. Don't know whether that's possible on powerpc, but at least on parisc it is.

Regards
Sven

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#10 lore raw

Re: [PATCH v3 5/7] kexec_elf: remove elf_addr_to_cpu macro

Quoted 17 lines · Sven Schnelle

Hi Michael,

Quoted 14 lines · Michael Ellerman
Quoted 12 lines · Sven Schnelle
Quoted 7 lines · Christophe Leroy

Le 10/07/2019 à 16:29, Sven Schnelle a écrit :

Quoted 1 line

It had only one definition, so just use the function directly.

It had only one definition because it was for ppc64 only.
But as far as I understand (at least from the name of the new file), you want it to be generic, don't you ? Therefore I get on 32 bits it would be elf32_to_cpu().

That brings up the question whether we need those endianess conversions. I would assume that the ELF file has always the same endianess as the running kernel. So i think we could just drop them. What do you think?

Quoted 6 lines
Quoted 2 lines

We should be able to kexec from big to little endian or vice versa, so they are necessary.

I'll update the patch to check for a needed 32/64 bit conversion during runtime, so we can also kexec from 32 to 64 bit kernels and vice versa. Don't know whether that's possible on powerpc, but at least on parisc it is.

On some of the Freescale (NXP) machines that should actually be possible, the hardware can run a 64 or 32-bit kernel, but I'm not sure if anyone has actually tested kexec'ing from one to the other.

cheers

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec