git: 9c1f54589173 - stable/13 - powerpc64le: fix boot when using QEMU PowerNV

From: Leandro Lupori <luporl_at_FreeBSD.org>
Date: Tue, 04 Oct 2022 16:29:38 UTC
The branch stable/13 has been updated by luporl:

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

commit 9c1f54589173dc7616a866b08be68fce889cc1b1
Author:     Leandro Lupori <luporl@FreeBSD.org>
AuthorDate: 2021-11-25 19:41:46 +0000
Commit:     Leandro Lupori <luporl@FreeBSD.org>
CommitDate: 2022-10-04 16:24:14 +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
    
    (cherry picked from commit e141b62d208867fc5bdb5803d05f5496260722ac)
---
 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