]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Sep 2021 15:25:08 +0000 (17:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Sep 2021 15:25:08 +0000 (17:25 +0200)
added patches:
kvm-s390-index-kvm-arch.idle_mask-by-vcpu_idx.patch

queue-4.19/kvm-s390-index-kvm-arch.idle_mask-by-vcpu_idx.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/kvm-s390-index-kvm-arch.idle_mask-by-vcpu_idx.patch b/queue-4.19/kvm-s390-index-kvm-arch.idle_mask-by-vcpu_idx.patch
new file mode 100644 (file)
index 0000000..b9c9ec6
--- /dev/null
@@ -0,0 +1,78 @@
+From a3e03bc1368c1bc16e19b001fc96dc7430573cc8 Mon Sep 17 00:00:00 2001
+From: Halil Pasic <pasic@linux.ibm.com>
+Date: Fri, 27 Aug 2021 14:54:29 +0200
+Subject: KVM: s390: index kvm->arch.idle_mask by vcpu_idx
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Halil Pasic <pasic@linux.ibm.com>
+
+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: 1ee0bc559dc3 ("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
+[borntraeger@de.ibm.com]: change  idle mask, remove kicked_mask 
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/s390/kvm/interrupt.c |    4 ++--
+ arch/s390/kvm/kvm-s390.h  |    2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -318,13 +318,13 @@ static unsigned long deliverable_irqs(st
+ static void __set_cpu_idle(struct kvm_vcpu *vcpu)
+ {
+       kvm_s390_set_cpuflags(vcpu, CPUSTAT_WAIT);
+-      set_bit(vcpu->vcpu_id, vcpu->kvm->arch.float_int.idle_mask);
++      set_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.float_int.idle_mask);
+ }
+ static void __unset_cpu_idle(struct kvm_vcpu *vcpu)
+ {
+       kvm_s390_clear_cpuflags(vcpu, CPUSTAT_WAIT);
+-      clear_bit(vcpu->vcpu_id, vcpu->kvm->arch.float_int.idle_mask);
++      clear_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.float_int.idle_mask);
+ }
+ static void __reset_intercept_indicators(struct kvm_vcpu *vcpu)
+--- a/arch/s390/kvm/kvm-s390.h
++++ b/arch/s390/kvm/kvm-s390.h
+@@ -67,7 +67,7 @@ static inline int is_vcpu_stopped(struct
+ static inline int is_vcpu_idle(struct kvm_vcpu *vcpu)
+ {
+-      return test_bit(vcpu->vcpu_id, vcpu->kvm->arch.float_int.idle_mask);
++      return test_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.float_int.idle_mask);
+ }
+ static inline int kvm_is_ucontrol(struct kvm *kvm)
index fff0f211b68c269979327b86ef3245efff4a8916..eaeb41b428af8e29888fdef69682ff7c77a43d86 100644 (file)
@@ -271,3 +271,4 @@ qed-handle-management-fw-error.patch
 ibmvnic-check-failover_pending-in-login-response.patch
 net-hns3-pad-the-short-tunnel-frame-before-sending-to-hardware.patch
 mm-memory_hotplug-use-unsigned-long-for-pfn-in-zone_for_pfn_range.patch
+kvm-s390-index-kvm-arch.idle_mask-by-vcpu_idx.patch