linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ppc64: Fix warnings
@ 2015-07-18 19:57 Scott Wood
  2015-07-18 19:57 ` [PATCH 2/2] ppc64: Add a flag to tell the kernel it's booting from kexec Scott Wood
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Wood @ 2015-07-18 19:57 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec, linuxppc-dev, 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>
---
 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] 6+ messages in thread

* [PATCH 2/2] ppc64: Add a flag to tell the kernel it's booting from kexec
  2015-07-18 19:57 [PATCH 1/2] ppc64: Fix warnings Scott Wood
@ 2015-07-18 19:57 ` Scott Wood
  2015-08-17 18:59   ` Scott Wood
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Wood @ 2015-07-18 19:57 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec, linuxppc-dev, 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.
Since there's already a similar flag being set (for kdump only), this
seemed like a reasonable approach.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 kexec/arch/ppc64/kexec-elf-ppc64.c | 11 ++++++++++-
 kexec/arch/ppc64/kexec-ppc64.h     |  2 ++
 purgatory/arch/ppc64/v2wrap.S      | 11 +++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
index adcee4c..ebd91b1 100644
--- a/kexec/arch/ppc64/kexec-elf-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
@@ -112,7 +112,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 	unsigned int my_panic_kernel;
 	uint64_t my_stack, my_backup_start;
 	uint64_t toc_addr;
-	uint32_t my_run_at_load;
+	uint32_t my_run_at_load, my_booted_from_kexec;
 	unsigned int slave_code[256/sizeof (unsigned int)], master_entry;
 
 	/* See options.h -- add any more there, too. */
@@ -314,6 +314,15 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
 				sizeof(my_run_at_load));
 	}
 
+	elf_rel_get_symbol(&info->rhdr, "booted_from_kexec",
+			&my_booted_from_kexec,
+			sizeof(my_booted_from_kexec));
+	if (my_booted_from_kexec == KERNEL_BOOTED_FROM_KEXEC_MAGIC)
+		my_booted_from_kexec = 1;
+	elf_rel_set_symbol(&info->rhdr, "booted_from_kexec",
+			&my_booted_from_kexec,
+			sizeof(my_booted_from_kexec));
+
 	/* Set stack address */
 	my_stack = locate_hole(info, 16*1024, 0, 0, max_addr, 1);
 	my_stack += 16*1024;
diff --git a/kexec/arch/ppc64/kexec-ppc64.h b/kexec/arch/ppc64/kexec-ppc64.h
index 89ee942..0e9f63d 100644
--- a/kexec/arch/ppc64/kexec-ppc64.h
+++ b/kexec/arch/ppc64/kexec-ppc64.h
@@ -14,6 +14,8 @@
 #define HAVE_DYNAMIC_MEMORY
 #define NEED_RESERVE_DTB
 
+#define KERNEL_BOOTED_FROM_KEXEC_MAGIC 0x6e6b7863 /* "nkxc" */
+
 int setup_memory_ranges(unsigned long kexec_flags);
 
 int elf_ppc64_probe(const char *buf, off_t len);
diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
index dc5034f..8ed9880 100644
--- a/purgatory/arch/ppc64/v2wrap.S
+++ b/purgatory/arch/ppc64/v2wrap.S
@@ -51,11 +51,19 @@
 	.align 8
 	.globl purgatory_start
 purgatory_start:	b	master
+
+	.org purgatory_start + 0x58     # ABI: possible booted_from_kexec flag
+	.globl booted_from_kexec
+booted_from_kexec:
+	.long 0
+	.size booted_from_kexec, . - booted_from_kexec
+
 	.org purgatory_start + 0x5c     # ABI: possible run_at_load flag at 0x5c
 	.globl run_at_load
 run_at_load:
 	.long 0
 	.size run_at_load, . - run_at_load
+
 	.org purgatory_start + 0x60     # ABI: slaves start at 60 with r3=phys
 slave:	b $
 	.org purgatory_start + 0x100    # ABI: end of copied region
@@ -111,6 +119,9 @@ master:
 	ld      9,0(6)          # load the OPAL entry address in r9
 	LOADADDR(6,kernel)
 	ld      4,0(6)          # load the kernel address
+	LOADADDR(6,booted_from_kexec)
+	lwz	7,0(6)		# possibly patched by kexec-elf-ppc64
+	stw	7,0x58(4)	# and patch it into the kernel
 	LOADADDR(6,run_at_load) # the load flag
 	lwz	7,0(6)		# possibly patched by kexec-elf-ppc64
 	stw	7,0x5c(4)	# and patch it into the kernel
-- 
2.1.4

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

* Re: [PATCH 2/2] ppc64: Add a flag to tell the kernel it's booting from kexec
  2015-07-18 19:57 ` [PATCH 2/2] ppc64: Add a flag to tell the kernel it's booting from kexec Scott Wood
@ 2015-08-17 18:59   ` Scott Wood
  2015-08-18  2:51     ` Michael Ellerman
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Wood @ 2015-08-17 18:59 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec, linuxppc-dev

On Sat, 2015-07-18 at 14:57 -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.
> Since there's already a similar flag being set (for kdump only), this
> seemed like a reasonable approach.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
>  kexec/arch/ppc64/kexec-elf-ppc64.c | 11 ++++++++++-
>  kexec/arch/ppc64/kexec-ppc64.h     |  2 ++
>  purgatory/arch/ppc64/v2wrap.S      | 11 +++++++++++
>  3 files changed, 23 insertions(+), 1 deletion(-)

Any comment on these two patches?

-Scott

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

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

On Mon, 2015-08-17 at 13:59 -0500, Scott Wood wrote:
> On Sat, 2015-07-18 at 14:57 -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.
> > Since there's already a similar flag being set (for kdump only), this
> > seemed like a reasonable approach.
> > 
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > ---
> >  kexec/arch/ppc64/kexec-elf-ppc64.c | 11 ++++++++++-
> >  kexec/arch/ppc64/kexec-ppc64.h     |  2 ++
> >  purgatory/arch/ppc64/v2wrap.S      | 11 +++++++++++
> >  3 files changed, 23 insertions(+), 1 deletion(-)
> 
> Any comment on these two patches?

We should probably reserve 0x58 in the kernel's head_64.S too?

cheers

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

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

On Tue, 2015-08-18 at 12:51 +1000, Michael Ellerman wrote:
> On Mon, 2015-08-17 at 13:59 -0500, Scott Wood wrote:
> > On Sat, 2015-07-18 at 14:57 -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.
> > > Since there's already a similar flag being set (for kdump only), this
> > > seemed like a reasonable approach.
> > > 
> > > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > > ---
> > >  kexec/arch/ppc64/kexec-elf-ppc64.c | 11 ++++++++++-
> > >  kexec/arch/ppc64/kexec-ppc64.h     |  2 ++
> > >  purgatory/arch/ppc64/v2wrap.S      | 11 +++++++++++
> > >  3 files changed, 23 insertions(+), 1 deletion(-)
> > 
> > Any comment on these two patches?
> 
> We should probably reserve 0x58 in the kernel's head_64.S too?

That's done in http://patchwork.ozlabs.org/patch/497417/

Or do you mean that you want the kernel change to go in before the userspace 
change?

-Scott

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

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

On Mon, 2015-08-17 at 22:30 -0500, Scott Wood wrote:
> On Tue, 2015-08-18 at 12:51 +1000, Michael Ellerman wrote:
> > On Mon, 2015-08-17 at 13:59 -0500, Scott Wood wrote:
> > > On Sat, 2015-07-18 at 14:57 -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.
> > > > Since there's already a similar flag being set (for kdump only), this
> > > > seemed like a reasonable approach.
> > > > 
> > > > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > > > ---
> > > >  kexec/arch/ppc64/kexec-elf-ppc64.c | 11 ++++++++++-
> > > >  kexec/arch/ppc64/kexec-ppc64.h     |  2 ++
> > > >  purgatory/arch/ppc64/v2wrap.S      | 11 +++++++++++
> > > >  3 files changed, 23 insertions(+), 1 deletion(-)
> > > 
> > > Any comment on these two patches?
> > 
> > We should probably reserve 0x58 in the kernel's head_64.S too?
> 
> That's done in http://patchwork.ozlabs.org/patch/497417/

Right, sorry should have reviewed those :)

> Or do you mean that you want the kernel change to go in before the userspace 
> change?

No I'm not bothered about the ordering really.

cheers

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

end of thread, other threads:[~2015-08-18  3:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-18 19:57 [PATCH 1/2] ppc64: Fix warnings Scott Wood
2015-07-18 19:57 ` [PATCH 2/2] ppc64: Add a flag to tell the kernel it's booting from kexec Scott Wood
2015-08-17 18:59   ` Scott Wood
2015-08-18  2:51     ` Michael Ellerman
2015-08-18  3:30       ` Scott Wood
2015-08-18  3:53         ` Michael Ellerman

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