]> git.proxmox.com Git - mirror_qemu.git/commit
target/ppc: 'PVR != host PVR' in KVM_SET_SREGS workaround
authorDaniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Wed, 9 Aug 2017 20:43:46 +0000 (17:43 -0300)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 22 Aug 2017 11:26:19 +0000 (21:26 +1000)
commitc363a37a450f925df76b88a87dc733bad75cc452
tree61bf56699e90c41ad8786bbe9d884c7822dcf082
parentb96919d765a65f5e0f140479f7da0b94521263c6
target/ppc: 'PVR != host PVR' in KVM_SET_SREGS workaround

Commit d5fc133eed ("ppc: Rework CPU compatibility testing
across migration") changed the way cpu_post_load behaves with
the PVR setting, causing an unexpected bug in KVM-HV migrations
between hosts that are compatible (POWER8 and POWER8E, for example).
Even with pvr_match() returning true, the guest freezes right after
cpu_post_load. The reason is that the guest kernel can't handle a
different PVR value other that the running host in KVM_SET_SREGS.

In [1] it was discussed the possibility of a new KVM capability
that would indicate that the guest kernel can handle a different
PVR in KVM_SET_SREGS. Even if such feature is implemented, there is
still the problem with older kernels that will not have this capability
and will fail to migrate.

This patch implements a workaround for that scenario. If running
with KVM, check if the guest kernel does not have the capability
(named here as 'cap_ppc_pvr_compat'). If it doesn't, calls
kvmppc_is_pr() to see if the guest is running in KVM-HV. If all this
happens, set env->spr[SPR_PVR] to the same value as the current
host PVR. This ensures that we allow migrations with 'close enough'
PVRs to still work in KVM-HV but also makes the code ready for
this new KVM capability when it is done.

A new function called 'kvmppc_pvr_workaround_required' was created
to encapsulate the conditions said above and to avoid calling too
many kvm.c internals inside cpu_post_load.

[1] https://lists.gnu.org/archive/html/qemu-ppc/2017-06/msg00503.html

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
[dwg: Fix for the case of using TCG on a PPC host]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
target/ppc/kvm.c
target/ppc/kvm_ppc.h
target/ppc/machine.c