Blame SOURCES/kvm-spapr-don-t-initialize-PATB-entry-if-max-cpu-compat-.patch

9bac43
From 19ab0de29b4a853622fbccccf957f6a2c44466f3 Mon Sep 17 00:00:00 2001
9bac43
From: Laurent Vivier <lvivier@redhat.com>
9bac43
Date: Tue, 19 Dec 2017 10:42:36 +0100
9bac43
Subject: [PATCH 01/42] spapr: don't initialize PATB entry if max-cpu-compat <
9bac43
 power9
9bac43
9bac43
RH-Author: Laurent Vivier <lvivier@redhat.com>
9bac43
Message-id: <20171219104236.22556-1-lvivier@redhat.com>
9bac43
Patchwork-id: 78413
9bac43
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH] spapr: don't initialize PATB entry if max-cpu-compat < power9
9bac43
Bugzilla: 1525866
9bac43
RH-Acked-by: David Gibson <dgibson@redhat.com>
9bac43
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9bac43
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
9bac43
9bac43
BZ:     https://bugzilla.redhat.com/show_bug.cgi?id=1525866
9bac43
BREW:   https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=14815605
9bac43
        s390x build is broken (binutils is missing), build only the others
9bac43
Tested: I tested this patch with upstream QEMU.
9bac43
        As it is difficult to have a P9 host in beaker to check migration
9bac43
        to P8 host, I didn't re-test it with downstream build
9bac43
        (but I have asked QE to do)
9bac43
9bac43
if KVM is enabled and KVM capabilities MMU radix is available,
9bac43
the partition table entry (patb_entry) for the radix mode is
9bac43
initialized by default in ppc_spapr_reset().
9bac43
9bac43
It's a problem if we want to migrate the guest to a POWER8 host
9bac43
while the kernel is not started to set the value to the one
9bac43
expected for a POWER8 CPU.
9bac43
9bac43
The "-machine max-cpu-compat=power8" should allow to migrate
9bac43
a POWER9 KVM host to a POWER8 KVM host, but because patb_entry
9bac43
is set, the destination QEMU tries to enable radix mode on the
9bac43
POWER8 host. This fails and cancels the migration:
9bac43
9bac43
    Process table config unsupported by the host
9bac43
    error while loading state for instance 0x0 of device 'spapr'
9bac43
    load of migration failed: Invalid argument
9bac43
9bac43
This patch doesn't set the PATB entry if the user provides
9bac43
a CPU compatibility mode that doesn't support radix mode.
9bac43
9bac43
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
9bac43
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
9bac43
(cherry picked from commit 1481fe5fcfeb7fcf3c1ebb9d8c0432e3e0188ccf)
9bac43
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 hw/ppc/spapr.c | 6 ++++--
9bac43
 1 file changed, 4 insertions(+), 2 deletions(-)
9bac43
9bac43
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
9bac43
index af7a3bb..d320b6c 100644
9bac43
--- a/hw/ppc/spapr.c
9bac43
+++ b/hw/ppc/spapr.c
9bac43
@@ -1424,7 +1424,10 @@ static void ppc_spapr_reset(void)
9bac43
     /* Check for unknown sysbus devices */
9bac43
     foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);
9bac43
 
9bac43
-    if (kvm_enabled() && kvmppc_has_cap_mmu_radix()) {
9bac43
+    first_ppc_cpu = POWERPC_CPU(first_cpu);
9bac43
+    if (kvm_enabled() && kvmppc_has_cap_mmu_radix() &&
9bac43
+        ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0,
9bac43
+                         spapr->max_compat_pvr)) {
9bac43
         /* If using KVM with radix mode available, VCPUs can be started
9bac43
          * without a HPT because KVM will start them in radix mode.
9bac43
          * Set the GR bit in PATB so that we know there is no HPT. */
9bac43
@@ -1483,7 +1486,6 @@ static void ppc_spapr_reset(void)
9bac43
     g_free(fdt);
9bac43
 
9bac43
     /* Set up the entry state */
9bac43
-    first_ppc_cpu = POWERPC_CPU(first_cpu);
9bac43
     first_ppc_cpu->env.gpr[3] = fdt_addr;
9bac43
     first_ppc_cpu->env.gpr[5] = 0;
9bac43
     first_cpu->halted = 0;
9bac43
-- 
9bac43
1.8.3.1
9bac43