]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: PPC: Book3S HV: Close race with page faults around memslot flushes
authorPaul Mackerras <paulus@ozlabs.org>
Thu, 28 May 2020 00:56:42 +0000 (10:56 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Thu, 28 May 2020 00:56:42 +0000 (10:56 +1000)
commitc95b0bd8455aa62c6680ce09a5aa2064c61cd76c
tree31e28225720a47331b4f3544cbc110fe29a448bd
parenta5c1997cc9ca4ecd67192df5daeae5c5ea29881b
KVM: PPC: Book3S HV: Close race with page faults around memslot flushes

There is a potential race condition between hypervisor page faults
and flushing a memslot.  It is possible for a page fault to read the
memslot before a memslot is updated and then write a PTE to the
partition-scoped page tables after kvmppc_radix_flush_memslot has
completed.  (Note that this race has never been explicitly observed.)

To close this race, it is sufficient to increment the MMU sequence
number while the kvm->mmu_lock is held.  That will cause
mmu_notifier_retry() to return true, and the page fault will then
return to the guest without inserting a PTE.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/kvm/book3s_64_mmu_radix.c