Merge tag 'iwlwifi-next-for-kalle-2014-12-30' of https://git.kernel.org/pub/scm/linux...
[cascardo/linux.git] / arch / s390 / kvm / gaccess.c
index 6dc0ad9..8a1be90 100644 (file)
@@ -207,8 +207,6 @@ union raddress {
        unsigned long pfra : 52; /* Page-Frame Real Address */
 };
 
-static int ipte_lock_count;
-static DEFINE_MUTEX(ipte_mutex);
 
 int ipte_lock_held(struct kvm_vcpu *vcpu)
 {
@@ -216,51 +214,48 @@ int ipte_lock_held(struct kvm_vcpu *vcpu)
 
        if (vcpu->arch.sie_block->eca & 1)
                return ic->kh != 0;
-       return ipte_lock_count != 0;
+       return vcpu->kvm->arch.ipte_lock_count != 0;
 }
 
 static void ipte_lock_simple(struct kvm_vcpu *vcpu)
 {
        union ipte_control old, new, *ic;
 
-       mutex_lock(&ipte_mutex);
-       ipte_lock_count++;
-       if (ipte_lock_count > 1)
+       mutex_lock(&vcpu->kvm->arch.ipte_mutex);
+       vcpu->kvm->arch.ipte_lock_count++;
+       if (vcpu->kvm->arch.ipte_lock_count > 1)
                goto out;
        ic = &vcpu->kvm->arch.sca->ipte_control;
        do {
-               old = *ic;
-               barrier();
+               old = READ_ONCE(*ic);
                while (old.k) {
                        cond_resched();
-                       old = *ic;
-                       barrier();
+                       old = READ_ONCE(*ic);
                }
                new = old;
                new.k = 1;
        } while (cmpxchg(&ic->val, old.val, new.val) != old.val);
 out:
-       mutex_unlock(&ipte_mutex);
+       mutex_unlock(&vcpu->kvm->arch.ipte_mutex);
 }
 
 static void ipte_unlock_simple(struct kvm_vcpu *vcpu)
 {
        union ipte_control old, new, *ic;
 
-       mutex_lock(&ipte_mutex);
-       ipte_lock_count--;
-       if (ipte_lock_count)
+       mutex_lock(&vcpu->kvm->arch.ipte_mutex);
+       vcpu->kvm->arch.ipte_lock_count--;
+       if (vcpu->kvm->arch.ipte_lock_count)
                goto out;
        ic = &vcpu->kvm->arch.sca->ipte_control;
        do {
-               old = *ic;
-               barrier();
+               old = READ_ONCE(*ic);
                new = old;
                new.k = 0;
        } while (cmpxchg(&ic->val, old.val, new.val) != old.val);
        wake_up(&vcpu->kvm->arch.ipte_wq);
 out:
-       mutex_unlock(&ipte_mutex);
+       mutex_unlock(&vcpu->kvm->arch.ipte_mutex);
 }
 
 static void ipte_lock_siif(struct kvm_vcpu *vcpu)
@@ -269,12 +264,10 @@ static void ipte_lock_siif(struct kvm_vcpu *vcpu)
 
        ic = &vcpu->kvm->arch.sca->ipte_control;
        do {
-               old = *ic;
-               barrier();
+               old = READ_ONCE(*ic);
                while (old.kg) {
                        cond_resched();
-                       old = *ic;
-                       barrier();
+                       old = READ_ONCE(*ic);
                }
                new = old;
                new.k = 1;
@@ -288,8 +281,7 @@ static void ipte_unlock_siif(struct kvm_vcpu *vcpu)
 
        ic = &vcpu->kvm->arch.sca->ipte_control;
        do {
-               old = *ic;
-               barrier();
+               old = READ_ONCE(*ic);
                new = old;
                new.kh--;
                if (!new.kh)