linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/kdump: skip enabling big endian exception during crash
@ 2014-12-11 16:44 Hari Bathini
  2014-12-11 22:40 ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: Hari Bathini @ 2014-12-11 16:44 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Mahesh J Salgaonkar

In LE kernel, we currently have a hack for kexec that resets the exception endian
before starting a new kernel as the kernel that is loaded could be a big endian
or a little endian kernel. In kdump case, resetting exception endian fails when
one or more cpus is disabled. But in case of kdump, we can conveniently ignore
resetting endianess as crashkernel is always of same endianess as primary kernel.
This patch adds a new inline function to say if this is kdump path. This function
is used at places where such a check is needed.

Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/kexec.h       |   10 ++++++++++
 arch/powerpc/kernel/machine_kexec_64.c |    2 +-
 arch/powerpc/platforms/pseries/lpar.c  |    7 ++++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 19c36cb..0d96d4d 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -86,6 +86,11 @@ extern int overlaps_crashkernel(unsigned long start, unsigned long size);
 extern void reserve_crashkernel(void);
 extern void machine_kexec_mask_interrupts(void);
 
+static inline int is_kdump_path(void)
+{
+	return (crashing_cpu >= 0) ? 1 : 0;
+}
+
 #else /* !CONFIG_KEXEC */
 static inline void crash_kexec_secondary(struct pt_regs *regs) { }
 
@@ -106,6 +111,11 @@ static inline int crash_shutdown_unregister(crash_shutdown_t handler)
 	return 0;
 }
 
+static inline int is_kdump_path(void)
+{
+	return 0;
+}
+
 #endif /* CONFIG_KEXEC */
 #endif /* ! __ASSEMBLY__ */
 #endif /* __KERNEL__ */
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 879b3aa..b4fe804 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -330,7 +330,7 @@ void default_machine_kexec(struct kimage *image)
         * using debugger IPI.
         */
 
-	if (crashing_cpu == -1)
+	if (!is_kdump_path())
 		kexec_prepare_cpus();
 
 	pr_debug("kexec: Starting switchover sequence.\n");
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index f6880d2..be41680 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -43,6 +43,7 @@
 #include <asm/trace.h>
 #include <asm/firmware.h>
 #include <asm/plpar_wrappers.h>
+#include <asm/kexec.h>
 #include <asm/fadump.h>
 
 #include "pseries.h"
@@ -257,8 +258,12 @@ static void pSeries_lpar_hptab_clear(void)
 	 *
 	 * This is also called on boot when a fadump happens. In that case we
 	 * must not change the exception endian mode.
+	 *
+	 * This is also called during kdump which doesn't need resetting, as the
+	 * the crashkernel is of same endainess as primary kernel.
 	 */
-	if (firmware_has_feature(FW_FEATURE_SET_MODE) && !is_fadump_active()) {
+	if (firmware_has_feature(FW_FEATURE_SET_MODE) && !is_fadump_active() &&
+			!is_kdump_path()) {
 		long rc;
 
 		rc = pseries_big_endian_exceptions();

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

* Re: powerpc/kdump: skip enabling big endian exception during crash
  2014-12-11 16:44 [PATCH] powerpc/kdump: skip enabling big endian exception during crash Hari Bathini
@ 2014-12-11 22:40 ` Michael Ellerman
  2014-12-12  4:06   ` Mahesh Jagannath Salgaonkar
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2014-12-11 22:40 UTC (permalink / raw)
  To: Hari Bathini, linuxppc-dev; +Cc: Mahesh J Salgaonkar

On Thu, 2014-11-12 at 16:44:54 UTC, Hari Bathini wrote:
> In LE kernel, we currently have a hack for kexec that resets the exception endian
> before starting a new kernel as the kernel that is loaded could be a big endian
> or a little endian kernel. In kdump case, resetting exception endian fails when
> one or more cpus is disabled. But in case of kdump, we can conveniently ignore
> resetting endianess as crashkernel is always of same endianess as primary kernel.

No, it's not guaranteed to be the same endianess.

That tends to be what people do in practice, but it's not an assumption you can
hard code.

cheers

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

* Re: powerpc/kdump: skip enabling big endian exception during crash
  2014-12-11 22:40 ` Michael Ellerman
@ 2014-12-12  4:06   ` Mahesh Jagannath Salgaonkar
  0 siblings, 0 replies; 3+ messages in thread
From: Mahesh Jagannath Salgaonkar @ 2014-12-12  4:06 UTC (permalink / raw)
  To: Michael Ellerman, Hari Bathini, linuxppc-dev; +Cc: Anton Blanchard

On 12/12/2014 04:10 AM, Michael Ellerman wrote:
> On Thu, 2014-11-12 at 16:44:54 UTC, Hari Bathini wrote:
>> In LE kernel, we currently have a hack for kexec that resets the exception endian
>> before starting a new kernel as the kernel that is loaded could be a big endian
>> or a little endian kernel. In kdump case, resetting exception endian fails when
>> one or more cpus is disabled. But in case of kdump, we can conveniently ignore
>> resetting endianess as crashkernel is always of same endianess as primary kernel.
> 
> No, it's not guaranteed to be the same endianess.
> 
> That tends to be what people do in practice, but it's not an assumption you can
> hard code.

Agree. The other solution could be to wakeup offline CPUs in crash path
as we do it in normal kexec path. PHYP expects all partitions processors
MSR[EE] = 0 while we call pseries_big_endian_exceptions(). Waking up
offline CPUs will help to achieve that. But since we are already in
crashed kernel context I am not sure how safe is to call
wake_offline_cpus().

Thanks,
-Mahesh.

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

end of thread, other threads:[~2014-12-12  4:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-11 16:44 [PATCH] powerpc/kdump: skip enabling big endian exception during crash Hari Bathini
2014-12-11 22:40 ` Michael Ellerman
2014-12-12  4:06   ` Mahesh Jagannath Salgaonkar

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