]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.8-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Aug 2020 15:19:10 +0000 (17:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Aug 2020 15:19:10 +0000 (17:19 +0200)
added patches:
kvm-arm64-only-reschedule-if-mmu_notifier_range_blockable-is-not-set.patch

queue-5.8/kvm-arm64-only-reschedule-if-mmu_notifier_range_blockable-is-not-set.patch [new file with mode: 0644]
queue-5.8/kvm-pass-mmu-notifier-range-flags-to-kvm_unmap_hva_range.patch
queue-5.8/series

diff --git a/queue-5.8/kvm-arm64-only-reschedule-if-mmu_notifier_range_blockable-is-not-set.patch b/queue-5.8/kvm-arm64-only-reschedule-if-mmu_notifier_range_blockable-is-not-set.patch
new file mode 100644 (file)
index 0000000..57505a5
--- /dev/null
@@ -0,0 +1,105 @@
+From b5331379bc62611d1026173a09c73573384201d9 Mon Sep 17 00:00:00 2001
+From: Will Deacon <will@kernel.org>
+Date: Tue, 11 Aug 2020 11:27:25 +0100
+Subject: KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set
+
+From: Will Deacon <will@kernel.org>
+
+commit b5331379bc62611d1026173a09c73573384201d9 upstream.
+
+When an MMU notifier call results in unmapping a range that spans multiple
+PGDs, we end up calling into cond_resched_lock() when crossing a PGD boundary,
+since this avoids running into RCU stalls during VM teardown. Unfortunately,
+if the VM is destroyed as a result of OOM, then blocking is not permitted
+and the call to the scheduler triggers the following BUG():
+
+ | BUG: sleeping function called from invalid context at arch/arm64/kvm/mmu.c:394
+ | in_atomic(): 1, irqs_disabled(): 0, non_block: 1, pid: 36, name: oom_reaper
+ | INFO: lockdep is turned off.
+ | CPU: 3 PID: 36 Comm: oom_reaper Not tainted 5.8.0 #1
+ | Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
+ | Call trace:
+ |  dump_backtrace+0x0/0x284
+ |  show_stack+0x1c/0x28
+ |  dump_stack+0xf0/0x1a4
+ |  ___might_sleep+0x2bc/0x2cc
+ |  unmap_stage2_range+0x160/0x1ac
+ |  kvm_unmap_hva_range+0x1a0/0x1c8
+ |  kvm_mmu_notifier_invalidate_range_start+0x8c/0xf8
+ |  __mmu_notifier_invalidate_range_start+0x218/0x31c
+ |  mmu_notifier_invalidate_range_start_nonblock+0x78/0xb0
+ |  __oom_reap_task_mm+0x128/0x268
+ |  oom_reap_task+0xac/0x298
+ |  oom_reaper+0x178/0x17c
+ |  kthread+0x1e4/0x1fc
+ |  ret_from_fork+0x10/0x30
+
+Use the new 'flags' argument to kvm_unmap_hva_range() to ensure that we
+only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is set in the notifier
+flags.
+
+Cc: <stable@vger.kernel.org>
+Fixes: 8b3405e345b5 ("kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd")
+Cc: Marc Zyngier <maz@kernel.org>
+Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
+Cc: James Morse <james.morse@arm.com>
+Signed-off-by: Will Deacon <will@kernel.org>
+Message-Id: <20200811102725.7121-3-will@kernel.org>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Will Deacon <will@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/arm64/kvm/mmu.c |   17 +++++++++++++----
+ 1 file changed, 13 insertions(+), 4 deletions(-)
+
+--- a/arch/arm64/kvm/mmu.c
++++ b/arch/arm64/kvm/mmu.c
+@@ -365,7 +365,8 @@ static void unmap_stage2_p4ds(struct kvm
+  * destroying the VM), otherwise another faulting VCPU may come in and mess
+  * with things behind our backs.
+  */
+-static void unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size)
++static void __unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size,
++                               bool may_block)
+ {
+       pgd_t *pgd;
+       phys_addr_t addr = start, end = start + size;
+@@ -390,11 +391,16 @@ static void unmap_stage2_range(struct kv
+                * If the range is too large, release the kvm->mmu_lock
+                * to prevent starvation and lockup detector warnings.
+                */
+-              if (next != end)
++              if (may_block && next != end)
+                       cond_resched_lock(&kvm->mmu_lock);
+       } while (pgd++, addr = next, addr != end);
+ }
++static void unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size)
++{
++      __unmap_stage2_range(kvm, start, size, true);
++}
++
+ static void stage2_flush_ptes(struct kvm *kvm, pmd_t *pmd,
+                             phys_addr_t addr, phys_addr_t end)
+ {
+@@ -2198,7 +2204,10 @@ static int handle_hva_to_gpa(struct kvm
+ static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data)
+ {
+-      unmap_stage2_range(kvm, gpa, size);
++      unsigned flags = *(unsigned *)data;
++      bool may_block = flags & MMU_NOTIFIER_RANGE_BLOCKABLE;
++
++      __unmap_stage2_range(kvm, gpa, size, may_block);
+       return 0;
+ }
+@@ -2209,7 +2218,7 @@ int kvm_unmap_hva_range(struct kvm *kvm,
+               return 0;
+       trace_kvm_unmap_hva_range(start, end);
+-      handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL);
++      handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, &flags);
+       return 0;
+ }
index f8fadc7214d436eb5f2ad332c3a3b594e5a9ce55..00f9cc0e86bbfe02da2f0003c28d33d744d0606b 100644 (file)
@@ -24,8 +24,8 @@ Cc: James Morse <james.morse@arm.com>
 Signed-off-by: Will Deacon <will@kernel.org>
 Message-Id: <20200811102725.7121-2-will@kernel.org>
 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Will Deacon <will@kernel.org>
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
 ---
  arch/arm64/include/asm/kvm_host.h   |    2 +-
  arch/arm64/kvm/mmu.c                |    2 +-
index 52c1850eada3865c6b031e37364b6a191d09e4ed..2528308b8fa7fff207fbdaf0a1125960ba0b4bb2 100644 (file)
@@ -26,7 +26,6 @@ ext4-do-not-block-rwf_nowait-dio-write-on-unallocated-space.patch
 ext4-fix-checking-of-directory-entry-validity-for-inline-directories.patch
 jbd2-add-the-missing-unlock_buffer-in-the-error-path-of-jbd2_write_superblock.patch
 scsi-zfcp-fix-use-after-free-in-request-timeout-handlers.patch
-kvm-pass-mmu-notifier-range-flags-to-kvm_unmap_hva_range.patch
 selftests-kvm-use-a-shorter-encoding-to-clear-rax.patch
 s390-pci-fix-zpci_bus_link_virtfn.patch
 s390-pci-re-introduce-zpci_remove_device.patch
@@ -146,3 +145,5 @@ efi-libstub-stop-parsing-arguments-at.patch
 efi-libstub-handle-null-cmdline.patch
 efi-libstub-handle-unterminated-cmdline.patch
 do_epoll_ctl-clean-the-failure-exits-up-a-bit.patch
+kvm-pass-mmu-notifier-range-flags-to-kvm_unmap_hva_range.patch
+kvm-arm64-only-reschedule-if-mmu_notifier_range_blockable-is-not-set.patch