Re: [PATCH 02/11] powerpc/kexec_file: mark PPC64 specific code

2020-06-29 Thread Hari Bathini
Hi Christophe

Thanks for the review...

On 27/06/20 12:12 pm, Christophe Leroy wrote:
> 
> 
> Le 26/06/2020 à 21:04, Hari Bathini a écrit :
>> Some of the kexec_file_load code isn't PPC64 specific. Move PPC64
>> specific code from kexec/file_load.c to kexec/file_load_64.c. Also,
>> rename purgatory/trampoline.S to purgatory/trampoline_64.S in the
>> same spirit.
> 
> At the time being, CONFIG_KEXEC_FILE depends on PPC64.

Right.

> Are you planning to make it work on PPC32 as well ?

No.

> Otherwise I don't understand the purpose of this patch.

But I want to make sure the changes I am adding in this series do not
get in the way of adding PPC32 changes whenever they are submitted as there
is common code currently and some more of it in the changes I am adding
in this series...

> Also, what is being done in this patch seems to go far beyond what you 
> describe above.> It is propably worth splitting in several patches with 
> proper explanation.

Hmmm.. I don't see any other reason beyond what I mentioned above.
Will try to split the patch but the changelog would still be the same, afaics.

> Christophe
> 
>>
>> Signed-off-by: Hari Bathini 
>> ---
>>   arch/powerpc/include/asm/kexec.h   |   11 +++
>>   arch/powerpc/kexec/Makefile    |    2 -
>>   arch/powerpc/kexec/elf_64.c    |    7 +-
>>   arch/powerpc/kexec/file_load.c |   37 ++
>>   arch/powerpc/kexec/file_load_64.c  |  108 
>> ++
>>   arch/powerpc/purgatory/Makefile    |    4 +
>>   arch/powerpc/purgatory/trampoline.S    |  117 
>> 
>>   arch/powerpc/purgatory/trampoline_64.S |  117 
>> 
>>   8 files changed, 248 insertions(+), 155 deletions(-)
>>   create mode 100644 arch/powerpc/kexec/file_load_64.c
>>   delete mode 100644 arch/powerpc/purgatory/trampoline.S
>>   create mode 100644 arch/powerpc/purgatory/trampoline_64.S

Thanks
Hari

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 02/11] powerpc/kexec_file: mark PPC64 specific code

2020-06-27 Thread Christophe Leroy



Le 26/06/2020 à 21:04, Hari Bathini a écrit :

Some of the kexec_file_load code isn't PPC64 specific. Move PPC64
specific code from kexec/file_load.c to kexec/file_load_64.c. Also,
rename purgatory/trampoline.S to purgatory/trampoline_64.S in the
same spirit.


At the time being, CONFIG_KEXEC_FILE depends on PPC64.
Are you planning to make it work on PPC32 as well ?
Otherwise I don't understand the purpose of this patch.

Also, what is being done in this patch seems to go far beyond what you 
describe above. It is propably worth splitting in several patches with 
proper explanation.


Christophe



Signed-off-by: Hari Bathini 
---
  arch/powerpc/include/asm/kexec.h   |   11 +++
  arch/powerpc/kexec/Makefile|2 -
  arch/powerpc/kexec/elf_64.c|7 +-
  arch/powerpc/kexec/file_load.c |   37 ++
  arch/powerpc/kexec/file_load_64.c  |  108 ++
  arch/powerpc/purgatory/Makefile|4 +
  arch/powerpc/purgatory/trampoline.S|  117 
  arch/powerpc/purgatory/trampoline_64.S |  117 
  8 files changed, 248 insertions(+), 155 deletions(-)
  create mode 100644 arch/powerpc/kexec/file_load_64.c
  delete mode 100644 arch/powerpc/purgatory/trampoline.S
  create mode 100644 arch/powerpc/purgatory/trampoline_64.S

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index c684768..7008ea1 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -114,8 +114,17 @@ int setup_purgatory(struct kimage *image, const void 
*slave_code,
unsigned long fdt_load_addr);
  int setup_new_fdt(const struct kimage *image, void *fdt,
  unsigned long initrd_load_addr, unsigned long initrd_len,
- const char *cmdline);
+ const char *cmdline, int *node);
  int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size);
+
+#ifdef CONFIG_PPC64
+int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,
+ const void *fdt, unsigned long kernel_load_addr,
+ unsigned long fdt_load_addr);
+int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
+   unsigned long initrd_load_addr,
+   unsigned long initrd_len, const char *cmdline);
+#endif /* CONFIG_PPC64 */
  #endif /* CONFIG_KEXEC_FILE */
  
  #else /* !CONFIG_KEXEC_CORE */

diff --git a/arch/powerpc/kexec/Makefile b/arch/powerpc/kexec/Makefile
index 86380c6..67c3553 100644
--- a/arch/powerpc/kexec/Makefile
+++ b/arch/powerpc/kexec/Makefile
@@ -7,7 +7,7 @@ obj-y   += core.o crash.o core_$(BITS).o
  
  obj-$(CONFIG_PPC32)		+= relocate_32.o
  
-obj-$(CONFIG_KEXEC_FILE)	+= file_load.o elf_$(BITS).o

+obj-$(CONFIG_KEXEC_FILE)   += file_load.o file_load_$(BITS).o elf_$(BITS).o
  
  ifdef CONFIG_HAVE_IMA_KEXEC

  ifdef CONFIG_IMA
diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c
index 3072fd6..23ad04c 100644
--- a/arch/powerpc/kexec/elf_64.c
+++ b/arch/powerpc/kexec/elf_64.c
@@ -88,7 +88,8 @@ static void *elf64_load(struct kimage *image, char 
*kernel_buf,
goto out;
}
  
-	ret = setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline);

+   ret = setup_new_fdt_ppc64(image, fdt, initrd_load_addr,
+ initrd_len, cmdline);
if (ret)
goto out;
  
@@ -107,8 +108,8 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,

pr_debug("Loaded device tree at 0x%lx\n", fdt_load_addr);
  
  	slave_code = elf_info.buffer + elf_info.proghdrs[0].p_offset;

-   ret = setup_purgatory(image, slave_code, fdt, kernel_load_addr,
- fdt_load_addr);
+   ret = setup_purgatory_ppc64(image, slave_code, fdt, kernel_load_addr,
+   fdt_load_addr);
if (ret)
pr_err("Error setting up the purgatory.\n");
  
diff --git a/arch/powerpc/kexec/file_load.c b/arch/powerpc/kexec/file_load.c

index 143c917..99a2c4d 100644
--- a/arch/powerpc/kexec/file_load.c
+++ b/arch/powerpc/kexec/file_load.c
@@ -1,6 +1,6 @@
  // SPDX-License-Identifier: GPL-2.0-only
  /*
- * ppc64 code to implement the kexec_file_load syscall
+ * powerpc code to implement the kexec_file_load syscall
   *
   * Copyright (C) 2004  Adam Litke (a...@us.ibm.com)
   * Copyright (C) 2004  IBM Corp.
@@ -16,26 +16,10 @@
  
  #include 

  #include 
-#include 
  #include 
  #include 
  
-#define SLAVE_CODE_SIZE		256

-
-const struct kexec_file_ops * const kexec_file_loaders[] = {
-   _elf64_ops,
-   NULL
-};
-
-int arch_kexec_kernel_image_probe(struct kimage *image, void *buf,
- unsigned long buf_len)
-{
-   /* We don't support crash kernels yet. */
-   if (image->type == KEXEC_TYPE_CRASH)
-