linux-brain/arch/s390/kvm
Halil Pasic 20fff3ef33 KVM: s390: index kvm->arch.idle_mask by vcpu_idx
commit a3e03bc1368c1bc16e19b001fc96dc7430573cc8 upstream.

While in practice vcpu->vcpu_idx ==  vcpu->vcp_id is often true, it may
not always be, and we must not rely on this. Reason is that KVM decides
the vcpu_idx, userspace decides the vcpu_id, thus the two might not
match.

Currently kvm->arch.idle_mask is indexed by vcpu_id, which implies
that code like
for_each_set_bit(vcpu_id, kvm->arch.idle_mask, online_vcpus) {
                vcpu = kvm_get_vcpu(kvm, vcpu_id);
		do_stuff(vcpu);
}
is not legit. Reason is that kvm_get_vcpu expects an vcpu_idx, not an
vcpu_id.  The trouble is, we do actually use kvm->arch.idle_mask like
this. To fix this problem we have two options. Either use
kvm_get_vcpu_by_id(vcpu_id), which would loop to find the right vcpu_id,
or switch to indexing via vcpu_idx. The latter is preferable for obvious
reasons.

Let us make switch from indexing kvm->arch.idle_mask by vcpu_id to
indexing it by vcpu_idx.  To keep gisa_int.kicked_mask indexed by the
same index as idle_mask lets make the same change for it as well.

Fixes: 1ee0bc559d ("KVM: s390: get rid of local_int array")
Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Reviewed-by: Christian Bornträger <borntraeger@de.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: <stable@vger.kernel.org> # 3.15+
Link: https://lore.kernel.org/r/20210827125429.1912577-1-pasic@linux.ibm.com
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-15 09:47:40 +02:00
..
Kconfig * ARM: support for SVE and Pointer Authentication in guests, PMU improvements 2019-05-17 10:33:30 -07:00
Makefile KVM: s390: Remove redundant license text 2017-12-06 09:18:42 +01:00
diag.c KVM: s390: add vcpu stat counters for many instruction 2018-01-24 16:49:02 +01:00
gaccess.c treewide: Use array_size() in vmalloc() 2018-06-12 16:19:22 -07:00
gaccess.h KVM: s390: split kvm_s390_real_to_abs 2021-05-14 09:44:15 +02:00
guestdbg.c KVM: s390: introduce defines for control registers 2018-05-17 09:02:27 +02:00
intercept.c KVM: s390: add exit io request stats and simplify code 2018-03-14 19:21:11 +00:00
interrupt.c KVM: s390: index kvm->arch.idle_mask by vcpu_idx 2021-09-15 09:47:40 +02:00
irq.h KVM: s390: Remove redundant license text 2017-12-06 09:18:42 +01:00
kvm-s390.c KVM: s390: index kvm->arch.idle_mask by vcpu_idx 2021-09-15 09:47:40 +02:00
kvm-s390.h KVM: s390: index kvm->arch.idle_mask by vcpu_idx 2021-09-15 09:47:40 +02:00
priv.c KVM: s390: Remove false WARN_ON_ONCE for the PQAP instruction 2020-05-14 07:58:25 +02:00
sigp.c KVM: s390: introduce and use kvm_s390_test_cpuflags() 2018-01-24 17:46:42 +01:00
trace-s390.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vsie.c KVM: s390: vsie: Fix delivery of addressing exceptions 2020-04-17 10:50:13 +02:00