Skip to content

Commit

Permalink
powerpc/powernv: Tell OPAL about our MMU mode on POWER9
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Benjamin Herrenschmidt authored and Michael Ellerman committed Jul 10, 2017
1 parent 1e2a516 commit 1c0eaf0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
9 changes: 9 additions & 0 deletions arch/powerpc/include/asm/opal-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,15 @@ struct OpalIoPhb4ErrorData {
enum {
OPAL_REINIT_CPUS_HILE_BE = (1 << 0),
OPAL_REINIT_CPUS_HILE_LE = (1 << 1),

/* These two define the base MMU mode of the host on P9
*
* On P9 Nimbus DD2.0 and Cumlus (and later), KVM can still
* create hash guests in "radix" mode with care (full core
* switch only).
*/
OPAL_REINIT_CPUS_MMU_HASH = (1 << 2),
OPAL_REINIT_CPUS_MMU_RADIX = (1 << 3),
};

typedef struct oppanel_line {
Expand Down
19 changes: 17 additions & 2 deletions arch/powerpc/platforms/powernv/opal.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,33 @@ static struct task_struct *kopald_tsk;

void opal_configure_cores(void)
{
u64 reinit_flags = 0;

/* Do the actual re-init, This will clobber all FPRs, VRs, etc...
*
* It will preserve non volatile GPRs and HSPRG0/1. It will
* also restore HIDs and other SPRs to their original value
* but it might clobber a bunch.
*/
#ifdef __BIG_ENDIAN__
opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
reinit_flags |= OPAL_REINIT_CPUS_HILE_BE;
#else
opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_LE);
reinit_flags |= OPAL_REINIT_CPUS_HILE_LE;
#endif

/*
* POWER9 always support running hash:
* ie. Host hash supports hash guests
* Host radix supports hash/radix guests
*/
if (cpu_has_feature(CPU_FTR_ARCH_300)) {
reinit_flags |= OPAL_REINIT_CPUS_MMU_HASH;
if (early_radix_enabled())
reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX;
}

opal_reinit_cpus(reinit_flags);

/* Restore some bits */
if (cur_cpu_spec->cpu_restore)
cur_cpu_spec->cpu_restore();
Expand Down
11 changes: 10 additions & 1 deletion arch/powerpc/platforms/powernv/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ static void pnv_kexec_wait_secondaries_down(void)

static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
{
u64 reinit_flags;

if (xive_enabled())
xive_kexec_teardown_cpu(secondary);
else
Expand Down Expand Up @@ -254,8 +256,15 @@ static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
* We might be running as little-endian - now that interrupts
* are disabled, reset the HILE bit to big-endian so we don't
* take interrupts in the wrong endian later
*
* We reinit to enable both radix and hash on P9 to ensure
* the mode used by the next kernel is always supported.
*/
opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE);
reinit_flags = OPAL_REINIT_CPUS_HILE_BE;
if (cpu_has_feature(CPU_FTR_ARCH_300))
reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX |
OPAL_REINIT_CPUS_MMU_HASH;
opal_reinit_cpus(reinit_flags);
}
}
#endif /* CONFIG_KEXEC_CORE */
Expand Down

0 comments on commit 1c0eaf0

Please sign in to comment.