summaryrefslogtreecommitdiff
path: root/.cocciconfig
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@ozlabs.org>2018-01-30 10:51:32 +1100
committerPaul Mackerras <paulus@ozlabs.org>2018-02-01 13:35:33 +1100
commit36ee41d161c67a6fcf696d4817a0da31f778938c (patch)
tree790868f34e9c7ec17b6d53d17c61aa27d112586a /.cocciconfig
parent9b9b13a6d1537ddc4caccd6f1c41b78edbc08437 (diff)
KVM: PPC: Book3S HV: Drop locks before reading guest memory
Running with CONFIG_DEBUG_ATOMIC_SLEEP reveals that HV KVM tries to read guest memory, in order to emulate guest instructions, while preempt is disabled and a vcore lock is held. This occurs in kvmppc_handle_exit_hv(), called from post_guest_process(), when emulating guest doorbell instructions on POWER9 systems, and also when checking whether we have hit a hypervisor breakpoint. Reading guest memory can cause a page fault and thus cause the task to sleep, so we need to avoid reading guest memory while holding a spinlock or when preempt is disabled. To fix this, we move the preempt_enable() in kvmppc_run_core() to before the loop that calls post_guest_process() for each vcore that has just run, and we drop and re-take the vcore lock around the calls to kvmppc_emulate_debug_inst() and kvmppc_emulate_doorbell_instr(). Dropping the lock is safe with respect to the iteration over the runnable vcpus in post_guest_process(); for_each_runnable_thread is actually safe to use locklessly. It is possible for a vcpu to become runnable and add itself to the runnable_threads array (code near the beginning of kvmppc_run_vcpu()) and then get included in the iteration in post_guest_process despite the fact that it has not just run. This is benign because vcpu->arch.trap and vcpu->arch.ceded will be zero. Cc: stable@vger.kernel.org # v4.13+ Fixes: 579006944e0d ("KVM: PPC: Book3S HV: Virtualize doorbell facility on POWER9") Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Diffstat (limited to '.cocciconfig')
0 files changed, 0 insertions, 0 deletions