spapr: harden code that depends on VSMT
commit1a5008fc17fe3d286baa6d07b5cce122553968e7
authorGreg Kurz <groug@kaod.org>
Tue, 27 Feb 2018 15:23:07 +0000 (27 16:23 +0100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 6 Mar 2018 02:16:29 +0000 (6 13:16 +1100)
tree8bda77fecd410828c588cb4df6b03625f7758ff2
parent72fdd4de8e5fdc1a6078e000835fb54592a3fe97
spapr: harden code that depends on VSMT

VSMT must be set in order to compute VCPU ids. This means that the
following functions must not be called before spapr_set_vsmt_mode()
was called:
- spapr_vcpu_id()
- spapr_is_thread0_in_vcore()
- xics_max_server_number()

We had a recent regression where the latter would be called before VSMT
was set, and broke migration of some old machine types. This patch
adds assert() in the above functions to avoid problems in the future.

Also, since VSMT is really a CPU related thing, spapr_set_vsmt_mode() is
now called from spapr_init_cpus(), just before the first VSMT user.

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/spapr.c