diff options
author | Thomas Huth <thuth@linux.vnet.ibm.com> | 2013-09-12 10:33:45 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2013-09-24 19:12:19 +0200 |
commit | 800c1065c3207a1b04d4ac457a57a37ce19eeb21 (patch) | |
tree | 62d1230e8b487587110150dc4a26c3157a23877c /arch/s390/kvm/kvm-s390.c | |
parent | a76ccff6f5ed89153bf58ef4215b5512a0316877 (diff) | |
download | op-kernel-dev-800c1065c3207a1b04d4ac457a57a37ce19eeb21.zip op-kernel-dev-800c1065c3207a1b04d4ac457a57a37ce19eeb21.tar.gz |
KVM: s390: Lock kvm->srcu at the appropriate places
The kvm->srcu lock has to be held while accessing the memory of
guests and during certain other actions. This patch now adds
the locks to the __vcpu_run function so that all affected code
is protected now (and additionally to the KVM_S390_STORE_STATUS
ioctl, which can be called out-of-band and needs a separate lock).
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/s390/kvm/kvm-s390.c')
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 8eec7ab..1e4e7b9 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -752,11 +752,18 @@ static int __vcpu_run(struct kvm_vcpu *vcpu) { int rc, exit_reason; + /* + * We try to hold kvm->srcu during most of vcpu_run (except when run- + * ning the guest), so that memslots (and other stuff) are protected + */ + vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); + do { rc = vcpu_pre_run(vcpu); if (rc) break; + srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); /* * As PF_VCPU will be used in fault handler, between * guest_enter and guest_exit should be no uaccess. @@ -767,10 +774,12 @@ static int __vcpu_run(struct kvm_vcpu *vcpu) exit_reason = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs); kvm_guest_exit(); + vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); rc = vcpu_post_run(vcpu, exit_reason); } while (!signal_pending(current) && !rc); + srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); return rc; } @@ -968,6 +977,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp, { struct kvm_vcpu *vcpu = filp->private_data; void __user *argp = (void __user *)arg; + int idx; long r; switch (ioctl) { @@ -981,7 +991,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp, break; } case KVM_S390_STORE_STATUS: + idx = srcu_read_lock(&vcpu->kvm->srcu); r = kvm_s390_vcpu_store_status(vcpu, arg); + srcu_read_unlock(&vcpu->kvm->srcu, idx); break; case KVM_S390_SET_INITIAL_PSW: { psw_t psw; |