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