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

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