aboutsummaryrefslogtreecommitdiff
path: root/target/ppc/machine.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-06-30 11:58:49 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-06-30 11:58:49 +0100
commit36f87b4513373b3cd79c87c9197d17face95d4ac (patch)
treeac88202439e0536371e015f72bd01a1692dde701 /target/ppc/machine.c
parentc5eb5846d2d207bbde7f4b665d9ff90b92c8adff (diff)
parent0dfabd39d523fc3f6f0f8c441f41c013cc429b52 (diff)
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.10-20170630' into staging
ppc patch queue 2017-06-30 * More DRC cleanups, these now actually fix a few bugs * Properly implements the openpic timers (they now count and generate interrupts) * Fixes for XICS migration * Fixes for migration of POWER9 RPT guests * The last of the compatibility mode rework # gpg: Signature made Fri 30 Jun 2017 10:52:25 BST # gpg: using RSA key 0x6C38CACA20D9B392 # gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>" # gpg: aka "David Gibson (Red Hat) <dgibson@redhat.com>" # gpg: aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>" # gpg: aka "David Gibson (kernel.org) <dwg@kernel.org>" # Primary key fingerprint: 75F4 6586 AE61 A66C C44E 87DC 6C38 CACA 20D9 B392 * remotes/dgibson/tags/ppc-for-2.10-20170630: (21 commits) spapr: Clean up DRC set_isolation_state() path spapr: Clean up DRC set_allocation_state path spapr: Make DRC reset force DRC into known state spapr: Split DRC release from DRC detach spapr: Eliminate DRC 'signalled' state variable spapr: Start hotplugged PCI devices in ISOLATED state target-ppc: Enable open-pic timers to count and generate interrupts hw/ppc/spapr.c: consecutive 'spapr->patb_entry = 0' statements spapr: prevent QEMU crash when CPU realization fails target/ppc: Proper cleanup when ppc_cpu_realizefn fails spapr: fix migration of ICPState objects from/to older QEMU xics: directly register ICPState objects to vmstate target/ppc: Fix return value in tcg radix mmu fault handler target/ppc/excp_helper: Take BQL before calling cpu_interrupt() spapr: Fix migration of Radix guests spapr: Add a "no HPT" encoding to HTAB migration stream ppc: Rework CPU compatibility testing across migration pseries: Reset CPU compatibility mode pseries: Move CPU compatibility property to machine qapi: add explicit null to string input and output visitors ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'target/ppc/machine.c')
-rw-r--r--target/ppc/machine.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/target/ppc/machine.c b/target/ppc/machine.c
index 445f489bd0..f578156dd4 100644
--- a/target/ppc/machine.c
+++ b/target/ppc/machine.c
@@ -8,6 +8,7 @@
#include "helper_regs.h"
#include "mmu-hash64.h"
#include "migration/cpu.h"
+#include "qapi/error.h"
static int cpu_load_old(QEMUFile *f, void *opaque, int version_id)
{
@@ -195,6 +196,27 @@ static void cpu_pre_save(void *opaque)
}
}
+/*
+ * Determine if a given PVR is a "close enough" match to the CPU
+ * object. For TCG and KVM PR it would probably be sufficient to
+ * require an exact PVR match. However for KVM HV the user is
+ * restricted to a PVR exactly matching the host CPU. The correct way
+ * to handle this is to put the guest into an architected
+ * compatibility mode. However, to allow a more forgiving transition
+ * and migration from before this was widely done, we allow migration
+ * between sufficiently similar PVRs, as determined by the CPU class's
+ * pvr_match() hook.
+ */
+static bool pvr_match(PowerPCCPU *cpu, uint32_t pvr)
+{
+ PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+ if (pvr == pcc->pvr) {
+ return true;
+ }
+ return pcc->pvr_match(pcc, pvr);
+}
+
static int cpu_post_load(void *opaque, int version_id)
{
PowerPCCPU *cpu = opaque;
@@ -203,10 +225,31 @@ static int cpu_post_load(void *opaque, int version_id)
target_ulong msr;
/*
- * We always ignore the source PVR. The user or management
- * software has to take care of running QEMU in a compatible mode.
+ * If we're operating in compat mode, we should be ok as long as
+ * the destination supports the same compatiblity mode.
+ *
+ * Otherwise, however, we require that the destination has exactly
+ * the same CPU model as the source.
*/
- env->spr[SPR_PVR] = env->spr_cb[SPR_PVR].default_value;
+
+#if defined(TARGET_PPC64)
+ if (cpu->compat_pvr) {
+ Error *local_err = NULL;
+
+ ppc_set_compat(cpu, cpu->compat_pvr, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ error_free(local_err);
+ return -1;
+ }
+ } else
+#endif
+ {
+ if (!pvr_match(cpu, env->spr[SPR_PVR])) {
+ return -1;
+ }
+ }
+
env->lr = env->spr[SPR_LR];
env->ctr = env->spr[SPR_CTR];
cpu_write_xer(env, env->spr[SPR_XER]);
@@ -560,6 +603,25 @@ static const VMStateDescription vmstate_tlbmas = {
}
};
+static bool compat_needed(void *opaque)
+{
+ PowerPCCPU *cpu = opaque;
+
+ assert(!(cpu->compat_pvr && !cpu->vhyp));
+ return !cpu->pre_2_10_migration && cpu->compat_pvr != 0;
+}
+
+static const VMStateDescription vmstate_compat = {
+ .name = "cpu/compat",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = compat_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT32(compat_pvr, PowerPCCPU),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
const VMStateDescription vmstate_ppc_cpu = {
.name = "cpu",
.version_id = 5,
@@ -613,6 +675,7 @@ const VMStateDescription vmstate_ppc_cpu = {
&vmstate_tlb6xx,
&vmstate_tlbemb,
&vmstate_tlbmas,
+ &vmstate_compat,
NULL
}
};