]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Mon, 1 Nov 2021 00:40:29 +0000 (20:40 -0400)
committerSasha Levin <sashal@kernel.org>
Mon, 1 Nov 2021 00:40:29 +0000 (20:40 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.4/kvm-s390-clear-kicked_mask-before-sleeping-again.patch [new file with mode: 0644]
queue-5.4/kvm-s390-preserve-deliverable_mask-in-__airqs_kick_s.patch [new file with mode: 0644]
queue-5.4/series

diff --git a/queue-5.4/kvm-s390-clear-kicked_mask-before-sleeping-again.patch b/queue-5.4/kvm-s390-clear-kicked_mask-before-sleeping-again.patch
new file mode 100644 (file)
index 0000000..714d7d5
--- /dev/null
@@ -0,0 +1,55 @@
+From 07739e5811cd6465ad6ded86e2487977af2494d5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 19 Oct 2021 19:53:59 +0200
+Subject: KVM: s390: clear kicked_mask before sleeping again
+
+From: Halil Pasic <pasic@linux.ibm.com>
+
+[ Upstream commit 9b57e9d5010bbed7c0d9d445085840f7025e6f9a ]
+
+The idea behind kicked mask is that we should not re-kick a vcpu that
+is already in the "kick" process, i.e. that was kicked and is
+is about to be dispatched if certain conditions are met.
+
+The problem with the current implementation is, that it assumes the
+kicked vcpu is going to enter SIE shortly. But under certain
+circumstances, the vcpu we just kicked will be deemed non-runnable and
+will remain in wait state. This can happen, if the interrupt(s) this
+vcpu got kicked to deal with got already cleared (because the interrupts
+got delivered to another vcpu). In this case kvm_arch_vcpu_runnable()
+would return false, and the vcpu would remain in kvm_vcpu_block(),
+but this time with its kicked_mask bit set. So next time around we
+wouldn't kick the vcpu form __airqs_kick_single_vcpu(), but would assume
+that we just kicked it.
+
+Let us make sure the kicked_mask is cleared before we give up on
+re-dispatching the vcpu.
+
+Fixes: 9f30f6216378 ("KVM: s390: add gib_alert_irq_handler()")
+Reported-by: Matthew Rosato <mjrosato@linux.ibm.com>
+Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Michael Mueller <mimu@linux.ibm.com>
+Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
+Link: https://lore.kernel.org/r/20211019175401.3757927-2-pasic@linux.ibm.com
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/s390/kvm/kvm-s390.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
+index 9ed2fee61229..b286818d8d54 100644
+--- a/arch/s390/kvm/kvm-s390.c
++++ b/arch/s390/kvm/kvm-s390.c
+@@ -3092,6 +3092,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
+ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
+ {
++      clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.gisa_int.kicked_mask);
+       return kvm_s390_vcpu_has_irq(vcpu, 0);
+ }
+-- 
+2.33.0
+
diff --git a/queue-5.4/kvm-s390-preserve-deliverable_mask-in-__airqs_kick_s.patch b/queue-5.4/kvm-s390-preserve-deliverable_mask-in-__airqs_kick_s.patch
new file mode 100644 (file)
index 0000000..b2c146d
--- /dev/null
@@ -0,0 +1,51 @@
+From 17dce6cc480826927a83323a9f828cd569717263 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 19 Oct 2021 19:54:00 +0200
+Subject: KVM: s390: preserve deliverable_mask in __airqs_kick_single_vcpu
+
+From: Halil Pasic <pasic@linux.ibm.com>
+
+[ Upstream commit 0e9ff65f455dfd0a8aea5e7843678ab6fe097e21 ]
+
+Changing the deliverable mask in __airqs_kick_single_vcpu() is a bug. If
+one idle vcpu can't take the interrupts we want to deliver, we should
+look for another vcpu that can, instead of saying that we don't want
+to deliver these interrupts by clearing the bits from the
+deliverable_mask.
+
+Fixes: 9f30f6216378 ("KVM: s390: add gib_alert_irq_handler()")
+Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
+Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Reviewed-by: Michael Mueller <mimu@linux.ibm.com>
+Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
+Link: https://lore.kernel.org/r/20211019175401.3757927-3-pasic@linux.ibm.com
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/s390/kvm/interrupt.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
+index fa9483aa4f57..fd73a8aa89d2 100644
+--- a/arch/s390/kvm/interrupt.c
++++ b/arch/s390/kvm/interrupt.c
+@@ -2987,13 +2987,14 @@ static void __airqs_kick_single_vcpu(struct kvm *kvm, u8 deliverable_mask)
+       int vcpu_idx, online_vcpus = atomic_read(&kvm->online_vcpus);
+       struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int;
+       struct kvm_vcpu *vcpu;
++      u8 vcpu_isc_mask;
+       for_each_set_bit(vcpu_idx, kvm->arch.idle_mask, online_vcpus) {
+               vcpu = kvm_get_vcpu(kvm, vcpu_idx);
+               if (psw_ioint_disabled(vcpu))
+                       continue;
+-              deliverable_mask &= (u8)(vcpu->arch.sie_block->gcr[6] >> 24);
+-              if (deliverable_mask) {
++              vcpu_isc_mask = (u8)(vcpu->arch.sie_block->gcr[6] >> 24);
++              if (deliverable_mask & vcpu_isc_mask) {
+                       /* lately kicked but not yet running */
+                       if (test_and_set_bit(vcpu_idx, gi->kicked_mask))
+                               return;
+-- 
+2.33.0
+
index b2f2ce9407b50d7b810a79de3af42d064575b685..0029fef4d5b2175aff2fe680726ee308345fb633 100644 (file)
@@ -46,3 +46,5 @@ sctp-add-vtag-check-in-sctp_sf_do_8_5_1_e_sa.patch
 sctp-add-vtag-check-in-sctp_sf_ootb.patch
 net-use-netif_is_bridge_port-to-check-for-iff_bridge.patch
 cfg80211-correct-bridge-4addr-mode-check.patch
+kvm-s390-clear-kicked_mask-before-sleeping-again.patch
+kvm-s390-preserve-deliverable_mask-in-__airqs_kick_s.patch