]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
powerpc/powernv: Tell OPAL about our MMU mode on POWER9
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 30 Jun 2017 22:37:32 +0000 (17:37 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 17 Jul 2017 14:54:37 +0000 (16:54 +0200)
BugLink: http://bugs.launchpad.net/bugs/1702159
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>
(cherry picked from 1c0eaf0f56d6128af7f0f252855173fcee85d202)
Signed-off-by: Breno Leitao <leitao@debian.org>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
arch/powerpc/include/asm/opal-api.h
arch/powerpc/platforms/powernv/opal.c
arch/powerpc/platforms/powernv/setup.c

index cb3e6242a78c51794e8d61e2a68e6621af8f549d..85e6d8817fd1411991e5632eeaad1238307349ae 100644 (file)
@@ -805,6 +805,15 @@ struct OpalIoPhb3ErrorData {
 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 {
index e0f856bfbfe8f3c6ecfa70e737b1b2496725d563..142ddc61bae281200227f390d1ae564184674220 100644 (file)
@@ -59,6 +59,8 @@ 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
@@ -66,11 +68,24 @@ void opal_configure_cores(void)
         * 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();
index adceac978d18625c36bfdc487c8c35fb9f44d7f2..41add28943935a18bf53d6a231eecd7914509128 100644 (file)
@@ -221,6 +221,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
@@ -250,8 +252,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 */