2014-11-13 00:19:56

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V3 0/4] kexec: minor fixups and enhancements

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


2014-11-13 00:19:55

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V3 4/4] 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]>
Acked-by: Benjamin Herrenschmidt <[email protected]>
Acked-by: Vivek Goyal <[email protected]>
---
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-13 00:19:54

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V3 1/4] 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-11-13 00:19:53

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V3 2/4] 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 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

2014-11-13 00:19:52

by Geoff Levand

[permalink] [raw]
Subject: [PATCH V3 3/4] 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 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