Skip to content

Commit 1c0eaf0

Browse files
ozbenhmpe
authored andcommitted
powerpc/powernv: Tell OPAL about our MMU mode on POWER9
That will allow OPAL to configure the CPU in an optimal way. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 1e2a516 commit 1c0eaf0

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

arch/powerpc/include/asm/opal-api.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,15 @@ struct OpalIoPhb4ErrorData {
876876
enum {
877877
OPAL_REINIT_CPUS_HILE_BE = (1 << 0),
878878
OPAL_REINIT_CPUS_HILE_LE = (1 << 1),
879+
880+
/* These two define the base MMU mode of the host on P9
881+
*
882+
* On P9 Nimbus DD2.0 and Cumlus (and later), KVM can still
883+
* create hash guests in "radix" mode with care (full core
884+
* switch only).
885+
*/
886+
OPAL_REINIT_CPUS_MMU_HASH = (1 << 2),
887+
OPAL_REINIT_CPUS_MMU_RADIX = (1 << 3),
879888
};
880889

881890
typedef struct oppanel_line {

arch/powerpc/platforms/powernv/opal.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,33 @@ static struct task_struct *kopald_tsk;
5959

6060
void opal_configure_cores(void)
6161
{
62+
u64 reinit_flags = 0;
63+
6264
/* Do the actual re-init, This will clobber all FPRs, VRs, etc...
6365
*
6466
* It will preserve non volatile GPRs and HSPRG0/1. It will
6567
* also restore HIDs and other SPRs to their original value
6668
* but it might clobber a bunch.
6769
*/
6870
#ifdef __BIG_ENDIAN__
69-
opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
71+
reinit_flags |= OPAL_REINIT_CPUS_HILE_BE;
7072
#else
71-
opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_LE);
73+
reinit_flags |= OPAL_REINIT_CPUS_HILE_LE;
7274
#endif
7375

76+
/*
77+
* POWER9 always support running hash:
78+
* ie. Host hash supports hash guests
79+
* Host radix supports hash/radix guests
80+
*/
81+
if (cpu_has_feature(CPU_FTR_ARCH_300)) {
82+
reinit_flags |= OPAL_REINIT_CPUS_MMU_HASH;
83+
if (early_radix_enabled())
84+
reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX;
85+
}
86+
87+
opal_reinit_cpus(reinit_flags);
88+
7489
/* Restore some bits */
7590
if (cur_cpu_spec->cpu_restore)
7691
cur_cpu_spec->cpu_restore();

arch/powerpc/platforms/powernv/setup.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ static void pnv_kexec_wait_secondaries_down(void)
225225

226226
static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
227227
{
228+
u64 reinit_flags;
229+
228230
if (xive_enabled())
229231
xive_kexec_teardown_cpu(secondary);
230232
else
@@ -254,8 +256,15 @@ static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
254256
* We might be running as little-endian - now that interrupts
255257
* are disabled, reset the HILE bit to big-endian so we don't
256258
* take interrupts in the wrong endian later
259+
*
260+
* We reinit to enable both radix and hash on P9 to ensure
261+
* the mode used by the next kernel is always supported.
257262
*/
258-
opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
263+
reinit_flags = OPAL_REINIT_CPUS_HILE_BE;
264+
if (cpu_has_feature(CPU_FTR_ARCH_300))
265+
reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX |
266+
OPAL_REINIT_CPUS_MMU_HASH;
267+
opal_reinit_cpus(reinit_flags);
259268
}
260269
}
261270
#endif /* CONFIG_KEXEC_CORE */

0 commit comments

Comments
 (0)