File kexec-tools-ppc64-purgatory-device-tree-values-should-be-read-stored-in-big-endian.patch of Package kexec-tools

From: Laurent Dufour <>
Subject: ppc64/purgatory: Device tree values should be read/stored in Big Endian
References: bnc#875485
Git-commit: pending
Signed-off-by: Tony Jones <>

The purgatory code reads the device tree's version and stores if needed the
currently running CPU number. These 2 values are stored in Big Endian
format in the device tree and should be byte swapped when running in Little
Endian mode.

Without this fix, when running in SMP environment, kexec or kdump kernel may
fail booting with the following message :
Failed to identify boot CPU

Signed-off-by: Laurent Dufour <>
 purgatory/arch/ppc64/v2wrap.S |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
index 6fc62e3..dc5034f 100644
--- a/purgatory/arch/ppc64/v2wrap.S
+++ b/purgatory/arch/ppc64/v2wrap.S
@@ -90,10 +90,20 @@ master:
 	LOADADDR(16, dt_offset)
 	ld      3,0(16)         # load device-tree address
 	mr      16,3            # save dt address in reg16
+#ifdef __BIG_ENDIAN__
 	lwz     6,20(3)         # fetch version number
+	li	4,20
+	lwbrx	6,3,4		# fetch BE version number
 	cmpwi   0,6,2           # v2 ?
 	blt     80f
+#ifdef __BIG_ENDIAN__
 	stw     17,28(3)        # save my cpu number as boot_cpu_phys
+	li	4,28
+	stwbrx	17,3,4		# Store my cpu as BE value
 	LOADADDR(6,opal_base)	# For OPAL early debug
 	ld      8,0(6)          # load the OPAL base address in r8
openSUSE Build Service is sponsored by