Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/kexec: Add kexec "hold" support for Book3e processors

Motivation:
IBM Blue Gene/Q comes with some very strange firmware that I'm trying to get out
of using in the kernel. So instead I spin all the threads in the boot wrapper
(using the firmware) and have them enter the kexec stub, pre-translated at the
virtual "linear" address, never touching firmware again.

This works strategy works wonderfully, but I need the following patch in the
kexec stub. I believe it should not effect Book3S and Book3E does not appear
to be here yet so I'd love to get any criticisms up front.

This patch adds two items:

1) Book3e requires that GPR4 survive the "hold" process, so we make
sure that happens.
2) Book3e has no real mode, and the hold code exploits this. Since
these processors ares always translated, we arrange for the kexeced
threads to enter the hold code using the normal kernel linear mapping.

Signed-off-by: Jimi Xenidis <jimix@pobox.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Jimi Xenidis and committed by
Benjamin Herrenschmidt
96f013fe c7c360ee

+18 -1
+18 -1
arch/powerpc/kernel/head_64.S
··· 122 122 #endif 123 123 /* Grab our physical cpu number */ 124 124 mr r24,r3 125 + /* stash r4 for book3e */ 126 + mr r25,r4 125 127 126 128 /* Tell the master cpu we're here */ 127 129 /* Relocation is off & we are located at an address less */ ··· 131 129 std r24,__secondary_hold_acknowledge-_stext(0) 132 130 sync 133 131 132 + li r26,0 133 + #ifdef CONFIG_PPC_BOOK3E 134 + tovirt(r26,r26) 135 + #endif 134 136 /* All secondary cpus wait here until told to start. */ 135 - 100: ld r4,__secondary_hold_spinloop-_stext(0) 137 + 100: ld r4,__secondary_hold_spinloop-_stext(r26) 136 138 cmpdi 0,r4,0 137 139 beq 100b 138 140 139 141 #if defined(CONFIG_SMP) || defined(CONFIG_KEXEC) 142 + #ifdef CONFIG_PPC_BOOK3E 143 + tovirt(r4,r4) 144 + #endif 140 145 ld r4,0(r4) /* deref function descriptor */ 141 146 mtctr r4 142 147 mr r3,r24 148 + /* 149 + * it may be the case that other platforms have r4 right to 150 + * begin with, this gives us some safety in case it is not 151 + */ 152 + #ifdef CONFIG_PPC_BOOK3E 153 + mr r4,r25 154 + #else 143 155 li r4,0 156 + #endif 144 157 /* Make sure that patched code is visible */ 145 158 isync 146 159 bctr