linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hari Bathini <hbathini@linux.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Pingfan Liu <piliu@redhat.com>,
	Kexec-ml <kexec@lists.infradead.org>,
	Mimi Zohar <zohar@linux.ibm.com>, Petr Tesarik <ptesarik@suse.cz>,
	Mahesh J Salgaonkar <mahesh@linux.ibm.com>,
	Sourabh Jain <sourabhjain@linux.ibm.com>,
	lkml <linux-kernel@vger.kernel.org>,
	linuxppc-dev <linuxppc-dev@ozlabs.org>,
	Eric Biederman <ebiederm@xmission.com>,
	Thiago Jung Bauermann <bauerman@linux.ibm.com>,
	Dave Young <dyoung@redhat.com>, Vivek Goyal <vgoyal@redhat.com>
Subject: [PATCH 08/11] ppc64/kexec_file: setup the stack for purgatory
Date: Sat, 27 Jun 2020 00:35:50 +0530	[thread overview]
Message-ID: <159319835023.16351.6771622598460231857.stgit@hbathini.in.ibm.com> (raw)
In-Reply-To: <159319825403.16351.7253978047621755765.stgit@hbathini.in.ibm.com>

To avoid any weird errors, the purgatory should run with its own
stack. Set one up by adding the stack buffer to .data section of
the purgatory.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
---
 arch/powerpc/include/asm/kexec.h       |    4 ++++
 arch/powerpc/kexec/file_load_64.c      |   14 +++++++++++++-
 arch/powerpc/purgatory/trampoline_64.S |   15 +++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index bf47a01..e78cd0a 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -45,6 +45,10 @@
 #define KEXEC_ARCH KEXEC_ARCH_PPC
 #endif
 
+#ifdef CONFIG_KEXEC_FILE
+#define KEXEC_PURGATORY_STACK_SIZE	16384	/* 16KB stack size */
+#endif
+
 #define KEXEC_STATE_NONE 0
 #define KEXEC_STATE_IRQS_OFF 1
 #define KEXEC_STATE_REAL_MODE 2
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index 4430336..8e66c28 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -878,7 +878,8 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,
 			  const void *fdt, unsigned long kernel_load_addr,
 			  unsigned long fdt_load_addr)
 {
-	uint64_t toc_ptr;
+	uint64_t toc_ptr, stack_top;
+	void *stack_buf;
 	int ret;
 
 	ret = setup_purgatory(image, slave_code, fdt, kernel_load_addr,
@@ -901,6 +902,17 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,
 			goto out;
 	}
 
+	/* Setup the stack top */
+	stack_buf = kexec_purgatory_get_symbol_addr(image, "stack_buf");
+	if (!stack_buf)
+		goto out;
+
+	stack_top = (u64)stack_buf + KEXEC_PURGATORY_STACK_SIZE;
+	ret = kexec_purgatory_get_set_symbol(image, "stack", &stack_top,
+					     sizeof(stack_top), false);
+	if (ret)
+		goto out;
+
 	/* Setup the TOC pointer */
 	toc_ptr = get_toc_ptr(image->purgatory_info.ehdr);
 	ret = kexec_purgatory_get_set_symbol(image, "my_toc", &toc_ptr,
diff --git a/arch/powerpc/purgatory/trampoline_64.S b/arch/powerpc/purgatory/trampoline_64.S
index 7b4a5f7..80615b4 100644
--- a/arch/powerpc/purgatory/trampoline_64.S
+++ b/arch/powerpc/purgatory/trampoline_64.S
@@ -9,6 +9,7 @@
  * Copyright (C) 2013, Anton Blanchard, IBM Corporation
  */
 
+#include <asm/kexec.h>
 #include <asm/asm-compat.h>
 
 	.machine ppc64
@@ -53,6 +54,8 @@ master:
 
 	ld	%r2,(my_toc - 0b)(%r18)		/* setup toc */
 
+	ld	%r1,(stack - 0b)(%r18)		/* setup stack */
+
 	/* load device-tree address */
 	ld	%r3, (dt_offset - 0b)(%r18)
 	mr	%r16,%r3	/* save dt address in reg16 */
@@ -111,6 +114,12 @@ my_toc:
 	.8byte  0x0
 	.size my_toc, . - my_toc
 
+	.balign 8
+	.globl stack
+stack:
+	.8byte  0x0
+	.size stack, . - stack
+
 	.data
 	.balign 8
 .globl purgatory_sha256_digest
@@ -123,3 +132,9 @@ purgatory_sha256_digest:
 purgatory_sha_regions:
 	.skip	8 * 2 * 16
 	.size purgatory_sha_regions, . - purgatory_sha_regions
+
+	.balign 8
+.globl stack_buf
+stack_buf:
+	.skip	KEXEC_PURGATORY_STACK_SIZE
+	.size stack_buf, . - stack_buf


  parent reply	other threads:[~2020-06-26 19:06 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26 19:04 [PATCH 00/11] ppc64: enable kdump support for kexec_file_load syscall Hari Bathini
2020-06-26 19:04 ` [PATCH 01/11] kexec_file: allow archs to handle special regions while locating memory hole Hari Bathini
2020-06-27  6:30   ` Christophe Leroy
2020-06-28  2:28   ` piliu
2020-06-29  6:00     ` Hari Bathini
2020-06-29 11:39   ` Petr Tesarik
2020-06-29 11:56     ` Hari Bathini
2020-07-01  7:46       ` Dave Young
2020-07-01 18:31         ` Hari Bathini
2020-07-02 11:47           ` Dave Young
2020-06-26 19:04 ` [PATCH 02/11] powerpc/kexec_file: mark PPC64 specific code Hari Bathini
2020-06-27  6:42   ` Christophe Leroy
2020-06-29  6:23     ` Hari Bathini
2020-06-26 19:05 ` [PATCH 03/11] powerpc/kexec_file: add helper functions for getting memory ranges Hari Bathini
2020-06-26 19:05 ` [PATCH 04/11] ppc64/kexec_file: avoid stomping memory used by special regions Hari Bathini
2020-06-27 10:45   ` kernel test robot
2020-06-28  2:14   ` piliu
2020-06-29  5:55     ` Hari Bathini
2020-06-30  3:30       ` piliu
2020-06-30  6:10         ` Hari Bathini
2020-06-30  8:13           ` piliu
2020-07-01  7:40   ` Dave Young
2020-07-01 12:53     ` piliu
2020-07-02 11:59       ` Dave Young
2020-07-01 18:18     ` Hari Bathini
2020-07-02 11:54       ` Dave Young
2020-06-26 19:05 ` [PATCH 05/11] powerpc/drmem: make lmb walk a bit more flexible Hari Bathini
2020-06-26 19:05 ` [PATCH 06/11] ppc64/kexec_file: restrict memory usage of kdump kernel Hari Bathini
2020-06-26 19:05 ` [PATCH 07/11] ppc64/kexec_file: add support to relocate purgatory Hari Bathini
2020-06-27 11:52   ` kernel test robot
2020-06-26 19:05 ` Hari Bathini [this message]
2020-06-26 19:05 ` [PATCH 09/11] ppc64/kexec_file: setup backup region for kdump kernel Hari Bathini
2020-06-27 13:02   ` kernel test robot
2020-06-26 19:06 ` [PATCH 10/11] ppc64/kexec_file: prepare elfcore header for crashing kernel Hari Bathini
2020-06-26 19:06 ` [PATCH 11/11] ppc64/kexec_file: add appropriate regions for memory reserve map Hari Bathini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=159319835023.16351.6771622598460231857.stgit@hbathini.in.ibm.com \
    --to=hbathini@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=bauerman@linux.ibm.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mahesh@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=piliu@redhat.com \
    --cc=ptesarik@suse.cz \
    --cc=sourabhjain@linux.ibm.com \
    --cc=vgoyal@redhat.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).