All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] ppc64: Fix warnings
@ 2015-10-06 22:55 ` Scott Wood
  0 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-10-06 22:55 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec, linuxppc-dev, Michael Ellerman, Scott Wood

Produce a warning-free build on ppc64 (at least, when built as 64-bit
userspace -- if a 64-bit binary for ppc64 is a requirement, why is -m64
set only on purgatory?).  Mostly unused (or write-only) variable
warnings, but also one nasty one where reserve() was used without a
prototype, causing long long arguments to be passed as int.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2: no change

 kexec/arch/ppc64/crashdump-ppc64.c | 3 ++-
 kexec/arch/ppc64/kexec-elf-ppc64.c | 9 +--------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c
index 6214b83..b3c8928 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.c
+++ b/kexec/arch/ppc64/crashdump-ppc64.c
@@ -33,6 +33,7 @@
 #include "../../kexec-syscall.h"
 #include "../../crashdump.h"
 #include "kexec-ppc64.h"
+#include "../../fs2dt.h"
 #include "crashdump-ppc64.h"
 
 static struct crash_elf_info elf_info64 =
@@ -187,7 +188,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
 	DIR *dir, *dmem;
 	FILE *file;
 	struct dirent *dentry, *mentry;
-	int i, n, crash_rng_len = 0;
+	int n, crash_rng_len = 0;
 	unsigned long long start, end;
 	int page_size;
 
diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
index 4a1540e..adcee4c 100644
--- a/kexec/arch/ppc64/kexec-elf-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
@@ -97,7 +97,6 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 	struct mem_ehdr ehdr;
 	char *cmdline, *modified_cmdline = NULL;
 	const char *devicetreeblob;
-	int cmdline_len, modified_cmdline_len;
 	uint64_t max_addr, hole_addr;
 	char *seg_buf = NULL;
 	off_t seg_size = 0;
@@ -107,7 +106,6 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 	uint64_t *rsvmap_ptr;
 	struct bootblock *bb_ptr;
 #endif
-	int i;
 	int result, opt;
 	uint64_t my_kernel, my_dt_offset;
 	uint64_t my_opal_base = 0, my_opal_entry = 0;
@@ -162,10 +160,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 		}
 	}
 
-	cmdline_len = 0;
-	if (cmdline)
-		cmdline_len = strlen(cmdline) + 1;
-	else
+	if (!cmdline)
 		fprintf(stdout, "Warning: append= option is not passed. Using the first kernel root partition\n");
 
 	if (ramdisk && reuse_initrd)
@@ -181,7 +176,6 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 			strncpy(modified_cmdline, cmdline, COMMAND_LINE_SIZE);
 			modified_cmdline[COMMAND_LINE_SIZE - 1] = '\0';
 		}
-		modified_cmdline_len = strlen(modified_cmdline);
 	}
 
 	/* Parse the Elf file */
@@ -219,7 +213,6 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 			return -1;
 		/* Use new command line. */
 		cmdline = modified_cmdline;
-		cmdline_len = strlen(modified_cmdline) + 1;
 	}
 
 	/* Add v2wrap to the current image */
-- 
2.1.4

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

* [PATCH v2 1/3] ppc64: Fix warnings
@ 2015-10-06 22:55 ` Scott Wood
  0 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-10-06 22:55 UTC (permalink / raw)
  To: Simon Horman; +Cc: Scott Wood, linuxppc-dev, kexec, Michael Ellerman

Produce a warning-free build on ppc64 (at least, when built as 64-bit
userspace -- if a 64-bit binary for ppc64 is a requirement, why is -m64
set only on purgatory?).  Mostly unused (or write-only) variable
warnings, but also one nasty one where reserve() was used without a
prototype, causing long long arguments to be passed as int.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2: no change

 kexec/arch/ppc64/crashdump-ppc64.c | 3 ++-
 kexec/arch/ppc64/kexec-elf-ppc64.c | 9 +--------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c
index 6214b83..b3c8928 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.c
+++ b/kexec/arch/ppc64/crashdump-ppc64.c
@@ -33,6 +33,7 @@
 #include "../../kexec-syscall.h"
 #include "../../crashdump.h"
 #include "kexec-ppc64.h"
+#include "../../fs2dt.h"
 #include "crashdump-ppc64.h"
 
 static struct crash_elf_info elf_info64 =
@@ -187,7 +188,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
 	DIR *dir, *dmem;
 	FILE *file;
 	struct dirent *dentry, *mentry;
-	int i, n, crash_rng_len = 0;
+	int n, crash_rng_len = 0;
 	unsigned long long start, end;
 	int page_size;
 
diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
index 4a1540e..adcee4c 100644
--- a/kexec/arch/ppc64/kexec-elf-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
@@ -97,7 +97,6 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 	struct mem_ehdr ehdr;
 	char *cmdline, *modified_cmdline = NULL;
 	const char *devicetreeblob;
-	int cmdline_len, modified_cmdline_len;
 	uint64_t max_addr, hole_addr;
 	char *seg_buf = NULL;
 	off_t seg_size = 0;
@@ -107,7 +106,6 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 	uint64_t *rsvmap_ptr;
 	struct bootblock *bb_ptr;
 #endif
-	int i;
 	int result, opt;
 	uint64_t my_kernel, my_dt_offset;
 	uint64_t my_opal_base = 0, my_opal_entry = 0;
@@ -162,10 +160,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 		}
 	}
 
-	cmdline_len = 0;
-	if (cmdline)
-		cmdline_len = strlen(cmdline) + 1;
-	else
+	if (!cmdline)
 		fprintf(stdout, "Warning: append= option is not passed. Using the first kernel root partition\n");
 
 	if (ramdisk && reuse_initrd)
@@ -181,7 +176,6 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 			strncpy(modified_cmdline, cmdline, COMMAND_LINE_SIZE);
 			modified_cmdline[COMMAND_LINE_SIZE - 1] = '\0';
 		}
-		modified_cmdline_len = strlen(modified_cmdline);
 	}
 
 	/* Parse the Elf file */
@@ -219,7 +213,6 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 			return -1;
 		/* Use new command line. */
 		cmdline = modified_cmdline;
-		cmdline_len = strlen(modified_cmdline) + 1;
 	}
 
 	/* Add v2wrap to the current image */
-- 
2.1.4


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

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

* [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
  2015-10-06 22:55 ` Scott Wood
@ 2015-10-06 22:55   ` Scott Wood
  -1 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-10-06 22:55 UTC (permalink / raw)
  To: Simon Horman
  Cc: kexec, linuxppc-dev, Michael Ellerman, Scott Wood, Samuel Mendoza-Jonas

Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
fatal exception on book3e.

Purgatory is an isolated environment which makes importing information
about the subarch awkward, so instead rely on the fact that MSR_LE
should never be set on book3e, and the rfid is only needed if MSR_LE is
set (and thus needs to be cleared).  In theory that MSR bit is reserved
on book3e, rather than zero, but in practice I have not seen it set.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
---
v2: new patch

 purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
index 179ade9..3534080 100644
--- a/purgatory/arch/ppc64/v2wrap.S
+++ b/purgatory/arch/ppc64/v2wrap.S
@@ -116,9 +116,17 @@ master:
 	stw	7,0x5c(4)	# and patch it into the kernel
 	mr      3,16            # restore dt address
 
+	mfmsr	5
+	andi.	10,5,1		# test MSR_LE
+	bne	little_endian
+
+	li	5,0		# r5 will be 0 for kernel
+	mtctr	4		# prepare branch to
+	bctr			# start kernel
+	
+little_endian:			# book3s-only
 	mtsrr0	4		# prepare branch to
 
-	mfmsr	5
 	clrrdi	5,5,1		# clear MSR_LE
 	mtsrr1	5
 
-- 
2.1.4

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

* [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
@ 2015-10-06 22:55   ` Scott Wood
  0 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-10-06 22:55 UTC (permalink / raw)
  To: Simon Horman
  Cc: Scott Wood, linuxppc-dev, kexec, Samuel Mendoza-Jonas, Michael Ellerman

Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
fatal exception on book3e.

Purgatory is an isolated environment which makes importing information
about the subarch awkward, so instead rely on the fact that MSR_LE
should never be set on book3e, and the rfid is only needed if MSR_LE is
set (and thus needs to be cleared).  In theory that MSR bit is reserved
on book3e, rather than zero, but in practice I have not seen it set.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
---
v2: new patch

 purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
index 179ade9..3534080 100644
--- a/purgatory/arch/ppc64/v2wrap.S
+++ b/purgatory/arch/ppc64/v2wrap.S
@@ -116,9 +116,17 @@ master:
 	stw	7,0x5c(4)	# and patch it into the kernel
 	mr      3,16            # restore dt address
 
+	mfmsr	5
+	andi.	10,5,1		# test MSR_LE
+	bne	little_endian
+
+	li	5,0		# r5 will be 0 for kernel
+	mtctr	4		# prepare branch to
+	bctr			# start kernel
+	
+little_endian:			# book3s-only
 	mtsrr0	4		# prepare branch to
 
-	mfmsr	5
 	clrrdi	5,5,1		# clear MSR_LE
 	mtsrr1	5
 
-- 
2.1.4


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

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

* [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
  2015-10-06 22:55 ` Scott Wood
@ 2015-10-06 22:55   ` Scott Wood
  -1 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-10-06 22:55 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec, linuxppc-dev, Michael Ellerman, Scott Wood

It needs to know this because the SMP release mechanism for Freescale
book3e is different from when booting with normal hardware.  In theory
we could simulate the normal spin table mechanism, but not (easily) at
the addresses U-Boot put in the device tree -- so there'd need to be
even more communication between the kernel and kexec to set that up.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2: Use a device tree property rather than setting a flag in the kernel
image, as requested by Michael Ellerman.
---
 kexec/arch/ppc64/Makefile           |  6 +++
 kexec/arch/ppc64/fdt.c              | 78 +++++++++++++++++++++++++++++++++++++
 kexec/arch/ppc64/include/arch/fdt.h |  9 +++++
 kexec/arch/ppc64/kexec-elf-ppc64.c  |  7 ++++
 4 files changed, 100 insertions(+)
 create mode 100644 kexec/arch/ppc64/fdt.c
 create mode 100644 kexec/arch/ppc64/include/arch/fdt.h

diff --git a/kexec/arch/ppc64/Makefile b/kexec/arch/ppc64/Makefile
index 9a6e475..37cd233 100644
--- a/kexec/arch/ppc64/Makefile
+++ b/kexec/arch/ppc64/Makefile
@@ -1,11 +1,15 @@
 #
 # kexec ppc64 (linux booting linux)
 #
+include $(srcdir)/kexec/libfdt/Makefile.libfdt
+
 ppc64_KEXEC_SRCS =  kexec/arch/ppc64/kexec-elf-rel-ppc64.c
 ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-zImage-ppc64.c
 ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-elf-ppc64.c
 ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-ppc64.c
 ppc64_KEXEC_SRCS += kexec/arch/ppc64/crashdump-ppc64.c
+ppc64_KEXEC_SRCS += kexec/arch/ppc64/fdt.c
+ppc64_KEXEC_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
 
 ppc64_ARCH_REUSE_INITRD =
 
@@ -13,6 +17,8 @@ ppc64_FS2DT	    = kexec/fs2dt.c
 ppc64_FS2DT_INCLUDE = -include $(srcdir)/kexec/arch/ppc64/crashdump-ppc64.h \
                       -include $(srcdir)/kexec/arch/ppc64/kexec-ppc64.h
 
+ppc64_CPPFLAGS = -I$(srcdir)/kexec/libfdt
+
 dist += kexec/arch/ppc64/Makefile $(ppc64_KEXEC_SRCS)			\
 	kexec/arch/ppc64/kexec-ppc64.h kexec/arch/ppc64/crashdump-ppc64.h \
 	kexec/arch/ppc64/include/arch/options.h
diff --git a/kexec/arch/ppc64/fdt.c b/kexec/arch/ppc64/fdt.c
new file mode 100644
index 0000000..8bc6d2d
--- /dev/null
+++ b/kexec/arch/ppc64/fdt.c
@@ -0,0 +1,78 @@
+/*
+ * ppc64 fdt fixups
+ *
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation (version 2 of the License).
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/fdt.h>
+#include <libfdt.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+ * Let the kernel know it booted from kexec, as some things (e.g.
+ * secondary CPU release) may work differently.
+ */
+static int fixup_kexec_prop(void *fdt)
+{
+	int err, nodeoffset;
+
+	nodeoffset = fdt_subnode_offset(fdt, 0, "chosen");
+	if (nodeoffset < 0)
+		nodeoffset = fdt_add_subnode(fdt, 0, "chosen");
+	if (nodeoffset < 0) {
+		printf("%s: add /chosen %s\n", __func__,
+		       fdt_strerror(nodeoffset));
+		return -1;
+	}
+
+	err = fdt_setprop(fdt, nodeoffset, "linux,booted-from-kexec",
+			  NULL, 0);
+	if (err < 0) {
+		printf("%s: couldn't write linux,booted-from-kexec: %s\n",
+		       __func__, fdt_strerror(err));
+		return -1;
+	}
+
+	return 0;
+}
+
+
+/*
+ * For now, assume that the added content fits in the file.
+ * This should be the case when flattening from /proc/device-tree,
+ * and when passing in a dtb, dtc can be told to add padding.
+ */
+int fixup_dt(char **fdt, off_t *size)
+{
+	int ret;
+
+	*size += 4096;
+	*fdt = realloc(*fdt, *size);
+	if (!*fdt) {
+		fprintf(stderr, "%s: out of memory\n", __func__);
+		return -1;
+	}
+
+	ret = fdt_open_into(*fdt, *fdt, *size);
+	if (ret < 0) {
+		fprintf(stderr, "%s: fdt_open_into: %s\n", __func__,
+			fdt_strerror(ret));
+		return -1;
+	}
+
+	ret = fixup_kexec_prop(*fdt);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
diff --git a/kexec/arch/ppc64/include/arch/fdt.h b/kexec/arch/ppc64/include/arch/fdt.h
new file mode 100644
index 0000000..14f8be2
--- /dev/null
+++ b/kexec/arch/ppc64/include/arch/fdt.h
@@ -0,0 +1,9 @@
+#ifndef KEXEC_ARCH_PPC64_FDT
+#define KEXEC_ARCH_PPC64_FDT
+
+#include <sys/types.h>
+
+int fixup_dt(char **fdt, off_t *size);
+
+#endif
+
diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
index adcee4c..ddd3de8 100644
--- a/kexec/arch/ppc64/kexec-elf-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
@@ -37,6 +37,8 @@
 #include "kexec-ppc64.h"
 #include "../../fs2dt.h"
 #include "crashdump-ppc64.h"
+#include <libfdt.h>
+#include <arch/fdt.h>
 #include <arch/options.h>
 
 uint64_t initrd_base, initrd_size;
@@ -242,6 +244,11 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 		/* create from fs2dt */
 		create_flatten_tree(&seg_buf, &seg_size, cmdline);
 	}
+
+	result = fixup_dt(&seg_buf, &seg_size);
+	if (result < 0)
+		return result;
+
 	my_dt_offset = add_buffer(info, seg_buf, seg_size, seg_size,
 				0, 0, max_addr, -1);
 
-- 
2.1.4

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

* [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
@ 2015-10-06 22:55   ` Scott Wood
  0 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-10-06 22:55 UTC (permalink / raw)
  To: Simon Horman; +Cc: Scott Wood, linuxppc-dev, kexec, Michael Ellerman

It needs to know this because the SMP release mechanism for Freescale
book3e is different from when booting with normal hardware.  In theory
we could simulate the normal spin table mechanism, but not (easily) at
the addresses U-Boot put in the device tree -- so there'd need to be
even more communication between the kernel and kexec to set that up.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
v2: Use a device tree property rather than setting a flag in the kernel
image, as requested by Michael Ellerman.
---
 kexec/arch/ppc64/Makefile           |  6 +++
 kexec/arch/ppc64/fdt.c              | 78 +++++++++++++++++++++++++++++++++++++
 kexec/arch/ppc64/include/arch/fdt.h |  9 +++++
 kexec/arch/ppc64/kexec-elf-ppc64.c  |  7 ++++
 4 files changed, 100 insertions(+)
 create mode 100644 kexec/arch/ppc64/fdt.c
 create mode 100644 kexec/arch/ppc64/include/arch/fdt.h

diff --git a/kexec/arch/ppc64/Makefile b/kexec/arch/ppc64/Makefile
index 9a6e475..37cd233 100644
--- a/kexec/arch/ppc64/Makefile
+++ b/kexec/arch/ppc64/Makefile
@@ -1,11 +1,15 @@
 #
 # kexec ppc64 (linux booting linux)
 #
+include $(srcdir)/kexec/libfdt/Makefile.libfdt
+
 ppc64_KEXEC_SRCS =  kexec/arch/ppc64/kexec-elf-rel-ppc64.c
 ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-zImage-ppc64.c
 ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-elf-ppc64.c
 ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-ppc64.c
 ppc64_KEXEC_SRCS += kexec/arch/ppc64/crashdump-ppc64.c
+ppc64_KEXEC_SRCS += kexec/arch/ppc64/fdt.c
+ppc64_KEXEC_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
 
 ppc64_ARCH_REUSE_INITRD =
 
@@ -13,6 +17,8 @@ ppc64_FS2DT	    = kexec/fs2dt.c
 ppc64_FS2DT_INCLUDE = -include $(srcdir)/kexec/arch/ppc64/crashdump-ppc64.h \
                       -include $(srcdir)/kexec/arch/ppc64/kexec-ppc64.h
 
+ppc64_CPPFLAGS = -I$(srcdir)/kexec/libfdt
+
 dist += kexec/arch/ppc64/Makefile $(ppc64_KEXEC_SRCS)			\
 	kexec/arch/ppc64/kexec-ppc64.h kexec/arch/ppc64/crashdump-ppc64.h \
 	kexec/arch/ppc64/include/arch/options.h
diff --git a/kexec/arch/ppc64/fdt.c b/kexec/arch/ppc64/fdt.c
new file mode 100644
index 0000000..8bc6d2d
--- /dev/null
+++ b/kexec/arch/ppc64/fdt.c
@@ -0,0 +1,78 @@
+/*
+ * ppc64 fdt fixups
+ *
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation (version 2 of the License).
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/fdt.h>
+#include <libfdt.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+ * Let the kernel know it booted from kexec, as some things (e.g.
+ * secondary CPU release) may work differently.
+ */
+static int fixup_kexec_prop(void *fdt)
+{
+	int err, nodeoffset;
+
+	nodeoffset = fdt_subnode_offset(fdt, 0, "chosen");
+	if (nodeoffset < 0)
+		nodeoffset = fdt_add_subnode(fdt, 0, "chosen");
+	if (nodeoffset < 0) {
+		printf("%s: add /chosen %s\n", __func__,
+		       fdt_strerror(nodeoffset));
+		return -1;
+	}
+
+	err = fdt_setprop(fdt, nodeoffset, "linux,booted-from-kexec",
+			  NULL, 0);
+	if (err < 0) {
+		printf("%s: couldn't write linux,booted-from-kexec: %s\n",
+		       __func__, fdt_strerror(err));
+		return -1;
+	}
+
+	return 0;
+}
+
+
+/*
+ * For now, assume that the added content fits in the file.
+ * This should be the case when flattening from /proc/device-tree,
+ * and when passing in a dtb, dtc can be told to add padding.
+ */
+int fixup_dt(char **fdt, off_t *size)
+{
+	int ret;
+
+	*size += 4096;
+	*fdt = realloc(*fdt, *size);
+	if (!*fdt) {
+		fprintf(stderr, "%s: out of memory\n", __func__);
+		return -1;
+	}
+
+	ret = fdt_open_into(*fdt, *fdt, *size);
+	if (ret < 0) {
+		fprintf(stderr, "%s: fdt_open_into: %s\n", __func__,
+			fdt_strerror(ret));
+		return -1;
+	}
+
+	ret = fixup_kexec_prop(*fdt);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
diff --git a/kexec/arch/ppc64/include/arch/fdt.h b/kexec/arch/ppc64/include/arch/fdt.h
new file mode 100644
index 0000000..14f8be2
--- /dev/null
+++ b/kexec/arch/ppc64/include/arch/fdt.h
@@ -0,0 +1,9 @@
+#ifndef KEXEC_ARCH_PPC64_FDT
+#define KEXEC_ARCH_PPC64_FDT
+
+#include <sys/types.h>
+
+int fixup_dt(char **fdt, off_t *size);
+
+#endif
+
diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
index adcee4c..ddd3de8 100644
--- a/kexec/arch/ppc64/kexec-elf-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
@@ -37,6 +37,8 @@
 #include "kexec-ppc64.h"
 #include "../../fs2dt.h"
 #include "crashdump-ppc64.h"
+#include <libfdt.h>
+#include <arch/fdt.h>
 #include <arch/options.h>
 
 uint64_t initrd_base, initrd_size;
@@ -242,6 +244,11 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 		/* create from fs2dt */
 		create_flatten_tree(&seg_buf, &seg_size, cmdline);
 	}
+
+	result = fixup_dt(&seg_buf, &seg_size);
+	if (result < 0)
+		return result;
+
 	my_dt_offset = add_buffer(info, seg_buf, seg_size, seg_size,
 				0, 0, max_addr, -1);
 
-- 
2.1.4


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

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

* Re: [PATCH v2 1/3] ppc64: Fix warnings
  2015-10-06 22:55 ` Scott Wood
@ 2015-10-16  1:47   ` Simon Horman
  -1 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-10-16  1:47 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, kexec, Michael Ellerman

On Tue, Oct 06, 2015 at 05:55:48PM -0500, Scott Wood wrote:
> Produce a warning-free build on ppc64 (at least, when built as 64-bit
> userspace -- if a 64-bit binary for ppc64 is a requirement, why is -m64
> set only on purgatory?).  Mostly unused (or write-only) variable
> warnings, but also one nasty one where reserve() was used without a
> prototype, causing long long arguments to be passed as int.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>

Thanks, applied.

I would have slightly preferred one-patch per problem.

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

* Re: [PATCH v2 1/3] ppc64: Fix warnings
@ 2015-10-16  1:47   ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-10-16  1:47 UTC (permalink / raw)
  To: Scott Wood; +Cc: kexec, linuxppc-dev, Michael Ellerman

On Tue, Oct 06, 2015 at 05:55:48PM -0500, Scott Wood wrote:
> Produce a warning-free build on ppc64 (at least, when built as 64-bit
> userspace -- if a 64-bit binary for ppc64 is a requirement, why is -m64
> set only on purgatory?).  Mostly unused (or write-only) variable
> warnings, but also one nasty one where reserve() was used without a
> prototype, causing long long arguments to be passed as int.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>

Thanks, applied.

I would have slightly preferred one-patch per problem.

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

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
  2015-10-06 22:55   ` Scott Wood
@ 2015-10-16  1:48     ` Simon Horman
  -1 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-10-16  1:48 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, kexec, Samuel Mendoza-Jonas, Michael Ellerman

On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> fatal exception on book3e.
> 
> Purgatory is an isolated environment which makes importing information
> about the subarch awkward, so instead rely on the fact that MSR_LE
> should never be set on book3e, and the rfid is only needed if MSR_LE is
> set (and thus needs to be cleared).  In theory that MSR bit is reserved
> on book3e, rather than zero, but in practice I have not seen it set.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> ---
> v2: new patch

Could I get a review of this from at lest one ppc person?

>  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> index 179ade9..3534080 100644
> --- a/purgatory/arch/ppc64/v2wrap.S
> +++ b/purgatory/arch/ppc64/v2wrap.S
> @@ -116,9 +116,17 @@ master:
>  	stw	7,0x5c(4)	# and patch it into the kernel
>  	mr      3,16            # restore dt address
>  
> +	mfmsr	5
> +	andi.	10,5,1		# test MSR_LE
> +	bne	little_endian
> +
> +	li	5,0		# r5 will be 0 for kernel
> +	mtctr	4		# prepare branch to
> +	bctr			# start kernel
> +	
> +little_endian:			# book3s-only
>  	mtsrr0	4		# prepare branch to
>  
> -	mfmsr	5
>  	clrrdi	5,5,1		# clear MSR_LE
>  	mtsrr1	5
>  
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
@ 2015-10-16  1:48     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-10-16  1:48 UTC (permalink / raw)
  To: Scott Wood; +Cc: kexec, linuxppc-dev, Samuel Mendoza-Jonas, Michael Ellerman

On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> fatal exception on book3e.
> 
> Purgatory is an isolated environment which makes importing information
> about the subarch awkward, so instead rely on the fact that MSR_LE
> should never be set on book3e, and the rfid is only needed if MSR_LE is
> set (and thus needs to be cleared).  In theory that MSR bit is reserved
> on book3e, rather than zero, but in practice I have not seen it set.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> ---
> v2: new patch

Could I get a review of this from at lest one ppc person?

>  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> index 179ade9..3534080 100644
> --- a/purgatory/arch/ppc64/v2wrap.S
> +++ b/purgatory/arch/ppc64/v2wrap.S
> @@ -116,9 +116,17 @@ master:
>  	stw	7,0x5c(4)	# and patch it into the kernel
>  	mr      3,16            # restore dt address
>  
> +	mfmsr	5
> +	andi.	10,5,1		# test MSR_LE
> +	bne	little_endian
> +
> +	li	5,0		# r5 will be 0 for kernel
> +	mtctr	4		# prepare branch to
> +	bctr			# start kernel
> +	
> +little_endian:			# book3s-only
>  	mtsrr0	4		# prepare branch to
>  
> -	mfmsr	5
>  	clrrdi	5,5,1		# clear MSR_LE
>  	mtsrr1	5
>  
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 

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

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

* Re: [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
  2015-10-06 22:55   ` Scott Wood
@ 2015-10-16  1:48     ` Simon Horman
  -1 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-10-16  1:48 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, kexec, Michael Ellerman

On Tue, Oct 06, 2015 at 05:55:50PM -0500, Scott Wood wrote:
> It needs to know this because the SMP release mechanism for Freescale
> book3e is different from when booting with normal hardware.  In theory
> we could simulate the normal spin table mechanism, but not (easily) at
> the addresses U-Boot put in the device tree -- so there'd need to be
> even more communication between the kernel and kexec to set that up.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
> v2: Use a device tree property rather than setting a flag in the kernel
> image, as requested by Michael Ellerman.

I'd value a review of this from someone more familiar with ppc than I.

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

* Re: [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
@ 2015-10-16  1:48     ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-10-16  1:48 UTC (permalink / raw)
  To: Scott Wood; +Cc: kexec, linuxppc-dev, Michael Ellerman

On Tue, Oct 06, 2015 at 05:55:50PM -0500, Scott Wood wrote:
> It needs to know this because the SMP release mechanism for Freescale
> book3e is different from when booting with normal hardware.  In theory
> we could simulate the normal spin table mechanism, but not (easily) at
> the addresses U-Boot put in the device tree -- so there'd need to be
> even more communication between the kernel and kexec to set that up.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
> v2: Use a device tree property rather than setting a flag in the kernel
> image, as requested by Michael Ellerman.

I'd value a review of this from someone more familiar with ppc than I.

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

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
  2015-10-16  1:48     ` Simon Horman
@ 2015-10-30  0:16       ` Scott Wood
  -1 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-10-30  0:16 UTC (permalink / raw)
  To: Simon Horman; +Cc: linuxppc-dev, kexec, Samuel Mendoza-Jonas, Michael Ellerman

On Fri, 2015-10-16 at 10:48 +0900, Simon Horman wrote:
> On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> > Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> > big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> > fatal exception on book3e.
> > 
> > Purgatory is an isolated environment which makes importing information
> > about the subarch awkward, so instead rely on the fact that MSR_LE
> > should never be set on book3e, and the rfid is only needed if MSR_LE is
> > set (and thus needs to be cleared).  In theory that MSR bit is reserved
> > on book3e, rather than zero, but in practice I have not seen it set.
> > 
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> > ---
> > v2: new patch
> 
> Could I get a review of this from at lest one ppc person?

Michael, can you comment on this as well as patch 3/3?

-Scott

> 
> >  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> > index 179ade9..3534080 100644
> > --- a/purgatory/arch/ppc64/v2wrap.S
> > +++ b/purgatory/arch/ppc64/v2wrap.S
> > @@ -116,9 +116,17 @@ master:
> >     stw     7,0x5c(4)       # and patch it into the kernel
> >     mr      3,16            # restore dt address
> >  
> > +   mfmsr   5
> > +   andi.   10,5,1          # test MSR_LE
> > +   bne     little_endian
> > +
> > +   li      5,0             # r5 will be 0 for kernel
> > +   mtctr   4               # prepare branch to
> > +   bctr                    # start kernel
> > +   
> > +little_endian:                     # book3s-only
> >     mtsrr0  4               # prepare branch to
> >  
> > -   mfmsr   5
> >     clrrdi  5,5,1           # clear MSR_LE
> >     mtsrr1  5
> >  

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
@ 2015-10-30  0:16       ` Scott Wood
  0 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-10-30  0:16 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec, linuxppc-dev, Samuel Mendoza-Jonas, Michael Ellerman

On Fri, 2015-10-16 at 10:48 +0900, Simon Horman wrote:
> On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> > Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> > big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> > fatal exception on book3e.
> > 
> > Purgatory is an isolated environment which makes importing information
> > about the subarch awkward, so instead rely on the fact that MSR_LE
> > should never be set on book3e, and the rfid is only needed if MSR_LE is
> > set (and thus needs to be cleared).  In theory that MSR bit is reserved
> > on book3e, rather than zero, but in practice I have not seen it set.
> > 
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> > ---
> > v2: new patch
> 
> Could I get a review of this from at lest one ppc person?

Michael, can you comment on this as well as patch 3/3?

-Scott

> 
> >  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> > index 179ade9..3534080 100644
> > --- a/purgatory/arch/ppc64/v2wrap.S
> > +++ b/purgatory/arch/ppc64/v2wrap.S
> > @@ -116,9 +116,17 @@ master:
> >     stw     7,0x5c(4)       # and patch it into the kernel
> >     mr      3,16            # restore dt address
> >  
> > +   mfmsr   5
> > +   andi.   10,5,1          # test MSR_LE
> > +   bne     little_endian
> > +
> > +   li      5,0             # r5 will be 0 for kernel
> > +   mtctr   4               # prepare branch to
> > +   bctr                    # start kernel
> > +   
> > +little_endian:                     # book3s-only
> >     mtsrr0  4               # prepare branch to
> >  
> > -   mfmsr   5
> >     clrrdi  5,5,1           # clear MSR_LE
> >     mtsrr1  5
> >  

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

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
  2015-10-06 22:55   ` Scott Wood
@ 2015-11-01 22:55     ` Sam Mendoza-Jonas
  -1 siblings, 0 replies; 26+ messages in thread
From: Sam Mendoza-Jonas @ 2015-11-01 22:55 UTC (permalink / raw)
  To: Scott Wood; +Cc: Simon Horman, kexec, linuxppc-dev, Michael Ellerman

On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> fatal exception on book3e.
> 
> Purgatory is an isolated environment which makes importing information
> about the subarch awkward, so instead rely on the fact that MSR_LE
> should never be set on book3e, and the rfid is only needed if MSR_LE is
> set (and thus needs to be cleared).  In theory that MSR bit is reserved
> on book3e, rather than zero, but in practice I have not seen it set.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> ---
> v2: new patch

Looks good to me, thanks for catching this!
I'll ping Michael too if you'd like his reviewed-by.

Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

> 
>  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> index 179ade9..3534080 100644
> --- a/purgatory/arch/ppc64/v2wrap.S
> +++ b/purgatory/arch/ppc64/v2wrap.S
> @@ -116,9 +116,17 @@ master:
>  	stw	7,0x5c(4)	# and patch it into the kernel
>  	mr      3,16            # restore dt address
>  
> +	mfmsr	5
> +	andi.	10,5,1		# test MSR_LE
> +	bne	little_endian
> +
> +	li	5,0		# r5 will be 0 for kernel
> +	mtctr	4		# prepare branch to
> +	bctr			# start kernel
> +	
> +little_endian:			# book3s-only
>  	mtsrr0	4		# prepare branch to
>  
> -	mfmsr	5
>  	clrrdi	5,5,1		# clear MSR_LE
>  	mtsrr1	5
>  
> -- 
> 2.1.4

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
@ 2015-11-01 22:55     ` Sam Mendoza-Jonas
  0 siblings, 0 replies; 26+ messages in thread
From: Sam Mendoza-Jonas @ 2015-11-01 22:55 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, Simon Horman, kexec, Michael Ellerman

On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> fatal exception on book3e.
> 
> Purgatory is an isolated environment which makes importing information
> about the subarch awkward, so instead rely on the fact that MSR_LE
> should never be set on book3e, and the rfid is only needed if MSR_LE is
> set (and thus needs to be cleared).  In theory that MSR bit is reserved
> on book3e, rather than zero, but in practice I have not seen it set.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> ---
> v2: new patch

Looks good to me, thanks for catching this!
I'll ping Michael too if you'd like his reviewed-by.

Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

> 
>  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> index 179ade9..3534080 100644
> --- a/purgatory/arch/ppc64/v2wrap.S
> +++ b/purgatory/arch/ppc64/v2wrap.S
> @@ -116,9 +116,17 @@ master:
>  	stw	7,0x5c(4)	# and patch it into the kernel
>  	mr      3,16            # restore dt address
>  
> +	mfmsr	5
> +	andi.	10,5,1		# test MSR_LE
> +	bne	little_endian
> +
> +	li	5,0		# r5 will be 0 for kernel
> +	mtctr	4		# prepare branch to
> +	bctr			# start kernel
> +	
> +little_endian:			# book3s-only
>  	mtsrr0	4		# prepare branch to
>  
> -	mfmsr	5
>  	clrrdi	5,5,1		# clear MSR_LE
>  	mtsrr1	5
>  
> -- 
> 2.1.4


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

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
  2015-11-01 22:55     ` Sam Mendoza-Jonas
@ 2015-11-02  0:21       ` Sam Mendoza-Jonas
  -1 siblings, 0 replies; 26+ messages in thread
From: Sam Mendoza-Jonas @ 2015-11-02  0:21 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, Simon Horman, kexec

On Mon, Nov 02, 2015 at 09:55:53AM +1100, Sam Mendoza-Jonas wrote:
> On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> > Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> > big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> > fatal exception on book3e.
> > 
> > Purgatory is an isolated environment which makes importing information
> > about the subarch awkward, so instead rely on the fact that MSR_LE
> > should never be set on book3e, and the rfid is only needed if MSR_LE is
> > set (and thus needs to be cleared).  In theory that MSR bit is reserved
> > on book3e, rather than zero, but in practice I have not seen it set.
> > 
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> > ---
> > v2: new patch
> 
> Looks good to me, thanks for catching this!
> I'll ping Michael too if you'd like his reviewed-by.
> 
> Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

Following up, also add my

Tested-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

> 
> > 
> >  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> > index 179ade9..3534080 100644
> > --- a/purgatory/arch/ppc64/v2wrap.S
> > +++ b/purgatory/arch/ppc64/v2wrap.S
> > @@ -116,9 +116,17 @@ master:
> >  	stw	7,0x5c(4)	# and patch it into the kernel
> >  	mr      3,16            # restore dt address
> >  
> > +	mfmsr	5
> > +	andi.	10,5,1		# test MSR_LE
> > +	bne	little_endian
> > +
> > +	li	5,0		# r5 will be 0 for kernel
> > +	mtctr	4		# prepare branch to
> > +	bctr			# start kernel
> > +	
> > +little_endian:			# book3s-only
> >  	mtsrr0	4		# prepare branch to
> >  
> > -	mfmsr	5
> >  	clrrdi	5,5,1		# clear MSR_LE
> >  	mtsrr1	5
> >  
> > -- 
> > 2.1.4
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
@ 2015-11-02  0:21       ` Sam Mendoza-Jonas
  0 siblings, 0 replies; 26+ messages in thread
From: Sam Mendoza-Jonas @ 2015-11-02  0:21 UTC (permalink / raw)
  To: Scott Wood; +Cc: kexec, Simon Horman, linuxppc-dev

On Mon, Nov 02, 2015 at 09:55:53AM +1100, Sam Mendoza-Jonas wrote:
> On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> > Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> > big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> > fatal exception on book3e.
> > 
> > Purgatory is an isolated environment which makes importing information
> > about the subarch awkward, so instead rely on the fact that MSR_LE
> > should never be set on book3e, and the rfid is only needed if MSR_LE is
> > set (and thus needs to be cleared).  In theory that MSR bit is reserved
> > on book3e, rather than zero, but in practice I have not seen it set.
> > 
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> > ---
> > v2: new patch
> 
> Looks good to me, thanks for catching this!
> I'll ping Michael too if you'd like his reviewed-by.
> 
> Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

Following up, also add my

Tested-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

> 
> > 
> >  purgatory/arch/ppc64/v2wrap.S | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> > index 179ade9..3534080 100644
> > --- a/purgatory/arch/ppc64/v2wrap.S
> > +++ b/purgatory/arch/ppc64/v2wrap.S
> > @@ -116,9 +116,17 @@ master:
> >  	stw	7,0x5c(4)	# and patch it into the kernel
> >  	mr      3,16            # restore dt address
> >  
> > +	mfmsr	5
> > +	andi.	10,5,1		# test MSR_LE
> > +	bne	little_endian
> > +
> > +	li	5,0		# r5 will be 0 for kernel
> > +	mtctr	4		# prepare branch to
> > +	bctr			# start kernel
> > +	
> > +little_endian:			# book3s-only
> >  	mtsrr0	4		# prepare branch to
> >  
> > -	mfmsr	5
> >  	clrrdi	5,5,1		# clear MSR_LE
> >  	mtsrr1	5
> >  
> > -- 
> > 2.1.4
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev


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

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
  2015-11-02  0:21       ` Sam Mendoza-Jonas
@ 2015-11-02  2:06         ` Simon Horman
  -1 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-11-02  2:06 UTC (permalink / raw)
  To: Sam Mendoza-Jonas; +Cc: Scott Wood, linuxppc-dev, kexec

On Mon, Nov 02, 2015 at 11:21:43AM +1100, Sam Mendoza-Jonas wrote:
> On Mon, Nov 02, 2015 at 09:55:53AM +1100, Sam Mendoza-Jonas wrote:
> > On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> > > Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> > > big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> > > fatal exception on book3e.
> > > 
> > > Purgatory is an isolated environment which makes importing information
> > > about the subarch awkward, so instead rely on the fact that MSR_LE
> > > should never be set on book3e, and the rfid is only needed if MSR_LE is
> > > set (and thus needs to be cleared).  In theory that MSR bit is reserved
> > > on book3e, rather than zero, but in practice I have not seen it set.
> > > 
> > > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > > Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> > > ---
> > > v2: new patch
> > 
> > Looks good to me, thanks for catching this!
> > I'll ping Michael too if you'd like his reviewed-by.
> > 
> > Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> 
> Following up, also add my
> 
> Tested-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

Thanks, I have queued this up for v2.0.11.

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

* Re: [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE
@ 2015-11-02  2:06         ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-11-02  2:06 UTC (permalink / raw)
  To: Sam Mendoza-Jonas; +Cc: Scott Wood, kexec, linuxppc-dev

On Mon, Nov 02, 2015 at 11:21:43AM +1100, Sam Mendoza-Jonas wrote:
> On Mon, Nov 02, 2015 at 09:55:53AM +1100, Sam Mendoza-Jonas wrote:
> > On Tue, Oct 06, 2015 at 05:55:49PM -0500, Scott Wood wrote:
> > > Commit a304e2d82a8c3 ("ppc64: purgatory: Reset primary cpu endian to
> > > big-endian) changed bctr to rfid.  rfid is book3s-only and will cause a
> > > fatal exception on book3e.
> > > 
> > > Purgatory is an isolated environment which makes importing information
> > > about the subarch awkward, so instead rely on the fact that MSR_LE
> > > should never be set on book3e, and the rfid is only needed if MSR_LE is
> > > set (and thus needs to be cleared).  In theory that MSR bit is reserved
> > > on book3e, rather than zero, but in practice I have not seen it set.
> > > 
> > > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > > Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> > > ---
> > > v2: new patch
> > 
> > Looks good to me, thanks for catching this!
> > I'll ping Michael too if you'd like his reviewed-by.
> > 
> > Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
> 
> Following up, also add my
> 
> Tested-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>

Thanks, I have queued this up for v2.0.11.

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

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

* Re: [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
  2015-10-06 22:55   ` Scott Wood
@ 2015-12-07 20:42     ` Scott Wood
  -1 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-12-07 20:42 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec, linuxppc-dev, Michael Ellerman

On Tue, 2015-10-06 at 17:55 -0500, Scott Wood wrote:
> It needs to know this because the SMP release mechanism for Freescale
> book3e is different from when booting with normal hardware.  In theory
> we could simulate the normal spin table mechanism, but not (easily) at
> the addresses U-Boot put in the device tree -- so there'd need to be
> even more communication between the kernel and kexec to set that up.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
> v2: Use a device tree property rather than setting a flag in the kernel
> image, as requested by Michael Ellerman.

ping?

Michael, can you review this?  Simon is waiting for another PPC person to
review it.

-Scott

> ---
>  kexec/arch/ppc64/Makefile           |  6 +++
>  kexec/arch/ppc64/fdt.c              | 78
> +++++++++++++++++++++++++++++++++++++
>  kexec/arch/ppc64/include/arch/fdt.h |  9 +++++
>  kexec/arch/ppc64/kexec-elf-ppc64.c  |  7 ++++
>  4 files changed, 100 insertions(+)
>  create mode 100644 kexec/arch/ppc64/fdt.c
>  create mode 100644 kexec/arch/ppc64/include/arch/fdt.h
> 
> diff --git a/kexec/arch/ppc64/Makefile b/kexec/arch/ppc64/Makefile
> index 9a6e475..37cd233 100644
> --- a/kexec/arch/ppc64/Makefile
> +++ b/kexec/arch/ppc64/Makefile
> @@ -1,11 +1,15 @@
>  #
>  # kexec ppc64 (linux booting linux)
>  #
> +include $(srcdir)/kexec/libfdt/Makefile.libfdt
> +
>  ppc64_KEXEC_SRCS =  kexec/arch/ppc64/kexec-elf-rel-ppc64.c
>  ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-zImage-ppc64.c
>  ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-elf-ppc64.c
>  ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-ppc64.c
>  ppc64_KEXEC_SRCS += kexec/arch/ppc64/crashdump-ppc64.c
> +ppc64_KEXEC_SRCS += kexec/arch/ppc64/fdt.c
> +ppc64_KEXEC_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
>  
>  ppc64_ARCH_REUSE_INITRD =
>  
> @@ -13,6 +17,8 @@ ppc64_FS2DT	    = kexec/fs2dt.c
>  ppc64_FS2DT_INCLUDE = -include $(srcdir)/kexec/arch/ppc64/crashdump-ppc64.h
> \
>                        -include $(srcdir)/kexec/arch/ppc64/kexec-ppc64.h
>  
> +ppc64_CPPFLAGS = -I$(srcdir)/kexec/libfdt
> +
>  dist += kexec/arch/ppc64/Makefile $(ppc64_KEXEC_SRCS)			
> \
>  	kexec/arch/ppc64/kexec-ppc64.h kexec/arch/ppc64/crashdump-ppc64.h \
>  	kexec/arch/ppc64/include/arch/options.h
> diff --git a/kexec/arch/ppc64/fdt.c b/kexec/arch/ppc64/fdt.c
> new file mode 100644
> index 0000000..8bc6d2d
> --- /dev/null
> +++ b/kexec/arch/ppc64/fdt.c
> @@ -0,0 +1,78 @@
> +/*
> + * ppc64 fdt fixups
> + *
> + * Copyright 2015 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation (version 2 of the License).
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <arch/fdt.h>
> +#include <libfdt.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +/*
> + * Let the kernel know it booted from kexec, as some things (e.g.
> + * secondary CPU release) may work differently.
> + */
> +static int fixup_kexec_prop(void *fdt)
> +{
> +	int err, nodeoffset;
> +
> +	nodeoffset = fdt_subnode_offset(fdt, 0, "chosen");
> +	if (nodeoffset < 0)
> +		nodeoffset = fdt_add_subnode(fdt, 0, "chosen");
> +	if (nodeoffset < 0) {
> +		printf("%s: add /chosen %s\n", __func__,
> +		       fdt_strerror(nodeoffset));
> +		return -1;
> +	}
> +
> +	err = fdt_setprop(fdt, nodeoffset, "linux,booted-from-kexec",
> +			  NULL, 0);
> +	if (err < 0) {
> +		printf("%s: couldn't write linux,booted-from-kexec: %s\n",
> +		       __func__, fdt_strerror(err));
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +
> +/*
> + * For now, assume that the added content fits in the file.
> + * This should be the case when flattening from /proc/device-tree,
> + * and when passing in a dtb, dtc can be told to add padding.
> + */
> +int fixup_dt(char **fdt, off_t *size)
> +{
> +	int ret;
> +
> +	*size += 4096;
> +	*fdt = realloc(*fdt, *size);
> +	if (!*fdt) {
> +		fprintf(stderr, "%s: out of memory\n", __func__);
> +		return -1;
> +	}
> +
> +	ret = fdt_open_into(*fdt, *fdt, *size);
> +	if (ret < 0) {
> +		fprintf(stderr, "%s: fdt_open_into: %s\n", __func__,
> +			fdt_strerror(ret));
> +		return -1;
> +	}
> +
> +	ret = fixup_kexec_prop(*fdt);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> diff --git a/kexec/arch/ppc64/include/arch/fdt.h
> b/kexec/arch/ppc64/include/arch/fdt.h
> new file mode 100644
> index 0000000..14f8be2
> --- /dev/null
> +++ b/kexec/arch/ppc64/include/arch/fdt.h
> @@ -0,0 +1,9 @@
> +#ifndef KEXEC_ARCH_PPC64_FDT
> +#define KEXEC_ARCH_PPC64_FDT
> +
> +#include <sys/types.h>
> +
> +int fixup_dt(char **fdt, off_t *size);
> +
> +#endif
> +
> diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf
> -ppc64.c
> index adcee4c..ddd3de8 100644
> --- a/kexec/arch/ppc64/kexec-elf-ppc64.c
> +++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
> @@ -37,6 +37,8 @@
>  #include "kexec-ppc64.h"
>  #include "../../fs2dt.h"
>  #include "crashdump-ppc64.h"
> +#include <libfdt.h>
> +#include <arch/fdt.h>
>  #include <arch/options.h>
>  
>  uint64_t initrd_base, initrd_size;
> @@ -242,6 +244,11 @@ int elf_ppc64_load(int argc, char **argv, const char
> *buf, off_t len,
>  		/* create from fs2dt */
>  		create_flatten_tree(&seg_buf, &seg_size, cmdline);
>  	}
> +
> +	result = fixup_dt(&seg_buf, &seg_size);
> +	if (result < 0)
> +		return result;
> +
>  	my_dt_offset = add_buffer(info, seg_buf, seg_size, seg_size,
>  				0, 0, max_addr, -1);
>  

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

* Re: [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
@ 2015-12-07 20:42     ` Scott Wood
  0 siblings, 0 replies; 26+ messages in thread
From: Scott Wood @ 2015-12-07 20:42 UTC (permalink / raw)
  To: Simon Horman; +Cc: linuxppc-dev, kexec, Michael Ellerman

On Tue, 2015-10-06 at 17:55 -0500, Scott Wood wrote:
> It needs to know this because the SMP release mechanism for Freescale
> book3e is different from when booting with normal hardware.  In theory
> we could simulate the normal spin table mechanism, but not (easily) at
> the addresses U-Boot put in the device tree -- so there'd need to be
> even more communication between the kernel and kexec to set that up.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
> v2: Use a device tree property rather than setting a flag in the kernel
> image, as requested by Michael Ellerman.

ping?

Michael, can you review this?  Simon is waiting for another PPC person to
review it.

-Scott

> ---
>  kexec/arch/ppc64/Makefile           |  6 +++
>  kexec/arch/ppc64/fdt.c              | 78
> +++++++++++++++++++++++++++++++++++++
>  kexec/arch/ppc64/include/arch/fdt.h |  9 +++++
>  kexec/arch/ppc64/kexec-elf-ppc64.c  |  7 ++++
>  4 files changed, 100 insertions(+)
>  create mode 100644 kexec/arch/ppc64/fdt.c
>  create mode 100644 kexec/arch/ppc64/include/arch/fdt.h
> 
> diff --git a/kexec/arch/ppc64/Makefile b/kexec/arch/ppc64/Makefile
> index 9a6e475..37cd233 100644
> --- a/kexec/arch/ppc64/Makefile
> +++ b/kexec/arch/ppc64/Makefile
> @@ -1,11 +1,15 @@
>  #
>  # kexec ppc64 (linux booting linux)
>  #
> +include $(srcdir)/kexec/libfdt/Makefile.libfdt
> +
>  ppc64_KEXEC_SRCS =  kexec/arch/ppc64/kexec-elf-rel-ppc64.c
>  ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-zImage-ppc64.c
>  ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-elf-ppc64.c
>  ppc64_KEXEC_SRCS += kexec/arch/ppc64/kexec-ppc64.c
>  ppc64_KEXEC_SRCS += kexec/arch/ppc64/crashdump-ppc64.c
> +ppc64_KEXEC_SRCS += kexec/arch/ppc64/fdt.c
> +ppc64_KEXEC_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%)
>  
>  ppc64_ARCH_REUSE_INITRD =
>  
> @@ -13,6 +17,8 @@ ppc64_FS2DT	    = kexec/fs2dt.c
>  ppc64_FS2DT_INCLUDE = -include $(srcdir)/kexec/arch/ppc64/crashdump-ppc64.h
> \
>                        -include $(srcdir)/kexec/arch/ppc64/kexec-ppc64.h
>  
> +ppc64_CPPFLAGS = -I$(srcdir)/kexec/libfdt
> +
>  dist += kexec/arch/ppc64/Makefile $(ppc64_KEXEC_SRCS)			
> \
>  	kexec/arch/ppc64/kexec-ppc64.h kexec/arch/ppc64/crashdump-ppc64.h \
>  	kexec/arch/ppc64/include/arch/options.h
> diff --git a/kexec/arch/ppc64/fdt.c b/kexec/arch/ppc64/fdt.c
> new file mode 100644
> index 0000000..8bc6d2d
> --- /dev/null
> +++ b/kexec/arch/ppc64/fdt.c
> @@ -0,0 +1,78 @@
> +/*
> + * ppc64 fdt fixups
> + *
> + * Copyright 2015 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation (version 2 of the License).
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <arch/fdt.h>
> +#include <libfdt.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +/*
> + * Let the kernel know it booted from kexec, as some things (e.g.
> + * secondary CPU release) may work differently.
> + */
> +static int fixup_kexec_prop(void *fdt)
> +{
> +	int err, nodeoffset;
> +
> +	nodeoffset = fdt_subnode_offset(fdt, 0, "chosen");
> +	if (nodeoffset < 0)
> +		nodeoffset = fdt_add_subnode(fdt, 0, "chosen");
> +	if (nodeoffset < 0) {
> +		printf("%s: add /chosen %s\n", __func__,
> +		       fdt_strerror(nodeoffset));
> +		return -1;
> +	}
> +
> +	err = fdt_setprop(fdt, nodeoffset, "linux,booted-from-kexec",
> +			  NULL, 0);
> +	if (err < 0) {
> +		printf("%s: couldn't write linux,booted-from-kexec: %s\n",
> +		       __func__, fdt_strerror(err));
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +
> +/*
> + * For now, assume that the added content fits in the file.
> + * This should be the case when flattening from /proc/device-tree,
> + * and when passing in a dtb, dtc can be told to add padding.
> + */
> +int fixup_dt(char **fdt, off_t *size)
> +{
> +	int ret;
> +
> +	*size += 4096;
> +	*fdt = realloc(*fdt, *size);
> +	if (!*fdt) {
> +		fprintf(stderr, "%s: out of memory\n", __func__);
> +		return -1;
> +	}
> +
> +	ret = fdt_open_into(*fdt, *fdt, *size);
> +	if (ret < 0) {
> +		fprintf(stderr, "%s: fdt_open_into: %s\n", __func__,
> +			fdt_strerror(ret));
> +		return -1;
> +	}
> +
> +	ret = fixup_kexec_prop(*fdt);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> diff --git a/kexec/arch/ppc64/include/arch/fdt.h
> b/kexec/arch/ppc64/include/arch/fdt.h
> new file mode 100644
> index 0000000..14f8be2
> --- /dev/null
> +++ b/kexec/arch/ppc64/include/arch/fdt.h
> @@ -0,0 +1,9 @@
> +#ifndef KEXEC_ARCH_PPC64_FDT
> +#define KEXEC_ARCH_PPC64_FDT
> +
> +#include <sys/types.h>
> +
> +int fixup_dt(char **fdt, off_t *size);
> +
> +#endif
> +
> diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf
> -ppc64.c
> index adcee4c..ddd3de8 100644
> --- a/kexec/arch/ppc64/kexec-elf-ppc64.c
> +++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
> @@ -37,6 +37,8 @@
>  #include "kexec-ppc64.h"
>  #include "../../fs2dt.h"
>  #include "crashdump-ppc64.h"
> +#include <libfdt.h>
> +#include <arch/fdt.h>
>  #include <arch/options.h>
>  
>  uint64_t initrd_base, initrd_size;
> @@ -242,6 +244,11 @@ int elf_ppc64_load(int argc, char **argv, const char
> *buf, off_t len,
>  		/* create from fs2dt */
>  		create_flatten_tree(&seg_buf, &seg_size, cmdline);
>  	}
> +
> +	result = fixup_dt(&seg_buf, &seg_size);
> +	if (result < 0)
> +		return result;
> +
>  	my_dt_offset = add_buffer(info, seg_buf, seg_size, seg_size,
>  				0, 0, max_addr, -1);
>  

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

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

* Re: [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
  2015-12-07 20:42     ` Scott Wood
@ 2015-12-08  3:46       ` Michael Ellerman
  -1 siblings, 0 replies; 26+ messages in thread
From: Michael Ellerman @ 2015-12-08  3:46 UTC (permalink / raw)
  To: Scott Wood, Simon Horman; +Cc: kexec, linuxppc-dev

On Mon, 2015-12-07 at 14:42 -0600, Scott Wood wrote:
> On Tue, 2015-10-06 at 17:55 -0500, Scott Wood wrote:
> > It needs to know this because the SMP release mechanism for Freescale
> > book3e is different from when booting with normal hardware.  In theory
> > we could simulate the normal spin table mechanism, but not (easily) at
> > the addresses U-Boot put in the device tree -- so there'd need to be
> > even more communication between the kernel and kexec to set that up.
> > 
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > ---
> > v2: Use a device tree property rather than setting a flag in the kernel
> > image, as requested by Michael Ellerman.
> 
> ping?
> 
> Michael, can you review this?  Simon is waiting for another PPC person to
> review it.

Oh sorry I thought it'd been merged already, but I see now only 1 & 2 went in.

Horms this looks fine to me:

Acked-by: Michael Ellerman <mpe@ellerman.id.au>

cheers

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

* Re: [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
@ 2015-12-08  3:46       ` Michael Ellerman
  0 siblings, 0 replies; 26+ messages in thread
From: Michael Ellerman @ 2015-12-08  3:46 UTC (permalink / raw)
  To: Scott Wood, Simon Horman; +Cc: linuxppc-dev, kexec

On Mon, 2015-12-07 at 14:42 -0600, Scott Wood wrote:
> On Tue, 2015-10-06 at 17:55 -0500, Scott Wood wrote:
> > It needs to know this because the SMP release mechanism for Freescale
> > book3e is different from when booting with normal hardware.  In theory
> > we could simulate the normal spin table mechanism, but not (easily) at
> > the addresses U-Boot put in the device tree -- so there'd need to be
> > even more communication between the kernel and kexec to set that up.
> > 
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > ---
> > v2: Use a device tree property rather than setting a flag in the kernel
> > image, as requested by Michael Ellerman.
> 
> ping?
> 
> Michael, can you review this?  Simon is waiting for another PPC person to
> review it.

Oh sorry I thought it'd been merged already, but I see now only 1 & 2 went in.

Horms this looks fine to me:

Acked-by: Michael Ellerman <mpe@ellerman.id.au>

cheers


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

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

* Re: [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
  2015-12-08  3:46       ` Michael Ellerman
@ 2015-12-08  6:01         ` Simon Horman
  -1 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-12-08  6:01 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Scott Wood, kexec, linuxppc-dev

On Tue, Dec 08, 2015 at 02:46:17PM +1100, Michael Ellerman wrote:
> On Mon, 2015-12-07 at 14:42 -0600, Scott Wood wrote:
> > On Tue, 2015-10-06 at 17:55 -0500, Scott Wood wrote:
> > > It needs to know this because the SMP release mechanism for Freescale
> > > book3e is different from when booting with normal hardware.  In theory
> > > we could simulate the normal spin table mechanism, but not (easily) at
> > > the addresses U-Boot put in the device tree -- so there'd need to be
> > > even more communication between the kernel and kexec to set that up.
> > > 
> > > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > > ---
> > > v2: Use a device tree property rather than setting a flag in the kernel
> > > image, as requested by Michael Ellerman.
> > 
> > ping?
> > 
> > Michael, can you review this?  Simon is waiting for another PPC person to
> > review it.
> 
> Oh sorry I thought it'd been merged already, but I see now only 1 & 2 went in.
> 
> Horms this looks fine to me:
> 
> Acked-by: Michael Ellerman <mpe@ellerman.id.au>

Thanks, applied.

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

* Re: [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec
@ 2015-12-08  6:01         ` Simon Horman
  0 siblings, 0 replies; 26+ messages in thread
From: Simon Horman @ 2015-12-08  6:01 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Scott Wood, linuxppc-dev, kexec

On Tue, Dec 08, 2015 at 02:46:17PM +1100, Michael Ellerman wrote:
> On Mon, 2015-12-07 at 14:42 -0600, Scott Wood wrote:
> > On Tue, 2015-10-06 at 17:55 -0500, Scott Wood wrote:
> > > It needs to know this because the SMP release mechanism for Freescale
> > > book3e is different from when booting with normal hardware.  In theory
> > > we could simulate the normal spin table mechanism, but not (easily) at
> > > the addresses U-Boot put in the device tree -- so there'd need to be
> > > even more communication between the kernel and kexec to set that up.
> > > 
> > > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > > ---
> > > v2: Use a device tree property rather than setting a flag in the kernel
> > > image, as requested by Michael Ellerman.
> > 
> > ping?
> > 
> > Michael, can you review this?  Simon is waiting for another PPC person to
> > review it.
> 
> Oh sorry I thought it'd been merged already, but I see now only 1 & 2 went in.
> 
> Horms this looks fine to me:
> 
> Acked-by: Michael Ellerman <mpe@ellerman.id.au>

Thanks, applied.

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

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

end of thread, other threads:[~2015-12-08  6:02 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-06 22:55 [PATCH v2 1/3] ppc64: Fix warnings Scott Wood
2015-10-06 22:55 ` Scott Wood
2015-10-06 22:55 ` [PATCH v2 2/3] ppc64: Avoid rfid if no need to clear MSR_LE Scott Wood
2015-10-06 22:55   ` Scott Wood
2015-10-16  1:48   ` Simon Horman
2015-10-16  1:48     ` Simon Horman
2015-10-30  0:16     ` Scott Wood
2015-10-30  0:16       ` Scott Wood
2015-11-01 22:55   ` Sam Mendoza-Jonas
2015-11-01 22:55     ` Sam Mendoza-Jonas
2015-11-02  0:21     ` Sam Mendoza-Jonas
2015-11-02  0:21       ` Sam Mendoza-Jonas
2015-11-02  2:06       ` Simon Horman
2015-11-02  2:06         ` Simon Horman
2015-10-06 22:55 ` [PATCH v2 3/3] ppc64: Add a flag to tell the kernel it's booting from kexec Scott Wood
2015-10-06 22:55   ` Scott Wood
2015-10-16  1:48   ` Simon Horman
2015-10-16  1:48     ` Simon Horman
2015-12-07 20:42   ` Scott Wood
2015-12-07 20:42     ` Scott Wood
2015-12-08  3:46     ` Michael Ellerman
2015-12-08  3:46       ` Michael Ellerman
2015-12-08  6:01       ` Simon Horman
2015-12-08  6:01         ` Simon Horman
2015-10-16  1:47 ` [PATCH v2 1/3] ppc64: Fix warnings Simon Horman
2015-10-16  1:47   ` Simon Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.