Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: PPC: Book3S: Take the kvm->srcu lock in kvmppc_h_logical_ci_load/store()

Access to the kvm->buses (like with the kvm_io_bus_read() and -write()
functions) has to be protected via the kvm->srcu lock.
The kvmppc_h_logical_ci_load() and -store() functions are missing
this lock so far, so let's add it there, too.
This fixes the problem that the kernel reports "suspicious RCU usage"
when lock debugging is enabled.

Cc: stable@vger.kernel.org # v4.1+
Fixes: 99342cf8044420eebdf9297ca03a14cb6a7085a1
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Thomas Huth and committed by
Paul Mackerras
3eb4ee68 7e022e71

+6
+6
arch/powerpc/kvm/book3s.c
··· 829 829 unsigned long size = kvmppc_get_gpr(vcpu, 4); 830 830 unsigned long addr = kvmppc_get_gpr(vcpu, 5); 831 831 u64 buf; 832 + int srcu_idx; 832 833 int ret; 833 834 834 835 if (!is_power_of_2(size) || (size > sizeof(buf))) 835 836 return H_TOO_HARD; 836 837 838 + srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); 837 839 ret = kvm_io_bus_read(vcpu, KVM_MMIO_BUS, addr, size, &buf); 840 + srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx); 838 841 if (ret != 0) 839 842 return H_TOO_HARD; 840 843 ··· 872 869 unsigned long addr = kvmppc_get_gpr(vcpu, 5); 873 870 unsigned long val = kvmppc_get_gpr(vcpu, 6); 874 871 u64 buf; 872 + int srcu_idx; 875 873 int ret; 876 874 877 875 switch (size) { ··· 896 892 return H_TOO_HARD; 897 893 } 898 894 895 + srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); 899 896 ret = kvm_io_bus_write(vcpu, KVM_MMIO_BUS, addr, size, &buf); 897 + srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx); 900 898 if (ret != 0) 901 899 return H_TOO_HARD; 902 900