1
0
Fork 0
alistair23-linux/arch/arm64
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
..
boot ARM: new SoC support for v5.9 2020-08-03 19:38:30 -07:00
configs ARM: SoC driver updates for v5.9 2020-08-03 19:30:59 -07:00
crypto crypto: arm64/gcm - use inline helper to suppress indirect calls 2020-07-09 22:14:32 +10:00
include KVM: Pass MMU notifier range flags to kvm_unmap_hva_range() 2020-08-21 18:03:47 -04:00
kernel KVM/arm64 updates for Linux 5.9: 2020-08-09 12:58:23 -04:00
kvm KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set 2020-08-21 18:06:43 -04:00
lib Merge branch 'rwonce/rework' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux 2020-06-10 14:46:54 -07:00
mm mm/sparse: cleanup the code surrounding memory_present() 2020-08-07 11:33:27 -07:00
net bpf, arm64: Add BPF exception tables 2020-07-31 00:43:40 +02:00
xen arm64: xen: Use modern annotations for assembly functions 2020-01-09 16:09:42 +00:00
Kbuild arm64: add arch/arm64/Kbuild 2019-08-21 18:47:15 +01:00
Kconfig KVM/arm64 updates for Linux 5.9: 2020-08-09 12:58:23 -04:00
Kconfig.debug arm64: remove TEXT_OFFSET randomization 2020-06-15 13:10:59 +01:00
Kconfig.platforms ARM: new SoC support for v5.9 2020-08-03 19:38:30 -07:00
Makefile arm64 and cross-arch updates for 5.9: 2020-08-03 14:11:08 -07:00