linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/5] kexec: Add bit definitions for kimage entry flags
  2014-08-22 18:39 [PATCH 0/5] kexec: minor fixups and enhancements Geoff Levand
@ 2014-08-22 18:39 ` Geoff Levand
  2014-08-25 17:52   ` Vivek Goyal
  2014-08-22 18:39 ` [PATCH 1/5] kexec: Fix make headers_check Geoff Levand
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 35+ messages in thread
From: Geoff Levand @ 2014-08-22 18:39 UTC (permalink / raw)
  To: Eric Biederman
  Cc: Andrew Morton, kexec, Benjamin Herrenschmidt, linuxppc-dev, linux-kernel

Define new kexec preprocessor macros IND_*_BIT that define the bit position of
the kimage entry flags.  Change the existing IND_* flag macros to be defined as
bit shifts of the corresponding IND_*_BIT macros.  Also wrap all C language code
in kexec.h with #if !defined(__ASSEMBLY__) so assembly files can include kexec.h
to get the IND_* and IND_*_BIT macros.

Some CPU instruction sets have tests for bit position which are convenient in
implementing routines that operate on the kimage entry list.  The addition of
these bit position macros in a common location will avoid duplicate definitions
and the chance that changes to the IND_* flags will not be propagated to
assembly files.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 include/linux/kexec.h | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 4b2a0e1..8c628ca 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -1,6 +1,18 @@
 #ifndef LINUX_KEXEC_H
 #define LINUX_KEXEC_H
 
+#define IND_DESTINATION_BIT 0
+#define IND_INDIRECTION_BIT 1
+#define IND_DONE_BIT        2
+#define IND_SOURCE_BIT      3
+
+#define IND_DESTINATION  (1 << IND_DESTINATION_BIT)
+#define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
+#define IND_DONE         (1 << IND_DONE_BIT)
+#define IND_SOURCE       (1 << IND_SOURCE_BIT)
+
+#if !defined(__ASSEMBLY__)
+
 #include <uapi/linux/kexec.h>
 
 #ifdef CONFIG_KEXEC
@@ -64,10 +76,6 @@
  */
 
 typedef unsigned long kimage_entry_t;
-#define IND_DESTINATION  0x1
-#define IND_INDIRECTION  0x2
-#define IND_DONE         0x4
-#define IND_SOURCE       0x8
 
 struct kexec_segment {
 	/*
@@ -312,4 +320,7 @@ struct task_struct;
 static inline void crash_kexec(struct pt_regs *regs) { }
 static inline int kexec_should_crash(struct task_struct *p) { return 0; }
 #endif /* CONFIG_KEXEC */
+
+#endif /* !defined(__ASSEBMLY__) */
+
 #endif /* LINUX_KEXEC_H */
-- 
1.9.1



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

* [PATCH 5/5] powerpc/kexec: Use global IND_FLAGS macro
  2014-08-22 18:39 [PATCH 0/5] kexec: minor fixups and enhancements Geoff Levand
  2014-08-22 18:39 ` [PATCH 3/5] kexec: Add bit definitions for kimage entry flags Geoff Levand
  2014-08-22 18:39 ` [PATCH 1/5] kexec: Fix make headers_check Geoff Levand
@ 2014-08-22 18:39 ` Geoff Levand
  2014-08-22 18:39 ` [PATCH 4/5] kexec: Add " Geoff Levand
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-08-22 18:39 UTC (permalink / raw)
  To: Eric Biederman
  Cc: Andrew Morton, kexec, Benjamin Herrenschmidt, linuxppc-dev, linux-kernel

linux/kexec.h now defines an IND_FLAGS macro.  Remove the local powerpc
definition and use the generic one.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/kernel/machine_kexec_64.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 879b3aa..75652a32 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -96,8 +96,6 @@ int default_machine_kexec_prepare(struct kimage *image)
 	return 0;
 }
 
-#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
-
 static void copy_segments(unsigned long ind)
 {
 	unsigned long entry;
-- 
1.9.1


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

* [PATCH 2/5] kexec: Simplify conditional
  2014-08-22 18:39 [PATCH 0/5] kexec: minor fixups and enhancements Geoff Levand
                   ` (3 preceding siblings ...)
  2014-08-22 18:39 ` [PATCH 4/5] kexec: Add " Geoff Levand
@ 2014-08-22 18:39 ` Geoff Levand
  2014-08-25 17:42   ` Vivek Goyal
  2014-08-25 16:59 ` [PATCH 0/5] kexec: minor fixups and enhancements Vivek Goyal
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 35+ messages in thread
From: Geoff Levand @ 2014-08-22 18:39 UTC (permalink / raw)
  To: Eric Biederman
  Cc: Andrew Morton, kexec, Benjamin Herrenschmidt, linuxppc-dev, linux-kernel

Simplify the code around one of the conditionals in the kexec_load
syscall routine.

The original code was confusing with a redundant check on KEXEC_ON_CRASH
and comments outside of the conditional block.  This change switches the
order of the conditional check, and cleans up the comments for the
conditional.  There is no functional change to the code.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 kernel/kexec.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/kernel/kexec.c b/kernel/kexec.c
index 0b49a0a..d04b56e 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1282,19 +1282,22 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
 	if (nr_segments > 0) {
 		unsigned long i;
 
-		/* Loading another kernel to reboot into */
-		if ((flags & KEXEC_ON_CRASH) == 0)
-			result = kimage_alloc_init(&image, entry, nr_segments,
-						   segments, flags);
-		/* Loading another kernel to switch to if this one crashes */
-		else if (flags & KEXEC_ON_CRASH) {
-			/* Free any current crash dump kernel before
+		if (flags & KEXEC_ON_CRASH) {
+			/*
+			 * Loading another kernel to switch to if this one
+			 * crashes.  Free any current crash dump kernel before
 			 * we corrupt it.
 			 */
+
 			kimage_free(xchg(&kexec_crash_image, NULL));
 			result = kimage_alloc_init(&image, entry, nr_segments,
 						   segments, flags);
 			crash_map_reserved_pages();
+		} else {
+			/* Loading another kernel to reboot into. */
+
+			result = kimage_alloc_init(&image, entry, nr_segments,
+						   segments, flags);
 		}
 		if (result)
 			goto out;
-- 
1.9.1



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

* [PATCH 1/5] kexec: Fix make headers_check
  2014-08-22 18:39 [PATCH 0/5] kexec: minor fixups and enhancements Geoff Levand
  2014-08-22 18:39 ` [PATCH 3/5] kexec: Add bit definitions for kimage entry flags Geoff Levand
@ 2014-08-22 18:39 ` Geoff Levand
  2014-08-25 17:22   ` Vivek Goyal
  2014-08-22 18:39 ` [PATCH 5/5] powerpc/kexec: Use global IND_FLAGS macro Geoff Levand
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 35+ messages in thread
From: Geoff Levand @ 2014-08-22 18:39 UTC (permalink / raw)
  To: Eric Biederman
  Cc: Andrew Morton, kexec, Benjamin Herrenschmidt, linuxppc-dev, linux-kernel

Remove the unneded declaration for a kexec_load() routine.

Fixes errors like these when running 'make headers_check':

include/uapi/linux/kexec.h: userspace cannot reference function or variable defined in the kernel

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 include/uapi/linux/kexec.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
index 6925f5b..99048e5 100644
--- a/include/uapi/linux/kexec.h
+++ b/include/uapi/linux/kexec.h
@@ -55,12 +55,6 @@ struct kexec_segment {
 	size_t memsz;
 };
 
-/* Load a new kernel image as described by the kexec_segment array
- * consisting of passed number of segments at the entry-point address.
- * The flags allow different useage types.
- */
-extern int kexec_load(void *, size_t, struct kexec_segment *,
-		unsigned long int);
 #endif /* __KERNEL__ */
 
 #endif /* _UAPILINUX_KEXEC_H */
-- 
1.9.1



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

* [PATCH 4/5] kexec: Add IND_FLAGS macro
  2014-08-22 18:39 [PATCH 0/5] kexec: minor fixups and enhancements Geoff Levand
                   ` (2 preceding siblings ...)
  2014-08-22 18:39 ` [PATCH 5/5] powerpc/kexec: Use global IND_FLAGS macro Geoff Levand
@ 2014-08-22 18:39 ` Geoff Levand
  2014-08-25 17:54   ` Vivek Goyal
  2014-08-22 18:39 ` [PATCH 2/5] kexec: Simplify conditional Geoff Levand
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 35+ messages in thread
From: Geoff Levand @ 2014-08-22 18:39 UTC (permalink / raw)
  To: Eric Biederman
  Cc: Andrew Morton, kexec, Benjamin Herrenschmidt, linuxppc-dev, linux-kernel

Add a new kexec preprocessor macro IND_FLAGS, which is the bitwise OR of
all the possible kexec IND_ kimage_entry indirection flags.

Having this macro allows for simplified code in the prosessing of the
kexec kimage_entry items.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 include/linux/kexec.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 8c628ca..a4758f9 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -10,6 +10,7 @@
 #define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
 #define IND_DONE         (1 << IND_DONE_BIT)
 #define IND_SOURCE       (1 << IND_SOURCE_BIT)
+#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
 
 #if !defined(__ASSEMBLY__)
 
-- 
1.9.1



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

* [PATCH 0/5] kexec: minor fixups and enhancements
@ 2014-08-22 18:39 Geoff Levand
  2014-08-22 18:39 ` [PATCH 3/5] kexec: Add bit definitions for kimage entry flags Geoff Levand
                   ` (7 more replies)
  0 siblings, 8 replies; 35+ messages in thread
From: Geoff Levand @ 2014-08-22 18:39 UTC (permalink / raw)
  To: Eric Biederman
  Cc: Andrew Morton, kexec, Benjamin Herrenschmidt, linuxppc-dev, linux-kernel

Hi,

Here are a few minor fixups and enhancements for kexec support. 

Patch 3 and 4 that add preprocessor macros for the kimage list flags are
ones that I use in the arm64 kexec support I am working on, so it would
be nice for those to go in.

Please consider.

-Geoff
    
The following changes since commit 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9:

  Linux 3.17-rc1 (2014-08-16 10:40:26 -0600)

are available in the git repository at:

  git://git.linaro.org/people/geoff.levand/linux-kexec.git for-kexec

for you to fetch changes up to dc3c63e69815e00dce5454bd50e2991e9ea33f64:

  powerpc/kexec: Use global IND_FLAGS macro (2014-08-22 11:15:18 -0700)

----------------------------------------------------------------
Geoff Levand (5):
      kexec: Fix make headers_check
      kexec: Simplify conditional
      kexec: Add bit definitions for kimage entry flags
      kexec: Add IND_FLAGS macro
      powerpc/kexec: Use global IND_FLAGS macro

 arch/powerpc/kernel/machine_kexec_64.c |  2 --
 include/linux/kexec.h                  | 20 ++++++++++++++++----
 include/uapi/linux/kexec.h             |  6 ------
 kernel/kexec.c                         | 17 ++++++++++-------
 4 files changed, 26 insertions(+), 19 deletions(-)

-- 
1.9.1


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

* Re: [PATCH 0/5] kexec: minor fixups and enhancements
  2014-08-22 18:39 [PATCH 0/5] kexec: minor fixups and enhancements Geoff Levand
                   ` (4 preceding siblings ...)
  2014-08-22 18:39 ` [PATCH 2/5] kexec: Simplify conditional Geoff Levand
@ 2014-08-25 16:59 ` Vivek Goyal
  2014-08-26  7:41   ` Dave Young
  2014-08-27  0:33   ` Geoff Levand
  2014-10-07  0:21 ` [PATCH V2 0/5] kexec: Minor " Geoff Levand
  2014-11-13  0:19 ` [PATCH V3 0/4] kexec: minor fixups and enhancements Geoff Levand
  7 siblings, 2 replies; 35+ messages in thread
From: Vivek Goyal @ 2014-08-25 16:59 UTC (permalink / raw)
  To: Geoff Levand
  Cc: Eric Biederman, Benjamin Herrenschmidt, Andrew Morton, kexec,
	linuxppc-dev, linux-kernel

On Fri, Aug 22, 2014 at 06:39:47PM +0000, Geoff Levand wrote:
> Hi,
> 
> Here are a few minor fixups and enhancements for kexec support. 
> 
> Patch 3 and 4 that add preprocessor macros for the kimage list flags are
> ones that I use in the arm64 kexec support I am working on, so it would
> be nice for those to go in.
> 
> Please consider.

Hi Geoff,

Does arm64 has secureboot? If yes, then it might make sense to
enable the new syscall kexec_file_load() on arm64 instead of trying
to make old syscall work first.

Thanks
Vivek

> 
> -Geoff
>     
> The following changes since commit 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9:
> 
>   Linux 3.17-rc1 (2014-08-16 10:40:26 -0600)
> 
> are available in the git repository at:
> 
>   git://git.linaro.org/people/geoff.levand/linux-kexec.git for-kexec
> 
> for you to fetch changes up to dc3c63e69815e00dce5454bd50e2991e9ea33f64:
> 
>   powerpc/kexec: Use global IND_FLAGS macro (2014-08-22 11:15:18 -0700)
> 
> ----------------------------------------------------------------
> Geoff Levand (5):
>       kexec: Fix make headers_check
>       kexec: Simplify conditional
>       kexec: Add bit definitions for kimage entry flags
>       kexec: Add IND_FLAGS macro
>       powerpc/kexec: Use global IND_FLAGS macro
> 
>  arch/powerpc/kernel/machine_kexec_64.c |  2 --
>  include/linux/kexec.h                  | 20 ++++++++++++++++----
>  include/uapi/linux/kexec.h             |  6 ------
>  kernel/kexec.c                         | 17 ++++++++++-------
>  4 files changed, 26 insertions(+), 19 deletions(-)
> 
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH 1/5] kexec: Fix make headers_check
  2014-08-22 18:39 ` [PATCH 1/5] kexec: Fix make headers_check Geoff Levand
@ 2014-08-25 17:22   ` Vivek Goyal
  2014-08-30 12:47     ` Paul Bolle
  0 siblings, 1 reply; 35+ messages in thread
From: Vivek Goyal @ 2014-08-25 17:22 UTC (permalink / raw)
  To: Geoff Levand
  Cc: Eric Biederman, Benjamin Herrenschmidt, Andrew Morton, kexec,
	linuxppc-dev, linux-kernel, maximilian attems, Paul Bolle

On Fri, Aug 22, 2014 at 06:39:47PM +0000, Geoff Levand wrote:
> Remove the unneded declaration for a kexec_load() routine.
> 
> Fixes errors like these when running 'make headers_check':
> 
> include/uapi/linux/kexec.h: userspace cannot reference function or variable defined in the kernel
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>

I think Paul Bolle tried to remove this in the past and maximilian
had objections.

http://lists.infradead.org/pipermail/kexec/2014-January/010902.html

I can't see that how exporting kernel prototype helps here. kexec-tools
seems to be using syscall(__NR_kexec_load) directly for non-xen case. So
I would be fine with removing this definition. Just trying to make sure
that it does not break any other library or users of this declaration.

Thanks
Vivek


> ---
>  include/uapi/linux/kexec.h | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
> index 6925f5b..99048e5 100644
> --- a/include/uapi/linux/kexec.h
> +++ b/include/uapi/linux/kexec.h
> @@ -55,12 +55,6 @@ struct kexec_segment {
>  	size_t memsz;
>  };
>  
> -/* Load a new kernel image as described by the kexec_segment array
> - * consisting of passed number of segments at the entry-point address.
> - * The flags allow different useage types.
> - */
> -extern int kexec_load(void *, size_t, struct kexec_segment *,
> -		unsigned long int);
>  #endif /* __KERNEL__ */
>  
>  #endif /* _UAPILINUX_KEXEC_H */
> -- 
> 1.9.1
> 
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH 2/5] kexec: Simplify conditional
  2014-08-22 18:39 ` [PATCH 2/5] kexec: Simplify conditional Geoff Levand
@ 2014-08-25 17:42   ` Vivek Goyal
  0 siblings, 0 replies; 35+ messages in thread
From: Vivek Goyal @ 2014-08-25 17:42 UTC (permalink / raw)
  To: Geoff Levand
  Cc: Eric Biederman, Benjamin Herrenschmidt, Andrew Morton, kexec,
	linuxppc-dev, linux-kernel

On Fri, Aug 22, 2014 at 06:39:47PM +0000, Geoff Levand wrote:
> Simplify the code around one of the conditionals in the kexec_load
> syscall routine.
> 
> The original code was confusing with a redundant check on KEXEC_ON_CRASH
> and comments outside of the conditional block.  This change switches the
> order of the conditional check, and cleans up the comments for the
> conditional.  There is no functional change to the code.
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>

This is simple reorganization.

Acked-by: Vivek Goyal <vgoyal@redhat.com>

Vivek

> ---
>  kernel/kexec.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/kexec.c b/kernel/kexec.c
> index 0b49a0a..d04b56e 100644
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -1282,19 +1282,22 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
>  	if (nr_segments > 0) {
>  		unsigned long i;
>  
> -		/* Loading another kernel to reboot into */
> -		if ((flags & KEXEC_ON_CRASH) == 0)
> -			result = kimage_alloc_init(&image, entry, nr_segments,
> -						   segments, flags);
> -		/* Loading another kernel to switch to if this one crashes */
> -		else if (flags & KEXEC_ON_CRASH) {
> -			/* Free any current crash dump kernel before
> +		if (flags & KEXEC_ON_CRASH) {
> +			/*
> +			 * Loading another kernel to switch to if this one
> +			 * crashes.  Free any current crash dump kernel before
>  			 * we corrupt it.
>  			 */
> +
>  			kimage_free(xchg(&kexec_crash_image, NULL));
>  			result = kimage_alloc_init(&image, entry, nr_segments,
>  						   segments, flags);
>  			crash_map_reserved_pages();
> +		} else {
> +			/* Loading another kernel to reboot into. */
> +
> +			result = kimage_alloc_init(&image, entry, nr_segments,
> +						   segments, flags);
>  		}
>  		if (result)
>  			goto out;
> -- 
> 1.9.1
> 
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH 3/5] kexec: Add bit definitions for kimage entry flags
  2014-08-22 18:39 ` [PATCH 3/5] kexec: Add bit definitions for kimage entry flags Geoff Levand
@ 2014-08-25 17:52   ` Vivek Goyal
  0 siblings, 0 replies; 35+ messages in thread
From: Vivek Goyal @ 2014-08-25 17:52 UTC (permalink / raw)
  To: Geoff Levand
  Cc: Eric Biederman, Benjamin Herrenschmidt, Andrew Morton, kexec,
	linuxppc-dev, linux-kernel

On Fri, Aug 22, 2014 at 06:39:47PM +0000, Geoff Levand wrote:
> Define new kexec preprocessor macros IND_*_BIT that define the bit position of
> the kimage entry flags.  Change the existing IND_* flag macros to be defined as
> bit shifts of the corresponding IND_*_BIT macros.  Also wrap all C language code
> in kexec.h with #if !defined(__ASSEMBLY__) so assembly files can include kexec.h
> to get the IND_* and IND_*_BIT macros.
> 
> Some CPU instruction sets have tests for bit position which are convenient in
> implementing routines that operate on the kimage entry list.  The addition of
> these bit position macros in a common location will avoid duplicate definitions
> and the chance that changes to the IND_* flags will not be propagated to
> assembly files.
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>

Looks good to me.

Acked-by: Vivek Goyal <vgoyal@redhat.com>

Vivek

> ---
>  include/linux/kexec.h | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
> index 4b2a0e1..8c628ca 100644
> --- a/include/linux/kexec.h
> +++ b/include/linux/kexec.h
> @@ -1,6 +1,18 @@
>  #ifndef LINUX_KEXEC_H
>  #define LINUX_KEXEC_H
>  
> +#define IND_DESTINATION_BIT 0
> +#define IND_INDIRECTION_BIT 1
> +#define IND_DONE_BIT        2
> +#define IND_SOURCE_BIT      3
> +
> +#define IND_DESTINATION  (1 << IND_DESTINATION_BIT)
> +#define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
> +#define IND_DONE         (1 << IND_DONE_BIT)
> +#define IND_SOURCE       (1 << IND_SOURCE_BIT)
> +
> +#if !defined(__ASSEMBLY__)
> +
>  #include <uapi/linux/kexec.h>
>  
>  #ifdef CONFIG_KEXEC
> @@ -64,10 +76,6 @@
>   */
>  
>  typedef unsigned long kimage_entry_t;
> -#define IND_DESTINATION  0x1
> -#define IND_INDIRECTION  0x2
> -#define IND_DONE         0x4
> -#define IND_SOURCE       0x8
>  
>  struct kexec_segment {
>  	/*
> @@ -312,4 +320,7 @@ struct task_struct;
>  static inline void crash_kexec(struct pt_regs *regs) { }
>  static inline int kexec_should_crash(struct task_struct *p) { return 0; }
>  #endif /* CONFIG_KEXEC */
> +
> +#endif /* !defined(__ASSEBMLY__) */
> +
>  #endif /* LINUX_KEXEC_H */
> -- 
> 1.9.1
> 
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH 4/5] kexec: Add IND_FLAGS macro
  2014-08-22 18:39 ` [PATCH 4/5] kexec: Add " Geoff Levand
@ 2014-08-25 17:54   ` Vivek Goyal
  0 siblings, 0 replies; 35+ messages in thread
From: Vivek Goyal @ 2014-08-25 17:54 UTC (permalink / raw)
  To: Geoff Levand
  Cc: Eric Biederman, Benjamin Herrenschmidt, Andrew Morton, kexec,
	linuxppc-dev, linux-kernel

On Fri, Aug 22, 2014 at 06:39:47PM +0000, Geoff Levand wrote:
> Add a new kexec preprocessor macro IND_FLAGS, which is the bitwise OR of
> all the possible kexec IND_ kimage_entry indirection flags.
> 
> Having this macro allows for simplified code in the prosessing of the
> kexec kimage_entry items.
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>

Acked-by: Vivek Goyal <vgoyal@redhat.com>

Vivek

> ---
>  include/linux/kexec.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
> index 8c628ca..a4758f9 100644
> --- a/include/linux/kexec.h
> +++ b/include/linux/kexec.h
> @@ -10,6 +10,7 @@
>  #define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
>  #define IND_DONE         (1 << IND_DONE_BIT)
>  #define IND_SOURCE       (1 << IND_SOURCE_BIT)
> +#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
>  
>  #if !defined(__ASSEMBLY__)
>  
> -- 
> 1.9.1
> 
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH 0/5] kexec: minor fixups and enhancements
  2014-08-25 16:59 ` [PATCH 0/5] kexec: minor fixups and enhancements Vivek Goyal
@ 2014-08-26  7:41   ` Dave Young
  2014-08-27  0:33   ` Geoff Levand
  1 sibling, 0 replies; 35+ messages in thread
From: Dave Young @ 2014-08-26  7:41 UTC (permalink / raw)
  To: Vivek Goyal
  Cc: Geoff Levand, Benjamin Herrenschmidt, kexec, linux-kernel,
	Eric Biederman, Andrew Morton, linuxppc-dev

On 08/25/14 at 12:59pm, Vivek Goyal wrote:
> On Fri, Aug 22, 2014 at 06:39:47PM +0000, Geoff Levand wrote:
> > Hi,
> > 
> > Here are a few minor fixups and enhancements for kexec support. 
> > 
> > Patch 3 and 4 that add preprocessor macros for the kimage list flags are
> > ones that I use in the arm64 kexec support I am working on, so it would
> > be nice for those to go in.
> > 
> > Please consider.
> 
> Hi Geoff,
> 
> Does arm64 has secureboot? If yes, then it might make sense to
> enable the new syscall kexec_file_load() on arm64 instead of trying
> to make old syscall work first.

It will save efforts for efi support as well, for the in-kernel loader we do not
necessary to save the efi physical addresses or runtime ranges to sysfs and
passing them to 2nd kernel, we can just copy them in kernel.

Thanks
Dave

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

* Re: [PATCH 0/5] kexec: minor fixups and enhancements
  2014-08-25 16:59 ` [PATCH 0/5] kexec: minor fixups and enhancements Vivek Goyal
  2014-08-26  7:41   ` Dave Young
@ 2014-08-27  0:33   ` Geoff Levand
  2014-08-27  0:42     ` Vivek Goyal
  1 sibling, 1 reply; 35+ messages in thread
From: Geoff Levand @ 2014-08-27  0:33 UTC (permalink / raw)
  To: Vivek Goyal
  Cc: Eric Biederman, Benjamin Herrenschmidt, Andrew Morton, kexec,
	linuxppc-dev, linux-kernel

Hi Vivek,

On Mon, 2014-08-25 at 12:59 -0400, Vivek Goyal wrote:
> Does arm64 has secureboot? If yes, then it might make sense to
> enable the new syscall kexec_file_load() on arm64 instead of trying
> to make old syscall work first.

Yes, arm64 should support secureboot, but I have not looked into it.

When do you expect syscall kexec_file_load to get merged?  I won't wait
until then to push my current kexec work.

-Geoff


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

* Re: [PATCH 0/5] kexec: minor fixups and enhancements
  2014-08-27  0:33   ` Geoff Levand
@ 2014-08-27  0:42     ` Vivek Goyal
  0 siblings, 0 replies; 35+ messages in thread
From: Vivek Goyal @ 2014-08-27  0:42 UTC (permalink / raw)
  To: Geoff Levand
  Cc: Eric Biederman, Benjamin Herrenschmidt, Andrew Morton, kexec,
	linuxppc-dev, linux-kernel

On Tue, Aug 26, 2014 at 05:33:28PM -0700, Geoff Levand wrote:
> Hi Vivek,
> 
> On Mon, 2014-08-25 at 12:59 -0400, Vivek Goyal wrote:
> > Does arm64 has secureboot? If yes, then it might make sense to
> > enable the new syscall kexec_file_load() on arm64 instead of trying
> > to make old syscall work first.
> 
> Yes, arm64 should support secureboot, but I have not looked into it.
> 
> When do you expect syscall kexec_file_load to get merged?  I won't wait
> until then to push my current kexec work.

It got merged in 3.17-rc1

Thanks
Vivek

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

* Re: [PATCH 1/5] kexec: Fix make headers_check
  2014-08-25 17:22   ` Vivek Goyal
@ 2014-08-30 12:47     ` Paul Bolle
  2014-10-06 14:12       ` Paul Bolle
  2014-10-06 17:44       ` H. Peter Anvin
  0 siblings, 2 replies; 35+ messages in thread
From: Paul Bolle @ 2014-08-30 12:47 UTC (permalink / raw)
  To: Vivek Goyal
  Cc: H. Peter Anvin, Geoff Levand, Eric Biederman,
	Benjamin Herrenschmidt, Andrew Morton, kexec, linuxppc-dev,
	linux-kernel, maximilian attems

[Added Peter Anvin.]

On Mon, 2014-08-25 at 13:22 -0400, Vivek Goyal wrote:
> On Fri, Aug 22, 2014 at 06:39:47PM +0000, Geoff Levand wrote:
> > Remove the unneded declaration for a kexec_load() routine.
> > 
> > Fixes errors like these when running 'make headers_check':
> > 
> > include/uapi/linux/kexec.h: userspace cannot reference function or variable defined in the kernel
> > 
> > Signed-off-by: Geoff Levand <geoff@infradead.org>
> 
> I think Paul Bolle tried to remove this in the past and maximilian
> had objections.
> 
> http://lists.infradead.org/pipermail/kexec/2014-January/010902.html

I've wanted to resend my patch, perhaps with a new commit explanation,
for quite some time now. I never got around doing that.

> I can't see that how exporting kernel prototype helps here.

It doesn't, for the reasons I've set out in
http://lists.infradead.org/pipermail/kexec/2014-January/010900.html . In
short: why bother using this prototype if one still needs to define the
matching function oneself?

> kexec-tools
> seems to be using syscall(__NR_kexec_load) directly for non-xen case. So
> I would be fine with removing this definition. Just trying to make sure
> that it does not break any other library or users of this declaration.

Obviously, this can only break compiling those libraries, or other
users. It can't break already compiled binaries. Besides I don't think
those libraries, etc actually exist. Maximilian mentioned klibc in
January, but I wasn't able to find a version of klibc that cared about
this prototype. No one pointed me at a version that does (or any other
library, etc., for that matter).

(If we do decide to keep this prototype, we should special case this
prototype in headers_check.pl just to silence the build.)

The above can be summarized like this:
    Acked-by: Paul Bolle <pebolle@tiscali.nl>


Paul Bolle


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

* Re: [PATCH 1/5] kexec: Fix make headers_check
  2014-08-30 12:47     ` Paul Bolle
@ 2014-10-06 14:12       ` Paul Bolle
  2014-10-06 17:34         ` Geoff Levand
  2014-10-06 17:44       ` H. Peter Anvin
  1 sibling, 1 reply; 35+ messages in thread
From: Paul Bolle @ 2014-10-06 14:12 UTC (permalink / raw)
  To: Geoff Levand
  Cc: Vivek Goyal, H. Peter Anvin, Eric Biederman,
	Benjamin Herrenschmidt, Andrew Morton, kexec, linuxppc-dev,
	linux-kernel, maximilian attems

Hi Geoff,

On Sat, 2014-08-30 at 14:47 +0200, Paul Bolle wrote:
> [Added Peter Anvin.]
> 
> On Mon, 2014-08-25 at 13:22 -0400, Vivek Goyal wrote:
> > On Fri, Aug 22, 2014 at 06:39:47PM +0000, Geoff Levand wrote:
> > > Remove the unneded declaration for a kexec_load() routine.
> > > 
> > > Fixes errors like these when running 'make headers_check':
> > > 
> > > include/uapi/linux/kexec.h: userspace cannot reference function or variable defined in the kernel
> > > 
> > > Signed-off-by: Geoff Levand <geoff@infradead.org>
> > 
> > I think Paul Bolle tried to remove this in the past and maximilian
> > had objections.
> > 
> > http://lists.infradead.org/pipermail/kexec/2014-January/010902.html
> 
> I've wanted to resend my patch, perhaps with a new commit explanation,
> for quite some time now. I never got around doing that.
> 
> > I can't see that how exporting kernel prototype helps here.
> 
> It doesn't, for the reasons I've set out in
> http://lists.infradead.org/pipermail/kexec/2014-January/010900.html . In
> short: why bother using this prototype if one still needs to define the
> matching function oneself?
> 
> > kexec-tools
> > seems to be using syscall(__NR_kexec_load) directly for non-xen case. So
> > I would be fine with removing this definition. Just trying to make sure
> > that it does not break any other library or users of this declaration.
> 
> Obviously, this can only break compiling those libraries, or other
> users. It can't break already compiled binaries. Besides I don't think
> those libraries, etc actually exist. Maximilian mentioned klibc in
> January, but I wasn't able to find a version of klibc that cared about
> this prototype. No one pointed me at a version that does (or any other
> library, etc., for that matter).
> 
> (If we do decide to keep this prototype, we should special case this
> prototype in headers_check.pl just to silence the build.)
> 
> The above can be summarized like this:
>     Acked-by: Paul Bolle <pebolle@tiscali.nl>

It seems not much happened after I added my Acked-by. I assume you still
want to get this merged. Is that correct?


Paul Bolle


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

* Re: [PATCH 1/5] kexec: Fix make headers_check
  2014-10-06 14:12       ` Paul Bolle
@ 2014-10-06 17:34         ` Geoff Levand
  2014-10-06 18:21           ` Paul Bolle
  0 siblings, 1 reply; 35+ messages in thread
From: Geoff Levand @ 2014-10-06 17:34 UTC (permalink / raw)
  To: Paul Bolle, Andrew Morton
  Cc: Vivek Goyal, H. Peter Anvin, Eric Biederman,
	Benjamin Herrenschmidt, Andrew Morton, kexec, linuxppc-dev,
	linux-kernel, maximilian attems

Hi,

On Mon, 2014-10-06 at 16:12 +0200, Paul Bolle wrote:
> On Sat, 2014-08-30 at 14:47 +0200, Paul Bolle wrote:
> > [Added Peter Anvin.]
> > 
> > On Mon, 2014-08-25 at 13:22 -0400, Vivek Goyal wrote:
> > > On Fri, Aug 22, 2014 at 06:39:47PM +0000, Geoff Levand wrote:
> > > > Remove the unneded declaration for a kexec_load() routine.
> > > > 
> > > > Fixes errors like these when running 'make headers_check':
> > > > 
> > > > include/uapi/linux/kexec.h: userspace cannot reference function or variable defined in the kernel
> > > > 
> > > > Signed-off-by: Geoff Levand <geoff@infradead.org>
> > > 
> > > I think Paul Bolle tried to remove this in the past and maximilian
> > > had objections.
> > > 
> > > http://lists.infradead.org/pipermail/kexec/2014-January/010902.html
> > 
> > I've wanted to resend my patch, perhaps with a new commit explanation,
> > for quite some time now. I never got around doing that.
> > 
> > > I can't see that how exporting kernel prototype helps here.
> > 
> > It doesn't, for the reasons I've set out in
> > http://lists.infradead.org/pipermail/kexec/2014-January/010900.html . In
> > short: why bother using this prototype if one still needs to define the
> > matching function oneself?
> > 
> > > kexec-tools
> > > seems to be using syscall(__NR_kexec_load) directly for non-xen case. So
> > > I would be fine with removing this definition. Just trying to make sure
> > > that it does not break any other library or users of this declaration.
> > 
> > Obviously, this can only break compiling those libraries, or other
> > users. It can't break already compiled binaries. Besides I don't think
> > those libraries, etc actually exist. Maximilian mentioned klibc in
> > January, but I wasn't able to find a version of klibc that cared about
> > this prototype. No one pointed me at a version that does (or any other
> > library, etc., for that matter).
> > 
> > (If we do decide to keep this prototype, we should special case this
> > prototype in headers_check.pl just to silence the build.)
> > 
> > The above can be summarized like this:
> >     Acked-by: Paul Bolle <pebolle@tiscali.nl>
> 
> It seems not much happened after I added my Acked-by. I assume you still
> want to get this merged. Is that correct?

Yes, I think we concluded there are no real users of this kexec_load()
ptototype, and so it can be removed.

-Geoff


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

* Re: [PATCH 1/5] kexec: Fix make headers_check
  2014-08-30 12:47     ` Paul Bolle
  2014-10-06 14:12       ` Paul Bolle
@ 2014-10-06 17:44       ` H. Peter Anvin
  1 sibling, 0 replies; 35+ messages in thread
From: H. Peter Anvin @ 2014-10-06 17:44 UTC (permalink / raw)
  To: Paul Bolle, Vivek Goyal
  Cc: Geoff Levand, Eric Biederman, Benjamin Herrenschmidt,
	Andrew Morton, kexec, linuxppc-dev, linux-kernel,
	maximilian attems

On 08/30/2014 05:47 AM, Paul Bolle wrote:
> 
> Obviously, this can only break compiling those libraries, or other
> users. It can't break already compiled binaries. Besides I don't think
> those libraries, etc actually exist. Maximilian mentioned klibc in
> January, but I wasn't able to find a version of klibc that cared about
> this prototype. No one pointed me at a version that does (or any other
> library, etc., for that matter).
> 

... and that would be a klibc bug and we'd just fix it.

	-hpa



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

* Re: [PATCH 1/5] kexec: Fix make headers_check
  2014-10-06 17:34         ` Geoff Levand
@ 2014-10-06 18:21           ` Paul Bolle
  2014-10-06 19:28             ` Geoff Levand
  0 siblings, 1 reply; 35+ messages in thread
From: Paul Bolle @ 2014-10-06 18:21 UTC (permalink / raw)
  To: Geoff Levand
  Cc: Andrew Morton, Vivek Goyal, H. Peter Anvin, Eric Biederman,
	Benjamin Herrenschmidt, kexec, linuxppc-dev, linux-kernel,
	maximilian attems

On Mon, 2014-10-06 at 10:34 -0700, Geoff Levand wrote:
> On Mon, 2014-10-06 at 16:12 +0200, Paul Bolle wrote:
> > It seems not much happened after I added my Acked-by. I assume you still
> > want to get this merged. Is that correct?
> 
> Yes, I think we concluded there are no real users of this kexec_load()
> ptototype, and so it can be removed.

What would be the quickest way to get this finally resolved? Who's in
charge of this stuff? Would resending your patch, with my Ack added,
speed up things? The vain side of my personality does think it would
help.


Paul Bolle


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

* Re: [PATCH 1/5] kexec: Fix make headers_check
  2014-10-06 18:21           ` Paul Bolle
@ 2014-10-06 19:28             ` Geoff Levand
  0 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-10-06 19:28 UTC (permalink / raw)
  To: Paul Bolle
  Cc: Andrew Morton, Vivek Goyal, H. Peter Anvin, Eric Biederman,
	Benjamin Herrenschmidt, kexec, linuxppc-dev, linux-kernel,
	maximilian attems

On Mon, 2014-10-06 at 20:21 +0200, Paul Bolle wrote:
> On Mon, 2014-10-06 at 10:34 -0700, Geoff Levand wrote:
> > On Mon, 2014-10-06 at 16:12 +0200, Paul Bolle wrote:
> > > It seems not much happened after I added my Acked-by. I assume you still
> > > want to get this merged. Is that correct?
> > 
> > Yes, I think we concluded there are no real users of this kexec_load()
> > ptototype, and so it can be removed.
> 
> What would be the quickest way to get this finally resolved? Who's in
> charge of this stuff? Would resending your patch, with my Ack added,
> speed up things? The vain side of my personality does think it would
> help.

I'll prepare a V2 set of the this series with the various acks and ask
Andrew to merge it.

-Geoff



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

* [PATCH V21/5] kexec: Fix make headers_check
  2014-10-07  0:21 ` [PATCH V2 0/5] kexec: Minor " Geoff Levand
  2014-10-07  0:21   ` [PATCH V25/5] powerpc/kexec: Use global IND_FLAGS macro Geoff Levand
  2014-10-07  0:21   ` [PATCH V22/5] kexec: Simplify conditional Geoff Levand
@ 2014-10-07  0:21   ` Geoff Levand
  2014-10-07  0:21   ` [PATCH V23/5] kexec: Add bit definitions for kimage entry flags Geoff Levand
  2014-10-07  0:21   ` [PATCH V24/5] kexec: Add IND_FLAGS macro Geoff Levand
  4 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-10-07  0:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Benjamin Herrenschmidt, linuxppc-dev,
	linux-kernel

Remove the unneded declaration for a kexec_load() routine.

Fixes errors like these when running 'make headers_check':

include/uapi/linux/kexec.h: userspace cannot reference function or variable defined in the kernel

Signed-off-by: Geoff Levand <geoff@infradead.org>
Acked-by: Paul Bolle <pebolle@tiscali.nl>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
---
 include/uapi/linux/kexec.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
index 6925f5b..99048e5 100644
--- a/include/uapi/linux/kexec.h
+++ b/include/uapi/linux/kexec.h
@@ -55,12 +55,6 @@ struct kexec_segment {
 	size_t memsz;
 };
 
-/* Load a new kernel image as described by the kexec_segment array
- * consisting of passed number of segments at the entry-point address.
- * The flags allow different useage types.
- */
-extern int kexec_load(void *, size_t, struct kexec_segment *,
-		unsigned long int);
 #endif /* __KERNEL__ */
 
 #endif /* _UAPILINUX_KEXEC_H */
-- 
1.9.1



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

* [PATCH V2 0/5] kexec: Minor fixups and enhancements
  2014-08-22 18:39 [PATCH 0/5] kexec: minor fixups and enhancements Geoff Levand
                   ` (5 preceding siblings ...)
  2014-08-25 16:59 ` [PATCH 0/5] kexec: minor fixups and enhancements Vivek Goyal
@ 2014-10-07  0:21 ` Geoff Levand
  2014-10-07  0:21   ` [PATCH V25/5] powerpc/kexec: Use global IND_FLAGS macro Geoff Levand
                     ` (4 more replies)
  2014-11-13  0:19 ` [PATCH V3 0/4] kexec: minor fixups and enhancements Geoff Levand
  7 siblings, 5 replies; 35+ messages in thread
From: Geoff Levand @ 2014-10-07  0:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Benjamin Herrenschmidt, linuxppc-dev,
	linux-kernel

Hi Andrew,

This series is basically a re-send of my kexec fix-up patches I sent out back
in August.  Everyone who commented seemed to think these changes were OK, but
there doesn't seem to be a kexec maintainer to pick these up.  Could you take
them through your mm tree?

Please let us know.

-Geoff

V2 changes:
	o Collected various Acked-by's.

The following changes since commit bfe01a5ba2490f299e1d2d5508cbbbadd897bbe9:

  Linux 3.17 (2014-10-05 12:23:04 -0700)

are available in the git repository at:

  git://git.linaro.org/people/geoff.levand/linux-kexec.git for-kexec

for you to fetch changes up to adf97d602657c72f6ee59aefe5d51149159a3e99:

  powerpc/kexec: Use global IND_FLAGS macro (2014-10-06 17:06:26 -0700)

----------------------------------------------------------------
Geoff Levand (5):
      kexec: Fix make headers_check
      kexec: Simplify conditional
      kexec: Add bit definitions for kimage entry flags
      kexec: Add IND_FLAGS macro
      powerpc/kexec: Use global IND_FLAGS macro

 arch/powerpc/kernel/machine_kexec_64.c |  2 --
 include/linux/kexec.h                  | 20 ++++++++++++++++----
 include/uapi/linux/kexec.h             |  6 ------
 kernel/kexec.c                         | 17 ++++++++++-------
 4 files changed, 26 insertions(+), 19 deletions(-)

-- 
1.9.1


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

* [PATCH V22/5] kexec: Simplify conditional
  2014-10-07  0:21 ` [PATCH V2 0/5] kexec: Minor " Geoff Levand
  2014-10-07  0:21   ` [PATCH V25/5] powerpc/kexec: Use global IND_FLAGS macro Geoff Levand
@ 2014-10-07  0:21   ` Geoff Levand
  2014-10-07  0:21   ` [PATCH V21/5] kexec: Fix make headers_check Geoff Levand
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-10-07  0:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Benjamin Herrenschmidt, linuxppc-dev,
	linux-kernel

Simplify the code around one of the conditionals in the kexec_load
syscall routine.

The original code was confusing with a redundant check on KEXEC_ON_CRASH
and comments outside of the conditional block.  This change switches the
order of the conditional check, and cleans up the comments for the
conditional.  There is no functional change to the code.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
---
 kernel/kexec.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/kernel/kexec.c b/kernel/kexec.c
index 2bee072..4b8356b 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1288,19 +1288,22 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
 	if (nr_segments > 0) {
 		unsigned long i;
 
-		/* Loading another kernel to reboot into */
-		if ((flags & KEXEC_ON_CRASH) == 0)
-			result = kimage_alloc_init(&image, entry, nr_segments,
-						   segments, flags);
-		/* Loading another kernel to switch to if this one crashes */
-		else if (flags & KEXEC_ON_CRASH) {
-			/* Free any current crash dump kernel before
+		if (flags & KEXEC_ON_CRASH) {
+			/*
+			 * Loading another kernel to switch to if this one
+			 * crashes.  Free any current crash dump kernel before
 			 * we corrupt it.
 			 */
+
 			kimage_free(xchg(&kexec_crash_image, NULL));
 			result = kimage_alloc_init(&image, entry, nr_segments,
 						   segments, flags);
 			crash_map_reserved_pages();
+		} else {
+			/* Loading another kernel to reboot into. */
+
+			result = kimage_alloc_init(&image, entry, nr_segments,
+						   segments, flags);
 		}
 		if (result)
 			goto out;
-- 
1.9.1



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

* [PATCH V23/5] kexec: Add bit definitions for kimage entry flags
  2014-10-07  0:21 ` [PATCH V2 0/5] kexec: Minor " Geoff Levand
                     ` (2 preceding siblings ...)
  2014-10-07  0:21   ` [PATCH V21/5] kexec: Fix make headers_check Geoff Levand
@ 2014-10-07  0:21   ` Geoff Levand
  2014-10-07  0:21   ` [PATCH V24/5] kexec: Add IND_FLAGS macro Geoff Levand
  4 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-10-07  0:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Benjamin Herrenschmidt, linuxppc-dev,
	linux-kernel

Define new kexec preprocessor macros IND_*_BIT that define the bit position of
the kimage entry flags.  Change the existing IND_* flag macros to be defined as
bit shifts of the corresponding IND_*_BIT macros.  Also wrap all C language code
in kexec.h with #if !defined(__ASSEMBLY__) so assembly files can include kexec.h
to get the IND_* and IND_*_BIT macros.

Some CPU instruction sets have tests for bit position which are convenient in
implementing routines that operate on the kimage entry list.  The addition of
these bit position macros in a common location will avoid duplicate definitions
and the chance that changes to the IND_* flags will not be propagated to
assembly files.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
---
 include/linux/kexec.h | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 4b2a0e1..8c628ca 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -1,6 +1,18 @@
 #ifndef LINUX_KEXEC_H
 #define LINUX_KEXEC_H
 
+#define IND_DESTINATION_BIT 0
+#define IND_INDIRECTION_BIT 1
+#define IND_DONE_BIT        2
+#define IND_SOURCE_BIT      3
+
+#define IND_DESTINATION  (1 << IND_DESTINATION_BIT)
+#define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
+#define IND_DONE         (1 << IND_DONE_BIT)
+#define IND_SOURCE       (1 << IND_SOURCE_BIT)
+
+#if !defined(__ASSEMBLY__)
+
 #include <uapi/linux/kexec.h>
 
 #ifdef CONFIG_KEXEC
@@ -64,10 +76,6 @@
  */
 
 typedef unsigned long kimage_entry_t;
-#define IND_DESTINATION  0x1
-#define IND_INDIRECTION  0x2
-#define IND_DONE         0x4
-#define IND_SOURCE       0x8
 
 struct kexec_segment {
 	/*
@@ -312,4 +320,7 @@ struct task_struct;
 static inline void crash_kexec(struct pt_regs *regs) { }
 static inline int kexec_should_crash(struct task_struct *p) { return 0; }
 #endif /* CONFIG_KEXEC */
+
+#endif /* !defined(__ASSEBMLY__) */
+
 #endif /* LINUX_KEXEC_H */
-- 
1.9.1



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

* [PATCH V24/5] kexec: Add IND_FLAGS macro
  2014-10-07  0:21 ` [PATCH V2 0/5] kexec: Minor " Geoff Levand
                     ` (3 preceding siblings ...)
  2014-10-07  0:21   ` [PATCH V23/5] kexec: Add bit definitions for kimage entry flags Geoff Levand
@ 2014-10-07  0:21   ` Geoff Levand
  2014-10-07 20:26     ` [PATCH V3 4/5] " Geoff Levand
  4 siblings, 1 reply; 35+ messages in thread
From: Geoff Levand @ 2014-10-07  0:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Benjamin Herrenschmidt, linuxppc-dev,
	linux-kernel

Add a new kexec preprocessor macro IND_FLAGS, which is the bitwise OR of
all the possible kexec IND_ kimage_entry indirection flags.

Having this macro allows for simplified code in the prosessing of the
kexec kimage_entry items.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
---
 include/linux/kexec.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 8c628ca..a4758f9 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -10,6 +10,7 @@
 #define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
 #define IND_DONE         (1 << IND_DONE_BIT)
 #define IND_SOURCE       (1 << IND_SOURCE_BIT)
+#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
 
 #if !defined(__ASSEMBLY__)
 
-- 
1.9.1



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

* [PATCH V25/5] powerpc/kexec: Use global IND_FLAGS macro
  2014-10-07  0:21 ` [PATCH V2 0/5] kexec: Minor " Geoff Levand
@ 2014-10-07  0:21   ` Geoff Levand
  2014-10-07 17:52     ` Vivek Goyal
  2014-10-07  0:21   ` [PATCH V22/5] kexec: Simplify conditional Geoff Levand
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 35+ messages in thread
From: Geoff Levand @ 2014-10-07  0:21 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Benjamin Herrenschmidt, linuxppc-dev,
	linux-kernel

linux/kexec.h now defines an IND_FLAGS macro.  Remove the local powerpc
definition and use the generic one.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 arch/powerpc/kernel/machine_kexec_64.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 879b3aa..75652a32 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -96,8 +96,6 @@ int default_machine_kexec_prepare(struct kimage *image)
 	return 0;
 }
 
-#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
-
 static void copy_segments(unsigned long ind)
 {
 	unsigned long entry;
-- 
1.9.1


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

* Re: [PATCH V25/5] powerpc/kexec: Use global IND_FLAGS macro
  2014-10-07  0:21   ` [PATCH V25/5] powerpc/kexec: Use global IND_FLAGS macro Geoff Levand
@ 2014-10-07 17:52     ` Vivek Goyal
  2014-11-12 19:29       ` [PATCH V3] kexec: Add " Geoff Levand
  0 siblings, 1 reply; 35+ messages in thread
From: Vivek Goyal @ 2014-10-07 17:52 UTC (permalink / raw)
  To: Geoff Levand
  Cc: Andrew Morton, Benjamin Herrenschmidt, linuxppc-dev, kexec,
	Eric Biederman, linux-kernel

On Tue, Oct 07, 2014 at 12:21:30AM +0000, Geoff Levand wrote:
> linux/kexec.h now defines an IND_FLAGS macro.  Remove the local powerpc
> definition and use the generic one.
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>

I think this patch should be merged in previous patch. I guess after
applying patch4, series might not be compilable as there are two
definitions of IND_FLAGS now.

Thanks
Vivek

> ---
>  arch/powerpc/kernel/machine_kexec_64.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
> index 879b3aa..75652a32 100644
> --- a/arch/powerpc/kernel/machine_kexec_64.c
> +++ b/arch/powerpc/kernel/machine_kexec_64.c
> @@ -96,8 +96,6 @@ int default_machine_kexec_prepare(struct kimage *image)
>  	return 0;
>  }
>  
> -#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
> -
>  static void copy_segments(unsigned long ind)
>  {
>  	unsigned long entry;
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH V3 4/5] kexec: Add IND_FLAGS macro
  2014-10-07  0:21   ` [PATCH V24/5] kexec: Add IND_FLAGS macro Geoff Levand
@ 2014-10-07 20:26     ` Geoff Levand
  0 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-10-07 20:26 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Benjamin Herrenschmidt, linuxppc-dev,
	linux-kernel

Add a new kexec preprocessor macro IND_FLAGS, which is the bitwise OR of
all the possible kexec IND_ kimage_entry indirection flags.  Having this
macro allows for simplified code in the prosessing of the kexec
kimage_entry items.  Also, remove the local powerpc definition and use
the generic one.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
---

>From V2: Folded patch 5 into patch 4.

 arch/powerpc/kernel/machine_kexec_64.c | 2 --
 include/linux/kexec.h                  | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 879b3aa..75652a32 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -96,8 +96,6 @@ int default_machine_kexec_prepare(struct kimage *image)
 	return 0;
 }
 
-#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
-
 static void copy_segments(unsigned long ind)
 {
 	unsigned long entry;
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 8c628ca..a4758f9 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -10,6 +10,7 @@
 #define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
 #define IND_DONE         (1 << IND_DONE_BIT)
 #define IND_SOURCE       (1 << IND_SOURCE_BIT)
+#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
 
 #if !defined(__ASSEMBLY__)
 
-- 
1.9.1




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

* [PATCH V3] kexec: Add IND_FLAGS macro
  2014-10-07 17:52     ` Vivek Goyal
@ 2014-11-12 19:29       ` Geoff Levand
  2014-11-12 23:06         ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 35+ messages in thread
From: Geoff Levand @ 2014-11-12 19:29 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: linuxppc-dev, kexec, Eric Biederman, linux-kernel, Vivek Goyal

Add a new kexec preprocessor macro IND_FLAGS, which is the bitwise OR of
all the possible kexec IND_ kimage_entry indirection flags.  Having this
macro allows for simplified code in the processing of the kexec
kimage_entry items.  Also, remove the local powerpc definition and use
the generic one.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
---
Hi Ben,

Could you give your ack on this, then I'll try to get it
merged with my other kexec patches.

Thanks.

-Geoff

 arch/powerpc/kernel/machine_kexec_64.c | 2 --
 include/linux/kexec.h                  | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 879b3aa..75652a32 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -96,8 +96,6 @@ int default_machine_kexec_prepare(struct kimage *image)
 	return 0;
 }
 
-#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
-
 static void copy_segments(unsigned long ind)
 {
 	unsigned long entry;
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 25e039c..b23412c 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -10,6 +10,7 @@
 #define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
 #define IND_DONE         (1 << IND_DONE_BIT)
 #define IND_SOURCE       (1 << IND_SOURCE_BIT)
+#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
 
 #if !defined(__ASSEMBLY__)
 
-- 
1.9.1




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

* Re: [PATCH V3] kexec: Add IND_FLAGS macro
  2014-11-12 19:29       ` [PATCH V3] kexec: Add " Geoff Levand
@ 2014-11-12 23:06         ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 35+ messages in thread
From: Benjamin Herrenschmidt @ 2014-11-12 23:06 UTC (permalink / raw)
  To: Geoff Levand
  Cc: linuxppc-dev, kexec, Eric Biederman, linux-kernel, Vivek Goyal

On Wed, 2014-11-12 at 11:29 -0800, Geoff Levand wrote:
> Add a new kexec preprocessor macro IND_FLAGS, which is the bitwise OR of
> all the possible kexec IND_ kimage_entry indirection flags.  Having this
> macro allows for simplified code in the processing of the kexec
> kimage_entry items.  Also, remove the local powerpc definition and use
> the generic one.
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Acked-by: Vivek Goyal <vgoyal@redhat.com>
> ---
> Hi Ben,
> 
> Could you give your ack on this, then I'll try to get it
> merged with my other kexec patches.
> 
> Thanks.
> 
> -Geoff
> 
>  arch/powerpc/kernel/machine_kexec_64.c | 2 --
>  include/linux/kexec.h                  | 1 +
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
> index 879b3aa..75652a32 100644
> --- a/arch/powerpc/kernel/machine_kexec_64.c
> +++ b/arch/powerpc/kernel/machine_kexec_64.c
> @@ -96,8 +96,6 @@ int default_machine_kexec_prepare(struct kimage *image)
>  	return 0;
>  }
>  
> -#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
> -
>  static void copy_segments(unsigned long ind)
>  {
>  	unsigned long entry;
> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
> index 25e039c..b23412c 100644
> --- a/include/linux/kexec.h
> +++ b/include/linux/kexec.h
> @@ -10,6 +10,7 @@
>  #define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
>  #define IND_DONE         (1 << IND_DONE_BIT)
>  #define IND_SOURCE       (1 << IND_SOURCE_BIT)
> +#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
>  
>  #if !defined(__ASSEMBLY__)
>  



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

* [PATCH V3 0/4] kexec: minor fixups and enhancements
  2014-08-22 18:39 [PATCH 0/5] kexec: minor fixups and enhancements Geoff Levand
                   ` (6 preceding siblings ...)
  2014-10-07  0:21 ` [PATCH V2 0/5] kexec: Minor " Geoff Levand
@ 2014-11-13  0:19 ` Geoff Levand
  2014-11-13  0:19   ` [PATCH V3 3/4] kexec: Add bit definitions for kimage entry flags Geoff Levand
                     ` (3 more replies)
  7 siblings, 4 replies; 35+ messages in thread
From: Geoff Levand @ 2014-11-13  0:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Vivek Goyal, linuxppc-dev, linux-kernel

Hi Andrew,

This is essentially a resend of my patch set from October with the exception
of folding the last two patches of that series into the final patch here.

The patches here have been in review since first posted in August, and have
been acked by one or two kexec developers.  Could you merge them through your
mm tree?  Thanks.

-Geoff


The following changes since commit 206c5f60a3d902bc4b56dab2de3e88de5eb06108:

  Linux 3.18-rc4 (2014-11-09 14:55:29 -0800)

are available in the git repository at:

  git://git.linaro.org/people/geoff.levand/linux-kexec.git for-kexec

for you to fetch changes up to 916ef4b8abaa4202ea43731b9cd3f8e0ea95f05b:

  kexec: Add IND_FLAGS macro (2014-11-12 15:27:54 -0800)

----------------------------------------------------------------
Geoff Levand (4):
      kexec: Fix make headers_check
      kexec: Simplify conditional
      kexec: Add bit definitions for kimage entry flags
      kexec: Add IND_FLAGS macro

 arch/powerpc/kernel/machine_kexec_64.c |  2 --
 include/linux/kexec.h                  | 20 ++++++++++++++++----
 include/uapi/linux/kexec.h             |  6 ------
 kernel/kexec.c                         | 17 ++++++++++-------
 4 files changed, 26 insertions(+), 19 deletions(-)

-- 
1.9.1


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

* [PATCH V3 4/4] kexec: Add IND_FLAGS macro
  2014-11-13  0:19 ` [PATCH V3 0/4] kexec: minor fixups and enhancements Geoff Levand
  2014-11-13  0:19   ` [PATCH V3 3/4] kexec: Add bit definitions for kimage entry flags Geoff Levand
@ 2014-11-13  0:19   ` Geoff Levand
  2014-11-13  0:19   ` [PATCH V3 2/4] kexec: Simplify conditional Geoff Levand
  2014-11-13  0:19   ` [PATCH V3 1/4] kexec: Fix make headers_check Geoff Levand
  3 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-11-13  0:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Benjamin Herrenschmidt, Vivek Goyal,
	linuxppc-dev, linux-kernel

Add a new kexec preprocessor macro IND_FLAGS, which is the bitwise OR of
all the possible kexec IND_ kimage_entry indirection flags.  Having this
macro allows for simplified code in the prosessing of the kexec
kimage_entry items.  Also, remove the local powerpc definition and use
the generic one.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
---
 arch/powerpc/kernel/machine_kexec_64.c | 2 --
 include/linux/kexec.h                  | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 879b3aa..75652a32 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -96,8 +96,6 @@ int default_machine_kexec_prepare(struct kimage *image)
 	return 0;
 }
 
-#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
-
 static void copy_segments(unsigned long ind)
 {
 	unsigned long entry;
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 25e039c..b23412c 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -10,6 +10,7 @@
 #define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
 #define IND_DONE         (1 << IND_DONE_BIT)
 #define IND_SOURCE       (1 << IND_SOURCE_BIT)
+#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
 
 #if !defined(__ASSEMBLY__)
 
-- 
1.9.1


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

* [PATCH V3 1/4] kexec: Fix make headers_check
  2014-11-13  0:19 ` [PATCH V3 0/4] kexec: minor fixups and enhancements Geoff Levand
                     ` (2 preceding siblings ...)
  2014-11-13  0:19   ` [PATCH V3 2/4] kexec: Simplify conditional Geoff Levand
@ 2014-11-13  0:19   ` Geoff Levand
  3 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-11-13  0:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Vivek Goyal, linuxppc-dev, linux-kernel

Remove the unneded declaration for a kexec_load() routine.

Fixes errors like these when running 'make headers_check':

include/uapi/linux/kexec.h: userspace cannot reference function or variable defined in the kernel

Signed-off-by: Geoff Levand <geoff@infradead.org>
Acked-by: Paul Bolle <pebolle@tiscali.nl>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
---
 include/uapi/linux/kexec.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
index 6925f5b..99048e5 100644
--- a/include/uapi/linux/kexec.h
+++ b/include/uapi/linux/kexec.h
@@ -55,12 +55,6 @@ struct kexec_segment {
 	size_t memsz;
 };
 
-/* Load a new kernel image as described by the kexec_segment array
- * consisting of passed number of segments at the entry-point address.
- * The flags allow different useage types.
- */
-extern int kexec_load(void *, size_t, struct kexec_segment *,
-		unsigned long int);
 #endif /* __KERNEL__ */
 
 #endif /* _UAPILINUX_KEXEC_H */
-- 
1.9.1



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

* [PATCH V3 2/4] kexec: Simplify conditional
  2014-11-13  0:19 ` [PATCH V3 0/4] kexec: minor fixups and enhancements Geoff Levand
  2014-11-13  0:19   ` [PATCH V3 3/4] kexec: Add bit definitions for kimage entry flags Geoff Levand
  2014-11-13  0:19   ` [PATCH V3 4/4] kexec: Add IND_FLAGS macro Geoff Levand
@ 2014-11-13  0:19   ` Geoff Levand
  2014-11-13  0:19   ` [PATCH V3 1/4] kexec: Fix make headers_check Geoff Levand
  3 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-11-13  0:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Vivek Goyal, linuxppc-dev, linux-kernel

Simplify the code around one of the conditionals in the kexec_load
syscall routine.

The original code was confusing with a redundant check on KEXEC_ON_CRASH
and comments outside of the conditional block.  This change switches the
order of the conditional check, and cleans up the comments for the
conditional.  There is no functional change to the code.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
---
 kernel/kexec.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/kernel/kexec.c b/kernel/kexec.c
index 2abf9f6..650fcba 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1288,19 +1288,22 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
 	if (nr_segments > 0) {
 		unsigned long i;
 
-		/* Loading another kernel to reboot into */
-		if ((flags & KEXEC_ON_CRASH) == 0)
-			result = kimage_alloc_init(&image, entry, nr_segments,
-						   segments, flags);
-		/* Loading another kernel to switch to if this one crashes */
-		else if (flags & KEXEC_ON_CRASH) {
-			/* Free any current crash dump kernel before
+		if (flags & KEXEC_ON_CRASH) {
+			/*
+			 * Loading another kernel to switch to if this one
+			 * crashes.  Free any current crash dump kernel before
 			 * we corrupt it.
 			 */
+
 			kimage_free(xchg(&kexec_crash_image, NULL));
 			result = kimage_alloc_init(&image, entry, nr_segments,
 						   segments, flags);
 			crash_map_reserved_pages();
+		} else {
+			/* Loading another kernel to reboot into. */
+
+			result = kimage_alloc_init(&image, entry, nr_segments,
+						   segments, flags);
 		}
 		if (result)
 			goto out;
-- 
1.9.1



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

* [PATCH V3 3/4] kexec: Add bit definitions for kimage entry flags
  2014-11-13  0:19 ` [PATCH V3 0/4] kexec: minor fixups and enhancements Geoff Levand
@ 2014-11-13  0:19   ` Geoff Levand
  2014-11-13  0:19   ` [PATCH V3 4/4] kexec: Add IND_FLAGS macro Geoff Levand
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 35+ messages in thread
From: Geoff Levand @ 2014-11-13  0:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Biederman, kexec, Vivek Goyal, linuxppc-dev, linux-kernel

Define new kexec preprocessor macros IND_*_BIT that define the bit position of
the kimage entry flags.  Change the existing IND_* flag macros to be defined as
bit shifts of the corresponding IND_*_BIT macros.  Also wrap all C language code
in kexec.h with #if !defined(__ASSEMBLY__) so assembly files can include kexec.h
to get the IND_* and IND_*_BIT macros.

Some CPU instruction sets have tests for bit position which are convenient in
implementing routines that operate on the kimage entry list.  The addition of
these bit position macros in a common location will avoid duplicate definitions
and the chance that changes to the IND_* flags will not be propagated to
assembly files.

Signed-off-by: Geoff Levand <geoff@infradead.org>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
---
 include/linux/kexec.h | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 9d957b7..25e039c 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -1,6 +1,18 @@
 #ifndef LINUX_KEXEC_H
 #define LINUX_KEXEC_H
 
+#define IND_DESTINATION_BIT 0
+#define IND_INDIRECTION_BIT 1
+#define IND_DONE_BIT        2
+#define IND_SOURCE_BIT      3
+
+#define IND_DESTINATION  (1 << IND_DESTINATION_BIT)
+#define IND_INDIRECTION  (1 << IND_INDIRECTION_BIT)
+#define IND_DONE         (1 << IND_DONE_BIT)
+#define IND_SOURCE       (1 << IND_SOURCE_BIT)
+
+#if !defined(__ASSEMBLY__)
+
 #include <uapi/linux/kexec.h>
 
 #ifdef CONFIG_KEXEC
@@ -64,10 +76,6 @@
  */
 
 typedef unsigned long kimage_entry_t;
-#define IND_DESTINATION  0x1
-#define IND_INDIRECTION  0x2
-#define IND_DONE         0x4
-#define IND_SOURCE       0x8
 
 struct kexec_segment {
 	/*
@@ -313,4 +321,7 @@ struct task_struct;
 static inline void crash_kexec(struct pt_regs *regs) { }
 static inline int kexec_should_crash(struct task_struct *p) { return 0; }
 #endif /* CONFIG_KEXEC */
+
+#endif /* !defined(__ASSEBMLY__) */
+
 #endif /* LINUX_KEXEC_H */
-- 
1.9.1



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

end of thread, other threads:[~2014-11-13  0:19 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-22 18:39 [PATCH 0/5] kexec: minor fixups and enhancements Geoff Levand
2014-08-22 18:39 ` [PATCH 3/5] kexec: Add bit definitions for kimage entry flags Geoff Levand
2014-08-25 17:52   ` Vivek Goyal
2014-08-22 18:39 ` [PATCH 1/5] kexec: Fix make headers_check Geoff Levand
2014-08-25 17:22   ` Vivek Goyal
2014-08-30 12:47     ` Paul Bolle
2014-10-06 14:12       ` Paul Bolle
2014-10-06 17:34         ` Geoff Levand
2014-10-06 18:21           ` Paul Bolle
2014-10-06 19:28             ` Geoff Levand
2014-10-06 17:44       ` H. Peter Anvin
2014-08-22 18:39 ` [PATCH 5/5] powerpc/kexec: Use global IND_FLAGS macro Geoff Levand
2014-08-22 18:39 ` [PATCH 4/5] kexec: Add " Geoff Levand
2014-08-25 17:54   ` Vivek Goyal
2014-08-22 18:39 ` [PATCH 2/5] kexec: Simplify conditional Geoff Levand
2014-08-25 17:42   ` Vivek Goyal
2014-08-25 16:59 ` [PATCH 0/5] kexec: minor fixups and enhancements Vivek Goyal
2014-08-26  7:41   ` Dave Young
2014-08-27  0:33   ` Geoff Levand
2014-08-27  0:42     ` Vivek Goyal
2014-10-07  0:21 ` [PATCH V2 0/5] kexec: Minor " Geoff Levand
2014-10-07  0:21   ` [PATCH V25/5] powerpc/kexec: Use global IND_FLAGS macro Geoff Levand
2014-10-07 17:52     ` Vivek Goyal
2014-11-12 19:29       ` [PATCH V3] kexec: Add " Geoff Levand
2014-11-12 23:06         ` Benjamin Herrenschmidt
2014-10-07  0:21   ` [PATCH V22/5] kexec: Simplify conditional Geoff Levand
2014-10-07  0:21   ` [PATCH V21/5] kexec: Fix make headers_check Geoff Levand
2014-10-07  0:21   ` [PATCH V23/5] kexec: Add bit definitions for kimage entry flags Geoff Levand
2014-10-07  0:21   ` [PATCH V24/5] kexec: Add IND_FLAGS macro Geoff Levand
2014-10-07 20:26     ` [PATCH V3 4/5] " Geoff Levand
2014-11-13  0:19 ` [PATCH V3 0/4] kexec: minor fixups and enhancements Geoff Levand
2014-11-13  0:19   ` [PATCH V3 3/4] kexec: Add bit definitions for kimage entry flags Geoff Levand
2014-11-13  0:19   ` [PATCH V3 4/4] kexec: Add IND_FLAGS macro Geoff Levand
2014-11-13  0:19   ` [PATCH V3 2/4] kexec: Simplify conditional Geoff Levand
2014-11-13  0:19   ` [PATCH V3 1/4] kexec: Fix make headers_check Geoff Levand

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).