ppc/kvm: Skip writing DPDES back when in run time state
commit972bd57689f1e11311d86b290134ea2ed9c7c11e
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 23 Sep 2019 08:41:10 +0000 (23 18:41 +1000)
committerDavid Gibson <david@gibson.dropbear.id.au>
Fri, 4 Oct 2019 00:25:23 +0000 (4 10:25 +1000)
tree70e29813f2eaad2a4e2acbe76071c2741b708335
parent5c94dd3806b6cd4a9540a818ee87c335804bdc38
ppc/kvm: Skip writing DPDES back when in run time state

On POWER8 systems the Directed Privileged Door-bell Exception State
register (DPDES) stores doorbell pending status, one bit per a thread
of a core, set by "msgsndp" instruction. The register is shared among
threads of the same core and KVM on POWER9 emulates it in a similar way
(POWER9 does not have DPDES).

DPDES is shared but QEMU assumes all SPRs are per thread so the only safe
way to write DPDES back to VCPU before running a guest is doing so
while all threads are pulled out of the guest so DPDES cannot change.
There is only one situation when this condition is met: incoming migration
when all threads are stopped. Otherwise any QEMU HMP/QMP command causing
kvm_arch_put_registers() (for example printing registers or dumping memory)
can clobber DPDES in a race with other vcpu threads.

This changes DPDES handling so it is not written to KVM at runtime.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Message-Id: <20190923084110.34643-1-aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
target/ppc/kvm.c
target/ppc/translate_init.inc.c