kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Carsten Otte <cotte@de.ibm.com>,
	Jens Freimann <jfrei@linux.vnet.ibm.com>
Cc: Avi Kivity <avi@redhat.com>,
	Marcelo Tossati <mtosatti@redhat.com>,
	Alexander Graf <agraf@suse.de>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	KVM <kvm@vger.kernel.org>
Subject: Re: [PATCH 3/6] kvm-s390: make sigp restart return busy when stop pending
Date: Mon, 06 Feb 2012 14:08:21 +0100	[thread overview]
Message-ID: <4F2FD0C5.8050205@de.ibm.com> (raw)
In-Reply-To: <4F2FBF46.2090604@de.ibm.com>

On 06/02/12 12:53, Carsten Otte wrote:
> Am 06.02.2012 10:59, schrieb Christian Borntraeger:
>> +static int __sigp_restart(struct kvm_vcpu *vcpu, u16 cpu_addr)
>> +{
>> +    int rc = 0;
>> +    struct kvm_s390_float_interrupt *fi =&vcpu->kvm->arch.float_int;
>> +
>> +    spin_lock(&fi->lock);
>> +    if (fi->local_int[cpu_addr]->action_bits&  ACTION_STOP_ON_STOP)
>> +        rc = 2; /* busy */
>> +    else
>> +        VCPU_EVENT(vcpu, 4, "sigp restart %x to handle userspace",
>> +            cpu_addr);
>> +    spin_unlock(&fi->lock);
>> +
>> +    return rc;
>> +}
>>
> local_int->action_bits is protected by the local int lock of subject CPU,
> as one can see in patch #2 of this series. This is racy.

Indeed the inner lock is missing (something like the addon-patch below)
Jens, can you update and test the patch accordingly?

--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -316,13 +316,26 @@ static int __sigp_restart(struct kvm_vcpu *vcpu, u16 cpu_addr)
 {
        int rc = 0;
        struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
+       struct kvm_s390_local_interrupt *li;
+
+       if (cpu_addr >= KVM_MAX_VCPUS)
+               return 3; /* not operational */
 
        spin_lock(&fi->lock);
-       if (fi->local_int[cpu_addr]->action_bits & ACTION_STOP_ON_STOP)
+       li = fi->local_int[cpu_addr];
+       if (li == NULL) {
+               rc = 3; /* not operational */
+               goto out;
+       }
+
+       spin_lock_bh(&li->lock);
+       if (li->action_bits & ACTION_STOP_ON_STOP)
                rc = 2; /* busy */
        else
                VCPU_EVENT(vcpu, 4, "sigp restart %x to handle userspace",
                        cpu_addr);
+       spin_unlock_bh(&li->lock);
+out:
        spin_unlock(&fi->lock);
 
        return rc;




Christian


  reply	other threads:[~2012-02-06 13:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-06  9:59 [PATCH 0/6] Fixes for kvm on s390 Christian Borntraeger
2012-02-06  9:59 ` [PATCH 1/6] kvm-s390: Sanitize fpc registers for KVM_SET_FPU Christian Borntraeger
2012-02-06  9:59 ` [PATCH 2/6] kvm-s390: do store status after handling STOP_ON_STOP bit Christian Borntraeger
2012-02-06  9:59 ` [PATCH 3/6] kvm-s390: make sigp restart return busy when stop pending Christian Borntraeger
2012-02-06 11:53   ` Carsten Otte
2012-02-06 13:08     ` Christian Borntraeger [this message]
2012-02-08  7:28   ` Fixed restart patch Christian Borntraeger
2012-02-08  7:28     ` [PATCH 3/6 v2] kvm-s390: make sigp restart return busy when stop pending Christian Borntraeger
2012-02-06  9:59 ` [PATCH 4/6] kvm-s390: ignore sigp stop overinitiative Christian Borntraeger
2012-02-06  9:59 ` [PATCH 5/6] kvm-s390: add stop_on_stop flag when doing stop and store Christian Borntraeger
2012-02-06  9:59 ` [PATCH 6/6] kvm-s390: provide control registers via kvm_run Christian Borntraeger
2012-02-08 17:44 ` [PATCH 0/6] Fixes for kvm on s390 Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F2FD0C5.8050205@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=cotte@de.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=schwidefsky@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).