OSDN Git Service

KVM: PPC: Book3S HV: Don't try to signal cpu -1
authorPaul Mackerras <paulus@ozlabs.org>
Tue, 20 Dec 2016 03:02:29 +0000 (14:02 +1100)
committerPaul Mackerras <paulus@ozlabs.org>
Thu, 26 Jan 2017 21:58:34 +0000 (08:58 +1100)
commit3deda5e50c893be38c1b6b3a73f8f8fb5560baa4
treecd251fd90ac8f50ee4d9b8a5f10dcda19b9c4045
parenta17f32270af1e1054bbc8858b0f27226a2c859ba
KVM: PPC: Book3S HV: Don't try to signal cpu -1

If the target vcpu for kvmppc_fast_vcpu_kick_hv() is not running on
any CPU, then we will have vcpu->arch.thread_cpu == -1, and as it
happens, kvmppc_fast_vcpu_kick_hv will call kvmppc_ipi_thread with
-1 as the cpu argument.  Although this is not meaningful, in the past,
before commit 1704a81ccebc ("KVM: PPC: Book3S HV: Use msgsnd for IPIs
to other cores on POWER9", 2016-11-18), it was harmless because CPU
-1 is not in the same core as any real CPU thread.  On a POWER9,
however, we don't do the "same core" check, so we were trying to
do a msgsnd to thread -1, which is invalid.  To avoid this, we add
a check to see that vcpu->arch.thread_cpu is >= 0 before calling
kvmppc_ipi_thread() with it.  Since vcpu->arch.thread_vcpu can change
asynchronously, we use READ_ONCE to ensure that the value we check is
the same value that we use as the argument to kvmppc_ipi_thread().

Fixes: 1704a81ccebc ("KVM: PPC: Book3S HV: Use msgsnd for IPIs to other cores on POWER9")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/kvm/book3s_hv.c