From: Samuel Mendoza-Jonas <hidden> Date: 2015-07-22 05:51:26
Older ppc64 kernels, namely those missing FIXUP_ENDIAN or opal_reinit_cpus,
will fail to boot if started via kexec from a little-endian kernel.
The following two patches make sure that the current endianess is reset to
big-endian just before entering the target kernel, and are accompanied by
a separate patch to kexec-lite that resets the endianess of the boot cpu.
Changes in v4:
As pointed out by Ben since interrupts are already disabled before checking
that all secondaries are in OPAL, we can make the call to opal_reinit_cpus
in C, in pnv_kexec_cpu_down().
Changes in v3:
Move the call to opal_reinit_cpus into kexec_sequence so we can call it in
real mode with interrupts disabled. Update the kexec_sequence prototype so
that we can check if OPAL is present.
Fix the !CONFIG_PPC_BOOK3S_64 case in kexec_wait to correctly branch to 0x60
Changes in v2:
Add an #ifdef for subarch-specific code
Neaten the endian check (and extra call to mfmsr!) by modifying the msr and
branching to the target kernel in the same call to rfid.
Samuel Mendoza-Jonas (2):
powerpc/kexec: Reset secondary cpu endianess before kexec
powerpc/kexec: Reset HILE before kexec_sequence
arch/powerpc/kernel/misc_64.S | 13 +++++++++++--
arch/powerpc/platforms/powernv/setup.c | 7 +++++++
2 files changed, 18 insertions(+), 2 deletions(-)
--
2.4.6
From: Samuel Mendoza-Jonas <hidden> Date: 2015-07-22 05:51:24
If the target kernel does not inlcude the FIXUP_ENDIAN check, coming
from a different-endian kernel will cause the target kernel to panic.
All ppc64 kernels can handle starting in big-endian mode, so return to
big-endian before branching into the target kernel.
This mainly affects pseries as secondaries on powernv are returned to
OPAL.
Signed-off-by: Samuel Mendoza-Jonas <redacted>
---
arch/powerpc/kernel/misc_64.S | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
@@ -475,9 +475,18 @@ _GLOBAL(kexec_wait)#ifdef CONFIG_KEXEC /* use no memory without kexec */lwzr4,0(r5)cmpwi0,r4,0-bnea0x60+beq99b+#ifdef CONFIG_PPC_BOOK3S_64+lir10,0x60+mfmsrr11+clrrdir11,r11,1/*ClearMSR_LE*/+mtsrr0r10+mtsrr1r11+rfid+#else+ba0x60+#endif#endif-b99b/*thiscanbeintextbecausewewon't change it until we are*runninginrealanyways
From: Samuel Mendoza-Jonas <hidden> Date: 2015-07-22 05:51:27
On powernv secondary cpus are returned to OPAL, and will then enter
the target kernel in big-endian. However if it is set the HILE bit
will persist, causing the first exception in the target kernel to be
delivered in litte-endian regardless of the current endianess.
If running on top of OPAL make sure the HILE bit is reset once we've
finished waiting for all of the secondaries to be returned to OPAL.
Signed-off-by: Samuel Mendoza-Jonas <redacted>
---
arch/powerpc/platforms/powernv/setup.c | 7 +++++++
1 file changed, 7 insertions(+)
@@ -243,6 +243,13 @@ static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)}else{/* Primary waits for the secondaries to have reached OPAL */pnv_kexec_wait_secondaries_down();++/*+*Wemightberunningaslittle-endian-nowthatinterrupts+*aredisabled,resettheHILEbittobig-endiansowedon't+*takeinterruptsinthewrongendianlater+*/+opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);}}#endif /* CONFIG_KEXEC */
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2015-08-21 07:43:35
On Wed, 2015-22-07 at 05:50:51 UTC, Samuel Mendoza-Jonas wrote:
On powernv secondary cpus are returned to OPAL, and will then enter
the target kernel in big-endian. However if it is set the HILE bit
will persist, causing the first exception in the target kernel to be
delivered in litte-endian regardless of the current endianess.
If running on top of OPAL make sure the HILE bit is reset once we've
finished waiting for all of the secondaries to be returned to OPAL.
Signed-off-by: Samuel Mendoza-Jonas <redacted>
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2015-08-21 07:43:36
On Wed, 2015-22-07 at 05:50:50 UTC, Samuel Mendoza-Jonas wrote:
If the target kernel does not inlcude the FIXUP_ENDIAN check, coming
from a different-endian kernel will cause the target kernel to panic.
All ppc64 kernels can handle starting in big-endian mode, so return to
big-endian before branching into the target kernel.
This mainly affects pseries as secondaries on powernv are returned to
OPAL.
Signed-off-by: Samuel Mendoza-Jonas <redacted>