]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: PPC: Book3S HV: Read kvm->arch.emul_smt_mode under kvm->lock
authorPaul Mackerras <paulus@ozlabs.org>
Thu, 26 Jul 2018 05:38:41 +0000 (15:38 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Thu, 26 Jul 2018 05:38:41 +0000 (15:38 +1000)
commita51c666e7c0c1f1084222a99ce08c39d5e985b79
tree8f2b60ec1b6dc6462210929f2ede6f3a25f9de63
parent3910d75750b84ae9a980c2c8423f66f954285f6c
KVM: PPC: Book3S HV: Read kvm->arch.emul_smt_mode under kvm->lock

Commit ab691c3 ("KVM: PPC: Book3S HV: Pack VCORE IDs to access full
VCPU ID space", 2018-07-25) added code that uses kvm->arch.emul_smt_mode
before any VCPUs are created.  However, userspace can change
kvm->arch.emul_smt_mode at any time up until the first VCPU is created.
Hence it is (theoretically) possible for the check in
kvmppc_core_vcpu_create_hv() to race with another userspace thread
changing kvm->arch.emul_smt_mode.

This fixes it by moving the test that uses kvm->arch.emul_smt_mode into
the block where kvm->lock is held.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/kvm/book3s_hv.c