spapr: Set compat mode in spapr_core_plug()
commitb1e815674343a171e51ce447495957e289091e9f
authorGreg Kurz <groug@kaod.org>
Wed, 28 Aug 2019 17:20:53 +0000 (28 19:20 +0200)
committerDavid Gibson <david@gibson.dropbear.id.au>
Wed, 28 Aug 2019 23:46:07 +0000 (29 09:46 +1000)
tree82be3b48c5c5a772d0fa0a4adde4acf5141bd28c
parent572ebd08b3c343bd692b816e622b2b511088a346
spapr: Set compat mode in spapr_core_plug()

A recent change in spapr_machine_reset() showed that resetting the compat
mode in spapr_machine_reset() for the boot vCPU and in spapr_cpu_reset()
for all other vCPUs was fragile. The fix was thus to reset the compat mode
for all vCPUs in spapr_machine_reset(), but we still have to propagate
it to hot-plugged CPUs. This is still performed from spapr_cpu_reset(),
hence resulting in ppc_set_compat() being called twice for every vCPU at
machine reset. Apart from wasting cycles, which isn't really an issue
during machine reset, this seems to indicate that spapr_cpu_reset() isn't
the best place to set the compat mode.

A natural candidate for CPU-hotplug specific code is spapr_core_plug().
Also, it sits in the same file as spapr_machine_reset() : this makes
it easier for someone who wants to know when the compat PVR is set.

Call ppc_set_compat() from there. This doesn't need to be done for
initial vCPUs since the compat PVR is 0 and spapr_machine_reset() sets
the appropriate value later. No need to do this on manually added vCPUS
on the destination QEMU during migration since the compat PVR is
part of the migrated vCPU state. Both conditions can be checked with
spapr_drc_hotplugged().

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <156701285312.499757.7807417667750711711.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/spapr.c
hw/ppc/spapr_cpu_core.c