1
0
Fork 0
alistair23-linux/arch/arm64/kvm
Will Deacon b5331379bc KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set
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: 8b3405e345 ("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>
2020-08-21 18:06:43 -04:00
..
hyp KVM/arm64 updates for Linux 5.9: 2020-08-09 12:58:23 -04:00
vgic KVM/arm64 updates for Linux 5.9: 2020-08-09 12:58:23 -04:00
Kconfig KVM: arm64: Substitute RANDOMIZE_BASE for HARDEN_EL2_VECTORS 2020-07-28 10:41:11 +01:00
Makefile Merge branch 'kvm-arm64/target-table-no-more' into kvmarm-master/next-WIP 2020-07-28 16:10:32 +01:00
aarch32.c KVM: arm64: Synchronize sysreg state on injecting an AArch32 exception 2020-06-10 16:04:08 +01:00
arch_timer.c KVM: arm64: timers: Move timer registers to the sys_regs file 2020-07-07 09:28:38 +01:00
arm.c KVM/arm64 updates for Linux 5.9: 2020-08-09 12:58:23 -04:00
debug.c KVM: arm64: Write arch.mdcr_el2 changes since last vcpu_load on VHE 2020-01-22 18:38:04 +00:00
fpsimd.c KVM: arm64: Make struct kvm_regs userspace-only 2020-07-07 09:28:38 +01:00
guest.c KVM: arm64: Move SPSR_EL1 to the system register array 2020-07-07 09:28:38 +01:00
handle_exit.c KVM/arm64 updates for Linux 5.9: 2020-08-09 12:58:23 -04:00
hyp.S arm64: kvm: Annotate assembly using modern annoations 2020-03-09 17:35:29 +00:00
hypercalls.c KVM: arm64: Move virt/kvm/arm to arch/arm64 2020-05-16 15:03:59 +01:00
inject_fault.c KVM: arm64: Move ELR_EL1 to the system register array 2020-07-07 09:28:38 +01:00
irq.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 422 2019-06-05 17:37:15 +02:00
mmio.c KVM/arm64 updates for Linux 5.9: 2020-08-09 12:58:23 -04:00
mmu.c KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set 2020-08-21 18:06:43 -04:00
perf.c KVM: arm64: Move virt/kvm/arm to arch/arm64 2020-05-16 15:03:59 +01:00
pmu-emul.c KVM: arm64: Move virt/kvm/arm to arch/arm64 2020-05-16 15:03:59 +01:00
pmu.c KVM: arm64: PMU: Fix per-CPU access in preemptible context 2020-07-06 11:47:02 +01:00
psci.c KVM: Fix spelling in code comments 2020-05-16 15:05:01 +01:00
pvtime.c KVM: arm64: pvtime: Ensure task delay accounting is enabled 2020-06-22 15:35:57 +01:00
regmap.c KVM: arm64: Move SPSR_EL1 to the system register array 2020-07-07 09:28:38 +01:00
reset.c KVM/arm64 updates for Linux 5.9: 2020-08-09 12:58:23 -04:00
sys_regs.c KVM/arm64 updates for Linux 5.9: 2020-08-09 12:58:23 -04:00
sys_regs.h KVM: arm64: Remove the target table 2020-07-05 18:20:45 +01:00
trace.h KVM: arm64: Move virt/kvm/arm to arch/arm64 2020-05-16 15:03:59 +01:00
trace_arm.h KVM: arm64: timers: Move timer registers to the sys_regs file 2020-07-07 09:28:38 +01:00
trace_handle_exit.h KVM: arm64: Move virt/kvm/arm to arch/arm64 2020-05-16 15:03:59 +01:00
va_layout.c KVM: arm64: Make nVHE ASLR conditional on RANDOMIZE_BASE 2020-07-28 10:41:11 +01:00
vgic-sys-reg-v3.c KVM: arm64: Move virt/kvm/arm to arch/arm64 2020-05-16 15:03:59 +01:00