git: e141b62d2088 - main - powerpc64le: fix boot when using QEMU PowerNV

From: Leandro Lupori <luporl_at_FreeBSD.org>
Date: Thu, 25 Nov 2021 19:44:17 UTC
The branch main has been updated by luporl:

URL: https://cgit.FreeBSD.org/src/commit/?id=e141b62d208867fc5bdb5803d05f5496260722ac

commit e141b62d208867fc5bdb5803d05f5496260722ac
Author:     Leandro Lupori <luporl@FreeBSD.org>
AuthorDate: 2021-11-25 19:41:46 +0000
Commit:     Leandro Lupori <luporl@FreeBSD.org>
CommitDate: 2021-11-25 19:41:46 +0000

    powerpc64le: fix boot when using QEMU PowerNV
    
    When using QEMU PowerNV with latest op-build release (v2.7), its
    kexec transfers control to FreeBSD kernel in BE mode, causing an
    instant exception on LE kernels. Make kboot able to detect and
    swap endian to fix this.
    
    Reviewed by:            imp
    Sponsored by:           Instituto de Pesquisas Eldorado (eldorado.org.br)
    Differential Revision:  https://reviews.freebsd.org/D33104
---
 sys/powerpc/aim/locore64.S | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/powerpc/aim/locore64.S b/sys/powerpc/aim/locore64.S
index f0a183c4b331..3eb6e546399c 100644
--- a/sys/powerpc/aim/locore64.S
+++ b/sys/powerpc/aim/locore64.S
@@ -82,6 +82,9 @@ TOC_ENTRY(trapstk)
  */
 	.section ".text.kboot", "x", @progbits
 kbootentry:
+#ifdef __LITTLE_ENDIAN__
+	RETURN_TO_NATIVE_ENDIAN
+#endif
 	b __start
 . = kbootentry + 0x40	/* Magic address used in platform layer */
 	.global smp_spin_sem