linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
To: anton@samba.org
Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>, linuxppc-dev@ozlabs.org
Subject: [kexec-lite PATCH] trampoline: Reset primary cpu endian to big-endian
Date: Wed,  8 Jul 2015 11:25:42 +1000	[thread overview]
Message-ID: <1436318742-13490-1-git-send-email-sam.mj@au1.ibm.com> (raw)

Older big-endian ppc64 kernels don't include the FIXUP_ENDIAN check,
meaning if we kexec from a little-endian kernel the target kernel will
fail to boot.
Returning to big-endian before we enter the target kernel ensures that
the target kernel can boot whether or not it includes FIXUP_ENDIAN.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
---
 kexec_trampoline.S |  9 ++++++++-
 kexec_trampoline.h | 17 +++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/kexec_trampoline.S b/kexec_trampoline.S
index a3eb314..29537ab 100644
--- a/kexec_trampoline.S
+++ b/kexec_trampoline.S
@@ -41,6 +41,8 @@
 #define	r7	7
 #define	r8	8
 #define	r9	9
+#define	r10	10
+#define	r11	11
 
 #ifdef __powerpc64__
 #define LOAD	ld
@@ -50,8 +52,10 @@
 
 #if defined(__LITTLE_ENDIAN__)
 #define STWX_BE	stwbrx
+#define BCTR .long 0x2004804e
 #elif defined(__BIG_ENDIAN__)
 #define STWX_BE	stwx
+#define BCTR bctr
 #else
 #error no endianness defined!
 #endif
@@ -89,7 +93,10 @@ start:
 	li	r5,0
 
 	mtctr	r4
-	bctr
+
+	RESET_ENDIAN
+
+	BCTR
 
 . = KERNEL_ADDR_OFFSET
 kernel_addr:
diff --git a/kexec_trampoline.h b/kexec_trampoline.h
index 6485c88..909953b 100644
--- a/kexec_trampoline.h
+++ b/kexec_trampoline.h
@@ -27,7 +27,20 @@
 /* Fixed offset in device tree for storing the physical ID of the boot CPU */
 #define DT_CPU_OFFSET			28
 
-#ifndef __ASSEMBLY__
+#ifdef __ASSEMBLY__
+#define RESET_ENDIAN						   \
+	mfmsr	r9;						   \
+	clrldi.	r10,r9,63;					   \
+	beq	$+36;		/* Already big-endian */	   \
+	bcl	20,31,$+4;					   \
+	mflr	r10;						   \
+	addi	r10,r10,28;					   \
+	mfmsr	r11;						   \
+	xori	r11,r11,1;					   \
+	mtsrr0	r10;						   \
+	mtsrr1	r11;						   \
+	rfid;
+#else
 
 extern char __trampoline_start[];
 extern char __trampoline_end[];
@@ -48,6 +61,6 @@ static inline void trampoline_set_device_tree(void *p, unsigned long addr)
 	*v = addr;
 }
 
-#endif
+#endif /* !__ASSEMBLY__ */
 
 #endif
-- 
2.4.5

             reply	other threads:[~2015-07-08  1:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08  1:25 Samuel Mendoza-Jonas [this message]
2015-07-08  1:56 ` [kexec-lite PATCH] trampoline: Reset primary cpu endian to big-endian Anton Blanchard
2015-07-08  3:11   ` Samuel Mendoza-Jonas

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=1436318742-13490-1-git-send-email-sam.mj@au1.ibm.com \
    --to=sam.mj@au1.ibm.com \
    --cc=anton@samba.org \
    --cc=linuxppc-dev@ozlabs.org \
    /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).