Re: [PATCH v2 2/5] ia64: reuse append_elf_note() and final_note() functions

2016-12-02 Thread Eric W. Biederman
Hari Bathini  writes:

> Hi Dave,
>
>
> Thanks for the review.
>
>
> On Thursday 01 December 2016 10:26 AM, Dave Young wrote:
>> Hi Hari
>>
>> Personally I like V1 more, but split the patch 2 is easier for ia64
>> people to reivew.  I did basic x86 testing, it runs ok.
>>
>> On 11/25/16 at 05:24pm, Hari Bathini wrote:
>>> Get rid of multiple definitions of append_elf_note() & final_note()
>>> functions. Reuse these functions compiled under CONFIG_CRASH_CORE.
>>>
>>> Signed-off-by: Hari Bathini 
>>> ---
>>>   arch/ia64/kernel/crash.c   |   22 --
>>>   include/linux/crash_core.h |4 
>>>   kernel/crash_core.c|6 +++---
>>>   kernel/kexec_core.c|   28 
>>>   4 files changed, 7 insertions(+), 53 deletions(-)
>>>
>>> diff --git a/arch/ia64/kernel/crash.c b/arch/ia64/kernel/crash.c
>>> index 2955f35..75859a0 100644
>>> --- a/arch/ia64/kernel/crash.c
>>> +++ b/arch/ia64/kernel/crash.c
>>> @@ -27,28 +27,6 @@ static int kdump_freeze_monarch;
>>>   static int kdump_on_init = 1;
>>>   static int kdump_on_fatal_mca = 1;
>>>   -static inline Elf64_Word
>>> -*append_elf_note(Elf64_Word *buf, char *name, unsigned type, void *data,
>>> -   size_t data_len)
>>> -{
>>> -   struct elf_note *note = (struct elf_note *)buf;
>>> -   note->n_namesz = strlen(name) + 1;
>>> -   note->n_descsz = data_len;
>>> -   note->n_type   = type;
>>> -   buf += (sizeof(*note) + 3)/4;
>>> -   memcpy(buf, name, note->n_namesz);
>>> -   buf += (note->n_namesz + 3)/4;
>>> -   memcpy(buf, data, data_len);
>>> -   buf += (data_len + 3)/4;
>>> -   return buf;
>>> -}
>>> -
>>> -static void
>>> -final_note(void *buf)
>>> -{
>>> -   memset(buf, 0, sizeof(struct elf_note));
>>> -}
>>> -
>> The above IA64 version looks better than the functions in kexec_core.c
>> about the Elf64_Word type usage and the simpler final_note function.
>
> Hmmm.. Is void* better over Elf64_Word* to be agnostic of Elf32 or
> Elf64 type?

Both Elf64_Word and Elf32_Word result in a u32.  So I expect the right
solution is to add a definition of Elf_Word to include/linux/elf.h
and to make the buffer "Elf_Word *buf".

That way we preserve the alignment knowledge, while making the code
depend on 32bit or 64bit.

Eric

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


Re: [PATCH v2 2/5] ia64: reuse append_elf_note() and final_note() functions

2016-12-02 Thread Hari Bathini

Hi Dave,


Thanks for the review.


On Thursday 01 December 2016 10:26 AM, Dave Young wrote:

Hi Hari

Personally I like V1 more, but split the patch 2 is easier for ia64
people to reivew.  I did basic x86 testing, it runs ok.

On 11/25/16 at 05:24pm, Hari Bathini wrote:

Get rid of multiple definitions of append_elf_note() & final_note()
functions. Reuse these functions compiled under CONFIG_CRASH_CORE.

Signed-off-by: Hari Bathini 
---
  arch/ia64/kernel/crash.c   |   22 --
  include/linux/crash_core.h |4 
  kernel/crash_core.c|6 +++---
  kernel/kexec_core.c|   28 
  4 files changed, 7 insertions(+), 53 deletions(-)

diff --git a/arch/ia64/kernel/crash.c b/arch/ia64/kernel/crash.c
index 2955f35..75859a0 100644
--- a/arch/ia64/kernel/crash.c
+++ b/arch/ia64/kernel/crash.c
@@ -27,28 +27,6 @@ static int kdump_freeze_monarch;
  static int kdump_on_init = 1;
  static int kdump_on_fatal_mca = 1;
  
-static inline Elf64_Word

-*append_elf_note(Elf64_Word *buf, char *name, unsigned type, void *data,
-   size_t data_len)
-{
-   struct elf_note *note = (struct elf_note *)buf;
-   note->n_namesz = strlen(name) + 1;
-   note->n_descsz = data_len;
-   note->n_type   = type;
-   buf += (sizeof(*note) + 3)/4;
-   memcpy(buf, name, note->n_namesz);
-   buf += (note->n_namesz + 3)/4;
-   memcpy(buf, data, data_len);
-   buf += (data_len + 3)/4;
-   return buf;
-}
-
-static void
-final_note(void *buf)
-{
-   memset(buf, 0, sizeof(struct elf_note));
-}
-

The above IA64 version looks better than the functions in kexec_core.c
about the Elf64_Word type usage and the simpler final_note function.


Hmmm.. Is void* better over Elf64_Word* to be agnostic of Elf32 or Elf64 
type?




Care to update crash_core.c to use this instead?


Sure. Will resend.

Thanks
Hari


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


[PATCH 5/6] mips: add dtb loading support

2016-12-02 Thread Marcin Nowakowski
Kexec for MIPS currently does not support loading devicetrees, unless
they are embedded in the kernel elf file.

Add an option to either pass a new dtb file or - if not specified - to
be generated from existing device tree on the device. As new generic
platforms require a dtb to be passed separately this is required for
such platforms and will be ignored by the kernel otherwise.

Generic kexec infrastructure for dtb support is used.

Signed-off-by: Marcin Nowakowski 
Cc: Ralf Baechle 
Cc: linux-m...@linux-mips.org
---
 kexec/arch/mips/Makefile   | 13 +
 kexec/arch/mips/crashdump-mips.c   |  3 +++
 kexec/arch/mips/include/arch/options.h |  5 -
 kexec/arch/mips/kexec-elf-mips.c   | 34 +++---
 kexec/arch/mips/kexec-mips.c   |  8 
 kexec/arch/mips/kexec-mips.h   |  9 +
 6 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/kexec/arch/mips/Makefile b/kexec/arch/mips/Makefile
index 03bdb9a..1fe7886 100644
--- a/kexec/arch/mips/Makefile
+++ b/kexec/arch/mips/Makefile
@@ -6,6 +6,19 @@ mips_KEXEC_SRCS += kexec/arch/mips/kexec-elf-mips.c
 mips_KEXEC_SRCS += kexec/arch/mips/kexec-elf-rel-mips.c
 mips_KEXEC_SRCS += kexec/arch/mips/crashdump-mips.c
 
+mips_FS2DT = kexec/fs2dt.c
+mips_FS2DT_INCLUDE = \
+   -include $(srcdir)/kexec/arch/mips/crashdump-mips.h \
+   -include $(srcdir)/kexec/arch/mips/kexec-mips.h
+
+mips_DT_OPS += kexec/dt-ops.c
+
+include $(srcdir)/kexec/libfdt/Makefile.libfdt
+
+libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
+mips_CPPFLAGS += -I$(srcdir)/kexec/libfdt
+mips_KEXEC_SRCS += $(libfdt_SRCS)
+
 mips_ADD_BUFFER =
 mips_ADD_SEGMENT =
 mips_VIRT_TO_PHYS =
diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index 278ee01..d6cff5a 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -39,6 +39,9 @@
  * A separate program header is created for backup region */
 static struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES];
 
+/* Not used currently but required by generic fs2dt code */
+struct memory_ranges usablemem_rgns;
+
 /* Memory region reserved for storing panic kernel and other data. */
 static struct memory_range crash_reserved_mem;
 
diff --git a/kexec/arch/mips/include/arch/options.h 
b/kexec/arch/mips/include/arch/options.h
index a18251b..86b620f 100644
--- a/kexec/arch/mips/include/arch/options.h
+++ b/kexec/arch/mips/include/arch/options.h
@@ -3,6 +3,7 @@
 
 #define OPT_ARCH_MAX   (OPT_MAX+0)
 #define OPT_APPEND (OPT_ARCH_MAX+0)
+#define OPT_DTB(OPT_ARCH_MAX+1)
 
 /* Options relevant to the architecture (excluding loader-specific ones),
  * in this case none:
@@ -10,7 +11,9 @@
 #define KEXEC_ARCH_OPTIONS \
KEXEC_OPTIONS \
{"command-line", 1, 0, OPT_APPEND}, \
-   {"append",   1, 0, OPT_APPEND},
+   {"append",   1, 0, OPT_APPEND}, \
+   {"dtb", 1, 0, OPT_DTB },
+
 
 #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""
 
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index 7cb06f1..6ca7ca0 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -29,13 +29,16 @@
 #include "kexec-mips.h"
 #include "crashdump-mips.h"
 #include 
+#include "../../fs2dt.h"
+#include "../../dt-ops.h"
 
 static const int probe_debug = 0;
 
 #define BOOTLOADER "kexec"
-#define MAX_COMMAND_LINE   256
 #define UPSZ(X) _ALIGN_UP(sizeof(X), 4)
-static char cmdline_buf[256] = "kexec ";
+
+#define CMDLINE_PREFIX "kexec "
+static char cmdline_buf[COMMAND_LINE_SIZE] = CMDLINE_PREFIX;
 
 int elf_mips_probe(const char *buf, off_t len)
 {
@@ -74,6 +77,10 @@ int elf_mips_load(int argc, char **argv, const char *buf, 
off_t len,
int result;
unsigned long cmdline_addr;
size_t i;
+   off_t dtb_length;
+   char *dtb_buf;
+   unsigned long long kernel_addr = 0, kernel_size = 0;
+   unsigned long pagesize = getpagesize();
 
/* Need to append some command line parameters internally in case of
 * taking crash dumps.
@@ -92,8 +99,11 @@ int elf_mips_load(int argc, char **argv, const char *buf, 
off_t len,
for (i = 0; i < ehdr.e_phnum; i++) {
struct mem_phdr *phdr;
phdr = &ehdr.e_phdr[i];
-   if (phdr->p_type == PT_LOAD)
+   if (phdr->p_type == PT_LOAD) {
phdr->p_paddr = virt_to_phys(phdr->p_paddr);
+   kernel_addr = phdr->p_paddr;
+   kernel_size = phdr->p_memsz;
+   }
}
 
/* Load the Elf data */
@@ -130,10 +140,28 @@ int elf_mips_load(int argc, char **argv, const char *buf, 
off_t len,
else
cmdline_addr = 0;
 
+   /* MIPS systems that have been converted to use device tree
+* passed through UHI will use commandline in the DTB and
+* the DTB passed as a separate buffer. Note th

[PATCH 1/6] mips: remove incorrect arch_usage string

2016-12-02 Thread Marcin Nowakowski
arch_usage shows '--elf32-core-headers' as an option, but this is not
implemented.

Signed-off-by: Marcin Nowakowski 
---
 kexec/arch/mips/kexec-mips.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index fe0c945..ebc3d9a 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -74,10 +74,6 @@ int file_types = sizeof(file_type) / sizeof(file_type[0]);
 
 void arch_usage(void)
 {
-#ifdef __mips64
-   fprintf(stderr, " --elf32-core-headers Prepare core headers in "
-   "ELF32 format\n");
-#endif
 }
 
 #ifdef __mips64
-- 
2.7.4


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


[PATCH 0/6] Kexec fixes and updates for MIPS platforms

2016-12-02 Thread Marcin Nowakowski
This patch series tries to bring the support for MIPS up to date and make it 
more
generic (fix little-endian support, simplify code for 32/64 bit handling), as 
well
as to clean up some existing incorrect code (patches 1-4).

Patches 5 & 6 add new functionality - passing external DTBs and initrd, 
especially
the DTB support is required for platforms that use a recently introduced generic
kernel infrastructure.

Note that patch 5 (and 6, as it depends on patch 5) require changes in the 
kernel
that are currently pending review:
https://patchwork.linux-mips.org/patch/14615/

Core dump support is currently broken on all MIPS kernels and is also pending
review:
https://patchwork.linux-mips.org/patch/14587/
https://patchwork.linux-mips.org/patch/14586/

Patches 1-4 can be safely added without waiting for kernel patches to be merged,
but patches 5-6 should be held until the kernel patches are accepted in case 
changes
are requested.

Cc: Ralf Baechle 
Cc: linux-m...@linux-mips.org

Marcin Nowakowski (6):
  mips: remove incorrect arch_usage string
  mips: use arch_options for both 32 and 64 bit variants
  mips: move arch option parsing from elf loader to common arch code
  mips: crashdump: add little-endian support
  mips: add dtb loading support
  mips: add option to load initrd from a specified file

 kexec/arch/mips/Makefile   | 13 +
 kexec/arch/mips/crashdump-mips.c   | 22 +---
 kexec/arch/mips/include/arch/options.h | 11 ++--
 kexec/arch/mips/kexec-elf-mips.c   | 96 +++---
 kexec/arch/mips/kexec-mips.c   | 46 +---
 kexec/arch/mips/kexec-mips.h   | 13 -
 6 files changed, 142 insertions(+), 59 deletions(-)

-- 
2.7.4


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


[PATCH 2/6] mips: use arch_options for both 32 and 64 bit variants

2016-12-02 Thread Marcin Nowakowski
At the moment arch_options structure is defined for 64-bit only and is
used exclusively in ifdef'ed code. Remove the ifdefs around the uses of
the structure and define it for all code variants as it will be used for
passing more arch options in the followup commits.

Signed-off-by: Marcin Nowakowski 
---
 kexec/arch/mips/crashdump-mips.c | 7 ++-
 kexec/arch/mips/kexec-mips.c | 8 +---
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index dc68cb4..e56b3ef 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -288,7 +288,6 @@ static int cmdline_add_elfcorehdr(char *cmdline, unsigned 
long addr)
return 0;
 }
 
-#ifdef __mips64
 static struct crash_elf_info elf_info64 = {
class: ELFCLASS64,
data : ELFDATA2MSB,
@@ -296,7 +295,7 @@ static struct crash_elf_info elf_info64 = {
page_offset : PAGE_OFFSET,
lowmem_limit : MAXMEM,
 };
-#endif
+
 static struct crash_elf_info elf_info32 = {
class: ELFCLASS32,
data : ELFDATA2MSB,
@@ -321,13 +320,11 @@ int load_crashdump_segments(struct kexec_info *info, 
char* mod_cmdline,
struct crash_elf_info *elf_info = &elf_info32;
unsigned long start_offset = 0x8000UL;
 
-#ifdef __mips64
if (arch_options.core_header_type == CORE_TYPE_ELF64) {
elf_info = &elf_info64;
crash_create = crash_create_elf64_headers;
-   start_offset = 0x8000UL;
+   start_offset = (unsigned long)0x8000UL;
}
-#endif
 
if (get_kernel_paddr(elf_info))
return -1;
diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index ebc3d9a..de9019a 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -76,11 +76,13 @@ void arch_usage(void)
 {
 }
 
-#ifdef __mips64
 struct arch_options_t arch_options = {
-   .core_header_type = CORE_TYPE_ELF64
-};
+#ifdef __mips64
+   .core_header_type = CORE_TYPE_ELF64,
+#else
+   .core_header_type = CORE_TYPE_ELF32,
 #endif
+};
 
 int arch_process_options(int argc, char **argv)
 {
-- 
2.7.4


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


[PATCH 6/6] mips: add option to load initrd from a specified file

2016-12-02 Thread Marcin Nowakowski
Use kexec's existing infrastrucutre for supporting initrd loading.
The initrd image is loaded into a buffer after the dtb and its details
passed through the device tree, so it's supported on newer platforms
that make use of the device tree passed from kexec.

Signed-off-by: Marcin Nowakowski 
Cc: Ralf Baechle 
Cc: linux-m...@linux-mips.org
---
 kexec/arch/mips/include/arch/options.h |  4 +++-
 kexec/arch/mips/kexec-elf-mips.c   | 19 +++
 kexec/arch/mips/kexec-mips.c   |  4 
 kexec/arch/mips/kexec-mips.h   |  1 +
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/mips/include/arch/options.h 
b/kexec/arch/mips/include/arch/options.h
index 86b620f..416e224 100644
--- a/kexec/arch/mips/include/arch/options.h
+++ b/kexec/arch/mips/include/arch/options.h
@@ -4,6 +4,7 @@
 #define OPT_ARCH_MAX   (OPT_MAX+0)
 #define OPT_APPEND (OPT_ARCH_MAX+0)
 #define OPT_DTB(OPT_ARCH_MAX+1)
+#define OPT_RAMDISK(OPT_ARCH_MAX+2)
 
 /* Options relevant to the architecture (excluding loader-specific ones),
  * in this case none:
@@ -12,7 +13,8 @@
KEXEC_OPTIONS \
{"command-line", 1, 0, OPT_APPEND}, \
{"append",   1, 0, OPT_APPEND}, \
-   {"dtb", 1, 0, OPT_DTB },
+   {"dtb", 1, 0, OPT_DTB }, \
+   {"initrd",  1, 0, OPT_RAMDISK },
 
 
 #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index 6ca7ca0..849a7ba 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -79,6 +79,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, 
off_t len,
size_t i;
off_t dtb_length;
char *dtb_buf;
+   char *initrd_buf = NULL;
unsigned long long kernel_addr = 0, kernel_size = 0;
unsigned long pagesize = getpagesize();
 
@@ -152,6 +153,24 @@ int elf_mips_load(int argc, char **argv, const char *buf, 
off_t len,
create_flatten_tree(&dtb_buf, &dtb_length, cmdline_buf + 
strlen(CMDLINE_PREFIX));
}
 
+   if (arch_options.initrd_file) {
+   initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size);
+
+   /* Create initrd entries in dtb - although at this time
+* they would not point to the correct location */
+   dtb_set_initrd(&dtb_buf, &dtb_length, initrd_buf, initrd_buf + 
initrd_size);
+
+   initrd_base = add_buffer(info, initrd_buf, initrd_size,
+   initrd_size, sizeof(void *),
+   _ALIGN_UP(kernel_addr + kernel_size + 
dtb_length,
+   pagesize), 0x0fff, 1);
+
+   /* Now that the buffer for initrd is prepared, update the dtb
+* with an appropriate location */
+   dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base 
+ initrd_size);
+   }
+
+
/* This is a legacy method for commandline passing used
 * currently by Octeon CPUs only */
add_buffer(info, cmdline_buf, sizeof(cmdline_buf),
diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index 2605c17..ee3cd3a 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -82,6 +82,7 @@ void arch_usage(void)
"--command-line=STRING Set the kernel command line to STRING.\n"
"--append=STRING   Set the kernel command line to STRING.\n"
"--dtb=FILEUse FILE as the device tree blob.\n"
+   "--initrd=FILE Use FILE as initial ramdisk.\n"
);
 }
 
@@ -111,6 +112,9 @@ int arch_process_options(int argc, char **argv)
case OPT_DTB:
arch_options.dtb_file = optarg;
break;
+   case OPT_RAMDISK:
+   arch_options.initrd_file = optarg;
+   break;
default:
break;
}
diff --git a/kexec/arch/mips/kexec-mips.h b/kexec/arch/mips/kexec-mips.h
index a609fb5..222c815 100644
--- a/kexec/arch/mips/kexec-mips.h
+++ b/kexec/arch/mips/kexec-mips.h
@@ -20,6 +20,7 @@ void elf_mips_usage(void);
 struct arch_options_t {
char *command_line;
char *dtb_file;
+   char *initrd_file;
int core_header_type;
 };
 
-- 
2.7.4


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


[PATCH 4/6] mips: crashdump: add little-endian support

2016-12-02 Thread Marcin Nowakowski
Elf header for crashdump has until now been hardcoded as big-endian.
Change that to use the native endianness for the compile target so that
the crashdumps are generated properly for each CPU type.

Signed-off-by: Marcin Nowakowski 
---
 kexec/arch/mips/crashdump-mips.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index e56b3ef..278ee01 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -288,9 +288,17 @@ static int cmdline_add_elfcorehdr(char *cmdline, unsigned 
long addr)
return 0;
 }
 
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define ELFDATALOCAL ELFDATA2LSB
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define ELFDATALOCAL ELFDATA2MSB
+#else
+# error Unknown byte order
+#endif
+
 static struct crash_elf_info elf_info64 = {
class: ELFCLASS64,
-   data : ELFDATA2MSB,
+   data : ELFDATALOCAL,
machine : EM_MIPS,
page_offset : PAGE_OFFSET,
lowmem_limit : MAXMEM,
@@ -298,7 +306,7 @@ static struct crash_elf_info elf_info64 = {
 
 static struct crash_elf_info elf_info32 = {
class: ELFCLASS32,
-   data : ELFDATA2MSB,
+   data : ELFDATALOCAL,
machine : EM_MIPS,
page_offset : PAGE_OFFSET,
lowmem_limit : MAXMEM,
-- 
2.7.4


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


[PATCH 3/6] mips: move arch option parsing from elf loader to common arch code

2016-12-02 Thread Marcin Nowakowski
At the moment only commandline handling is implemented and there is
nothing elf-specific about it, so all of the commandline parsing logic
can be moved to common arch code.
getopt() options are moved to KEXEC_ARCH_OPTIONS macro (as many
platforms currently do) to avoid unnecessary duplication.

Signed-off-by: Marcin Nowakowski 
---
 kexec/arch/mips/include/arch/options.h |  6 ++---
 kexec/arch/mips/kexec-elf-mips.c   | 43 --
 kexec/arch/mips/kexec-mips.c   | 22 +
 kexec/arch/mips/kexec-mips.h   |  3 ++-
 4 files changed, 32 insertions(+), 42 deletions(-)

diff --git a/kexec/arch/mips/include/arch/options.h 
b/kexec/arch/mips/include/arch/options.h
index 07b4f63..a18251b 100644
--- a/kexec/arch/mips/include/arch/options.h
+++ b/kexec/arch/mips/include/arch/options.h
@@ -9,6 +9,8 @@
  */
 #define KEXEC_ARCH_OPTIONS \
KEXEC_OPTIONS \
+   {"command-line", 1, 0, OPT_APPEND}, \
+   {"append",   1, 0, OPT_APPEND},
 
 #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""
 
@@ -27,9 +29,7 @@
  * recognise -- as they now recognise (if not act upon) all possible options.
  */
 #define KEXEC_ALL_OPTIONS  \
-   KEXEC_ARCH_OPTIONS  \
-   {"command-line", 1, 0, OPT_APPEND}, \
-   {"append",   1, 0, OPT_APPEND},
+   KEXEC_ARCH_OPTIONS
 
 #define KEXEC_ALL_OPT_STR KEXEC_ARCH_OPT_STR
 
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index 8a6419a..7cb06f1 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -63,51 +63,18 @@ int elf_mips_probe(const char *buf, off_t len)
 
 void elf_mips_usage(void)
 {
-   printf("--command-line=STRING Set the kernel command line to "
-   "STRING.\n"
-  "--append=STRING   Set the kernel command line to "
-   "STRING.\n");
 }
 
 int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info)
 {
struct mem_ehdr ehdr;
-   const char *command_line;
-   int command_line_len;
+   int command_line_len = 0;
char *crash_cmdline;
-   int opt;
int result;
unsigned long cmdline_addr;
size_t i;
 
-   /* See options.h if adding any more options. */
-   static const struct option options[] = {
-   KEXEC_ARCH_OPTIONS
-   {"command-line", 1, 0, OPT_APPEND},
-   {"append",   1, 0, OPT_APPEND},
-   {0, 0, 0, 0},
-   };
-
-   static const char short_options[] = KEXEC_ARCH_OPT_STR "d";
-
-   command_line = 0;
-   while ((opt = getopt_long(argc, argv, short_options,
- options, 0)) != -1) {
-   switch (opt) {
-   default:
-   /* Ignore core options */
-   if (opt < OPT_ARCH_MAX) {
-   break;
-   }
-   case OPT_APPEND:
-   command_line = optarg;
-   break;
-   }
-   }
-
-   command_line_len = 0;
-
/* Need to append some command line parameters internally in case of
 * taking crash dumps.
 */
@@ -136,8 +103,8 @@ int elf_mips_load(int argc, char **argv, const char *buf, 
off_t len,
 
info->entry = (void *)virt_to_phys(ehdr.e_entry);
 
-   if (command_line)
-   command_line_len = strlen(command_line) + 1;
+   if (arch_options.command_line)
+   command_line_len = strlen(arch_options.command_line) + 1;
 
if (info->kexec_flags & KEXEC_ON_CRASH) {
result = load_crashdump_segments(info, crash_cmdline,
@@ -148,8 +115,8 @@ int elf_mips_load(int argc, char **argv, const char *buf, 
off_t len,
}
}
 
-   if (command_line)
-   strncat(cmdline_buf, command_line, command_line_len);
+   if (arch_options.command_line)
+   strncat(cmdline_buf, arch_options.command_line, 
command_line_len);
if (crash_cmdline)
strncat(cmdline_buf, crash_cmdline,
sizeof(crash_cmdline) -
diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index de9019a..867e9c3 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -74,6 +74,10 @@ int file_types = sizeof(file_type) / sizeof(file_type[0]);
 
 void arch_usage(void)
 {
+   printf(
+   "--command-line=STRING Set the kernel command line to STRING.\n"
+   "--append=STRING   Set the kernel command line to STRING.\n"
+   );
 }
 
 struct arch_options_t arch_options = {
@@ -86,6 +90,24 @@ struct arch_options_t arch_options = {
 
 int arch_process_options(int argc, char **argv)
 {
+   static const struct option options[] = {
+   KEXEC_ARCH_OPTIONS
+   { 0 },
+   }

[ANNOUNCE] kexec-tools v2.0.14 preparation

2016-12-02 Thread Simon Horman
Hi all,

I am planning to release kexec-tools v2.0.14 around the time that
the v4.9 kernel is released.

I would like to ask interested parties to send any patches they would like
included in v2.0.14 within one week so that I can make an rc release.

For reference the patches queued up since v2.0.13 are as follows:

0a7fba8b1453 purgatory: Change default sha256 optimization to -O2
ec271d6c2988 arm64: Add support of R_AARCH64_PREL32 relocation in purgatory
c743758d77b8 arm64: Add support for additional relocations in the kexec 
purgatory code
e345e27417db arm64: Add missing kexec dist files
402cf1427293 arm64: Cleanup kexec Makefile
16fd64af363b kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()
6e8804f9ca67 multiboot: Use the "reserved" type for non-ram zones
53634c3e9a0c multiboot: Fix length computation for the memory zones
97b6f5f78d95 kexec elf: Sanity check on the note header before accessing it
1574ff1aae4f arm: include phys_to_virt.h and iomem.h in distribution
29086f45a45f kexec: socket not released when error situation occur.
9fd57cad8a0f kexec: fix mem_regions_sort()
9f62cbfc kexec/arch/i386: Add support for KASLR memory randomization
abdfe97736f8 arm64: Add support for binary image files
522df5f7217f arm64: Add arm64 kexec support
217bcc00c930 kexec: Add common device tree routines
f7a0ff52e04d kexec-tools 2.0.13.git

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


Re: [PATCH V2] purgatory: Change default sha256 optimization to -O2

2016-12-02 Thread Simon Horman
On Thu, Dec 01, 2016 at 11:09:37AM -0800, Geoff Levand wrote:
> Change the default purgatory sha256 code optimization from -O0 to -O2, and 
> add a
> new arch specific makefile variable $(ARCH)_PURGATORY_SHA256_CFLAGS which can
> over ride this default.  Set ia64_PURGATORY_SHA256_CFLAGS to -O0 to retain the
> previous optimization level for ia64.
> 
> The purgatory sha256 code needs the be built with -O0 for the  ia64
> architecture.  Currently this code is built with -O0 for all architectures,
> which slows down the calculations for architectures which could otherwise
> use -O2.
> 
> On arm64, it takes around 20 second to verify SHA in purgatory when
> vmlinuz image is around 13MB and initramfs is around 30M with -O2
> enabled. Otherwise, it takes more than 2 minutes.
> 
> Cc: Pratyush Anand 
> Signed-off-by: Geoff Levand 

Thanks, applied.

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