• Paul Mackerras's avatar
    KVM: PPC: Book3S HV: Read kvm->arch.emul_smt_mode under kvm->lock · b5c6f760
    Paul Mackerras authored
    Commit 1e175d2e ("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: default avatarPaul Mackerras <paulus@ozlabs.org>
    b5c6f760
book3s_hv.c 119 KB