2014-10-07 00:21:51

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V2 0/5] kexec: Minor fixups and enhancements

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


2014-10-07 00:21:52

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V21/5] kexec: Fix make headers_check

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 <[email protected]>
Acked-by: Paul Bolle <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Vivek Goyal <[email protected]>
---
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

2014-10-07 00:21:50

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V22/5] kexec: Simplify conditional

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 <[email protected]>
Acked-by: Vivek Goyal <[email protected]>
---
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

2014-10-07 00:22:43

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V23/5] kexec: Add bit definitions for kimage entry flags

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 <[email protected]>
Acked-by: Vivek Goyal <[email protected]>
---
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

2014-10-07 00:22:42

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V24/5] kexec: Add IND_FLAGS macro

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 <[email protected]>
Acked-by: Vivek Goyal <[email protected]>
---
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

2014-10-07 00:22:41

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V25/5] powerpc/kexec: Use global IND_FLAGS macro

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

Signed-off-by: Geoff Levand <[email protected]>
---
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

2014-10-07 17:53:44

by Vivek Goyal

[permalink] [raw]
Subject: Re: [PATCH V25/5] powerpc/kexec: Use global IND_FLAGS macro

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 <[email protected]>

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
> [email protected]
> http://lists.infradead.org/mailman/listinfo/kexec

2014-10-07 20:26:25

by Geoff Levand

[permalink] [raw]
Subject: Re: [PATCH V3 4/5] kexec: Add IND_FLAGS macro

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 <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Acked-by: Vivek Goyal <[email protected]>
---

>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


2014-11-12 19:29:57

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V3] kexec: Add IND_FLAGS macro

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 <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Acked-by: Vivek Goyal <[email protected]>
---
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


2014-11-12 23:07:30

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH V3] kexec: Add IND_FLAGS macro

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 <[email protected]>
Acked-by: Benjamin Herrenschmidt <[email protected]>
> Acked-by: Vivek Goyal <[email protected]>
> ---
> 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__)
>