From: Sasha Levin Date: Mon, 1 Nov 2021 00:40:29 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v4.4.291~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=507b7e0f3a5b55234f1ace121bb254ea1c86a24f;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- 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 index 00000000000..714d7d51967 --- /dev/null +++ b/queue-5.4/kvm-s390-clear-kicked_mask-before-sleeping-again.patch @@ -0,0 +1,55 @@ +From 07739e5811cd6465ad6ded86e2487977af2494d5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 19 Oct 2021 19:53:59 +0200 +Subject: KVM: s390: clear kicked_mask before sleeping again + +From: Halil Pasic + +[ 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 +Signed-off-by: Halil Pasic +Reviewed-by: Christian Borntraeger +Reviewed-by: Michael Mueller +Reviewed-by: Claudio Imbrenda +Link: https://lore.kernel.org/r/20211019175401.3757927-2-pasic@linux.ibm.com +Signed-off-by: Christian Borntraeger +Signed-off-by: Sasha Levin +--- + 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 index 00000000000..b2c146da246 --- /dev/null +++ b/queue-5.4/kvm-s390-preserve-deliverable_mask-in-__airqs_kick_s.patch @@ -0,0 +1,51 @@ +From 17dce6cc480826927a83323a9f828cd569717263 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 19 Oct 2021 19:54:00 +0200 +Subject: KVM: s390: preserve deliverable_mask in __airqs_kick_single_vcpu + +From: Halil Pasic + +[ 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 +Reviewed-by: Christian Borntraeger +Reviewed-by: Michael Mueller +Reviewed-by: Claudio Imbrenda +Link: https://lore.kernel.org/r/20211019175401.3757927-3-pasic@linux.ibm.com +Signed-off-by: Christian Borntraeger +Signed-off-by: Sasha Levin +--- + 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 + diff --git a/queue-5.4/series b/queue-5.4/series index b2f2ce9407b..0029fef4d5b 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -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