diff options
author | Paul Mackerras <paulus@ozlabs.org> | 2017-09-11 02:05:30 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@ozlabs.org> | 2017-09-12 02:02:27 -0400 |
commit | cf5f6f3125241853462334b1bc696f3c3c492178 (patch) | |
tree | 4108b0c8c4d6bab9772d8ff03f20461aa1887385 | |
parent | d222af072380c4470295c07d84ecb15f4937e365 (diff) |
KVM: PPC: Book3S HV: Hold kvm->lock around call to kvmppc_update_lpcr
Commit 468808bd35c4 ("KVM: PPC: Book3S HV: Set process table for HPT
guests on POWER9", 2017-01-30) added a call to kvmppc_update_lpcr()
which doesn't hold the kvm->lock mutex around the call, as required.
This adds the lock/unlock pair, and for good measure, includes
the kvmppc_setup_partition_table() call in the locked region, since
it is altering global state of the VM.
This error appears not to have any fatal consequences for the host;
the consequences would be that the VCPUs could end up running with
different LPCR values, or an update to the LPCR value by userspace
using the one_reg interface could get overwritten, or the update
done by kvmhv_configure_mmu() could get overwritten.
Cc: stable@vger.kernel.org # v4.10+
Fixes: 468808bd35c4 ("KVM: PPC: Book3S HV: Set process table for HPT guests on POWER9")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
-rw-r--r-- | arch/powerpc/kvm/book3s_hv.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 18e974a34fce..a7177c284f9b 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c | |||
@@ -4212,11 +4212,13 @@ static int kvmhv_configure_mmu(struct kvm *kvm, struct kvm_ppc_mmuv3_cfg *cfg) | |||
4212 | if ((cfg->process_table & PRTS_MASK) > 24) | 4212 | if ((cfg->process_table & PRTS_MASK) > 24) |
4213 | return -EINVAL; | 4213 | return -EINVAL; |
4214 | 4214 | ||
4215 | mutex_lock(&kvm->lock); | ||
4215 | kvm->arch.process_table = cfg->process_table; | 4216 | kvm->arch.process_table = cfg->process_table; |
4216 | kvmppc_setup_partition_table(kvm); | 4217 | kvmppc_setup_partition_table(kvm); |
4217 | 4218 | ||
4218 | lpcr = (cfg->flags & KVM_PPC_MMUV3_GTSE) ? LPCR_GTSE : 0; | 4219 | lpcr = (cfg->flags & KVM_PPC_MMUV3_GTSE) ? LPCR_GTSE : 0; |
4219 | kvmppc_update_lpcr(kvm, lpcr, LPCR_GTSE); | 4220 | kvmppc_update_lpcr(kvm, lpcr, LPCR_GTSE); |
4221 | mutex_unlock(&kvm->lock); | ||
4220 | 4222 | ||
4221 | return 0; | 4223 | return 0; |
4222 | } | 4224 | } |