]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: x86/mmu: Ensure forward progress when yielding in TDP MMU iter
authorBen Gardon <bgardon@google.com>
Sat, 10 Apr 2021 15:12:24 +0000 (11:12 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Apr 2021 06:47:15 +0000 (08:47 +0200)
commit2d08b4ae1eb3156e80cb9c77d3ee268d4733e7f6
tree73975176e896b0b8142fb392f151672f32ded818
parenta4b9d17cb96728c89ab3cd6ff6c0fb78bcaa945e
KVM: x86/mmu: Ensure forward progress when yielding in TDP MMU iter

[ Upstream commit ed5e484b79e8a9b8be714bd85b6fc70bd6dc99a7 ]

In some functions the TDP iter risks not making forward progress if two
threads livelock yielding to one another. This is possible if two threads
are trying to execute wrprot_gfn_range. Each could write protect an entry
and then yield. This would reset the tdp_iter's walk over the paging
structure and the loop would end up repeating the same entry over and
over, preventing either thread from making forward progress.

Fix this issue by only yielding if the loop has made forward progress
since the last yield.

Fixes: a6a0b05da9f3 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
Reviewed-by: Peter Feiner <pfeiner@google.com>
Signed-off-by: Ben Gardon <bgardon@google.com>
Message-Id: <20210202185734.1680553-14-bgardon@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kvm/mmu/tdp_iter.c
arch/x86/kvm/mmu/tdp_iter.h
arch/x86/kvm/mmu/tdp_mmu.c