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

Configure Feed

Select the types of activity you want to include in your feed.

KVM: S390: Remove sca_lock

Since we are no longer switching from a BSCA to a ESCA we can completely
get rid of the sca_lock. The write lock was only taken for that
conversion.

After removal of the lock some local code cleanups are possible.

Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Suggested-by: Janosch Frank <frankja@linux.ibm.com>
[frankja@linux.ibm.com: Added suggested-by tag as discussed on list]
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

authored by

Christoph Schlameuss and committed by
Janosch Frank
14542a0a e72753ed

+20 -70
-1
arch/s390/include/asm/kvm_host.h
··· 633 633 634 634 struct kvm_arch { 635 635 struct esca_block *sca; 636 - rwlock_t sca_lock; 637 636 debug_info_t *dbf; 638 637 struct kvm_s390_float_interrupt float_int; 639 638 struct kvm_device *flic;
+2 -17
arch/s390/kvm/gaccess.c
··· 109 109 110 110 int ipte_lock_held(struct kvm *kvm) 111 111 { 112 - if (sclp.has_siif) { 113 - int rc; 112 + if (sclp.has_siif) 113 + return kvm->arch.sca->ipte_control.kh != 0; 114 114 115 - read_lock(&kvm->arch.sca_lock); 116 - rc = kvm->arch.sca->ipte_control.kh != 0; 117 - read_unlock(&kvm->arch.sca_lock); 118 - return rc; 119 - } 120 115 return kvm->arch.ipte_lock_count != 0; 121 116 } 122 117 ··· 124 129 if (kvm->arch.ipte_lock_count > 1) 125 130 goto out; 126 131 retry: 127 - read_lock(&kvm->arch.sca_lock); 128 132 ic = &kvm->arch.sca->ipte_control; 129 133 old = READ_ONCE(*ic); 130 134 do { 131 135 if (old.k) { 132 - read_unlock(&kvm->arch.sca_lock); 133 136 cond_resched(); 134 137 goto retry; 135 138 } 136 139 new = old; 137 140 new.k = 1; 138 141 } while (!try_cmpxchg(&ic->val, &old.val, new.val)); 139 - read_unlock(&kvm->arch.sca_lock); 140 142 out: 141 143 mutex_unlock(&kvm->arch.ipte_mutex); 142 144 } ··· 146 154 kvm->arch.ipte_lock_count--; 147 155 if (kvm->arch.ipte_lock_count) 148 156 goto out; 149 - read_lock(&kvm->arch.sca_lock); 150 157 ic = &kvm->arch.sca->ipte_control; 151 158 old = READ_ONCE(*ic); 152 159 do { 153 160 new = old; 154 161 new.k = 0; 155 162 } while (!try_cmpxchg(&ic->val, &old.val, new.val)); 156 - read_unlock(&kvm->arch.sca_lock); 157 163 wake_up(&kvm->arch.ipte_wq); 158 164 out: 159 165 mutex_unlock(&kvm->arch.ipte_mutex); ··· 162 172 union ipte_control old, new, *ic; 163 173 164 174 retry: 165 - read_lock(&kvm->arch.sca_lock); 166 175 ic = &kvm->arch.sca->ipte_control; 167 176 old = READ_ONCE(*ic); 168 177 do { 169 178 if (old.kg) { 170 - read_unlock(&kvm->arch.sca_lock); 171 179 cond_resched(); 172 180 goto retry; 173 181 } ··· 173 185 new.k = 1; 174 186 new.kh++; 175 187 } while (!try_cmpxchg(&ic->val, &old.val, new.val)); 176 - read_unlock(&kvm->arch.sca_lock); 177 188 } 178 189 179 190 static void ipte_unlock_siif(struct kvm *kvm) 180 191 { 181 192 union ipte_control old, new, *ic; 182 193 183 - read_lock(&kvm->arch.sca_lock); 184 194 ic = &kvm->arch.sca->ipte_control; 185 195 old = READ_ONCE(*ic); 186 196 do { ··· 187 201 if (!new.kh) 188 202 new.k = 0; 189 203 } while (!try_cmpxchg(&ic->val, &old.val, new.val)); 190 - read_unlock(&kvm->arch.sca_lock); 191 204 if (!new.kh) 192 205 wake_up(&kvm->arch.ipte_wq); 193 206 }
+9 -27
arch/s390/kvm/interrupt.c
··· 45 45 /* handle external calls via sigp interpretation facility */ 46 46 static int sca_ext_call_pending(struct kvm_vcpu *vcpu, int *src_id) 47 47 { 48 - union esca_sigp_ctrl sigp_ctrl; 49 - struct esca_block *sca; 50 - int c, scn; 48 + struct esca_block *sca = vcpu->kvm->arch.sca; 49 + union esca_sigp_ctrl sigp_ctrl = sca->cpu[vcpu->vcpu_id].sigp_ctrl; 51 50 52 51 if (!kvm_s390_test_cpuflags(vcpu, CPUSTAT_ECALL_PEND)) 53 52 return 0; 54 53 55 54 BUG_ON(!kvm_s390_use_sca_entries()); 56 - read_lock(&vcpu->kvm->arch.sca_lock); 57 - sca = vcpu->kvm->arch.sca; 58 - sigp_ctrl = sca->cpu[vcpu->vcpu_id].sigp_ctrl; 59 - 60 - c = sigp_ctrl.c; 61 - scn = sigp_ctrl.scn; 62 - read_unlock(&vcpu->kvm->arch.sca_lock); 63 55 64 56 if (src_id) 65 - *src_id = scn; 57 + *src_id = sigp_ctrl.scn; 66 58 67 - return c; 59 + return sigp_ctrl.c; 68 60 } 69 61 70 62 static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id) 71 63 { 72 - union esca_sigp_ctrl old_val, new_val = {0}; 73 - union esca_sigp_ctrl *sigp_ctrl; 74 - struct esca_block *sca; 64 + struct esca_block *sca = vcpu->kvm->arch.sca; 65 + union esca_sigp_ctrl *sigp_ctrl = &sca->cpu[vcpu->vcpu_id].sigp_ctrl; 66 + union esca_sigp_ctrl old_val, new_val = {.scn = src_id, .c = 1}; 75 67 int expect, rc; 76 68 77 69 BUG_ON(!kvm_s390_use_sca_entries()); 78 - read_lock(&vcpu->kvm->arch.sca_lock); 79 - sca = vcpu->kvm->arch.sca; 80 - sigp_ctrl = &sca->cpu[vcpu->vcpu_id].sigp_ctrl; 81 70 82 71 old_val = READ_ONCE(*sigp_ctrl); 83 - new_val.scn = src_id; 84 - new_val.c = 1; 85 72 old_val.c = 0; 86 73 87 74 expect = old_val.value; 88 75 rc = cmpxchg(&sigp_ctrl->value, old_val.value, new_val.value); 89 - read_unlock(&vcpu->kvm->arch.sca_lock); 90 76 91 77 if (rc != expect) { 92 78 /* another external call is pending */ ··· 84 98 85 99 static void sca_clear_ext_call(struct kvm_vcpu *vcpu) 86 100 { 87 - union esca_sigp_ctrl *sigp_ctrl; 88 - struct esca_block *sca; 101 + struct esca_block *sca = vcpu->kvm->arch.sca; 102 + union esca_sigp_ctrl *sigp_ctrl = &sca->cpu[vcpu->vcpu_id].sigp_ctrl; 89 103 90 104 if (!kvm_s390_use_sca_entries()) 91 105 return; 92 106 kvm_s390_clear_cpuflags(vcpu, CPUSTAT_ECALL_PEND); 93 - read_lock(&vcpu->kvm->arch.sca_lock); 94 - sca = vcpu->kvm->arch.sca; 95 - sigp_ctrl = &sca->cpu[vcpu->vcpu_id].sigp_ctrl; 96 107 97 108 WRITE_ONCE(sigp_ctrl->value, 0); 98 - read_unlock(&vcpu->kvm->arch.sca_lock); 99 109 } 100 110 101 111 int psw_extint_disabled(struct kvm_vcpu *vcpu)
+9 -25
arch/s390/kvm/kvm-s390.c
··· 1938 1938 union sca_utility new, old; 1939 1939 struct esca_block *sca; 1940 1940 1941 - read_lock(&kvm->arch.sca_lock); 1942 1941 sca = kvm->arch.sca; 1943 1942 old = READ_ONCE(sca->utility); 1944 1943 do { 1945 1944 new = old; 1946 1945 new.mtcr = val; 1947 1946 } while (!try_cmpxchg(&sca->utility.val, &old.val, new.val)); 1948 - read_unlock(&kvm->arch.sca_lock); 1949 1947 } 1950 1948 1951 1949 static int kvm_s390_set_topo_change_indication(struct kvm *kvm, ··· 1964 1966 if (!test_kvm_facility(kvm, 11)) 1965 1967 return -ENXIO; 1966 1968 1967 - read_lock(&kvm->arch.sca_lock); 1968 1969 topo = kvm->arch.sca->utility.mtcr; 1969 - read_unlock(&kvm->arch.sca_lock); 1970 1970 1971 1971 return put_user(topo, (u8 __user *)attr->addr); 1972 1972 } ··· 3341 3345 3342 3346 if (!sclp.has_64bscao) 3343 3347 alloc_flags |= GFP_DMA; 3344 - rwlock_init(&kvm->arch.sca_lock); 3345 3348 mutex_lock(&kvm_lock); 3346 3349 3347 3350 kvm->arch.sca = alloc_pages_exact(sizeof(*kvm->arch.sca), alloc_flags); ··· 3525 3530 3526 3531 static void sca_del_vcpu(struct kvm_vcpu *vcpu) 3527 3532 { 3528 - struct esca_block *sca; 3533 + struct esca_block *sca = vcpu->kvm->arch.sca; 3529 3534 3530 3535 if (!kvm_s390_use_sca_entries()) 3531 3536 return; 3532 - read_lock(&vcpu->kvm->arch.sca_lock); 3533 - sca = vcpu->kvm->arch.sca; 3534 3537 3535 3538 clear_bit_inv(vcpu->vcpu_id, (unsigned long *)sca->mcn); 3536 3539 sca->cpu[vcpu->vcpu_id].sda = 0; 3537 - read_unlock(&vcpu->kvm->arch.sca_lock); 3538 3540 } 3539 3541 3540 3542 static void sca_add_vcpu(struct kvm_vcpu *vcpu) 3541 3543 { 3542 - struct esca_block *sca; 3543 - phys_addr_t sca_phys; 3544 + struct esca_block *sca = vcpu->kvm->arch.sca; 3545 + phys_addr_t sca_phys = virt_to_phys(sca); 3544 3546 3545 - if (!kvm_s390_use_sca_entries()) { 3546 - sca_phys = virt_to_phys(vcpu->kvm->arch.sca); 3547 - 3548 - /* we still need the basic sca for the ipte control */ 3549 - vcpu->arch.sie_block->scaoh = sca_phys >> 32; 3550 - vcpu->arch.sie_block->scaol = sca_phys; 3551 - return; 3552 - } 3553 - read_lock(&vcpu->kvm->arch.sca_lock); 3554 - sca = vcpu->kvm->arch.sca; 3555 - sca_phys = virt_to_phys(sca); 3556 - 3557 - sca->cpu[vcpu->vcpu_id].sda = virt_to_phys(vcpu->arch.sie_block); 3547 + /* we still need the sca header for the ipte control */ 3558 3548 vcpu->arch.sie_block->scaoh = sca_phys >> 32; 3559 3549 vcpu->arch.sie_block->scaol = sca_phys & ESCA_SCAOL_MASK; 3560 3550 vcpu->arch.sie_block->ecb2 |= ECB2_ESCA; 3551 + 3552 + if (!kvm_s390_use_sca_entries()) 3553 + return; 3554 + 3561 3555 set_bit_inv(vcpu->vcpu_id, (unsigned long *)sca->mcn); 3562 - read_unlock(&vcpu->kvm->arch.sca_lock); 3556 + sca->cpu[vcpu->vcpu_id].sda = virt_to_phys(vcpu->arch.sie_block); 3563 3557 } 3564 3558 3565 3559 static int sca_can_add_vcpu(struct kvm *kvm, unsigned int id)