]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: x86/mmu: Yield in TDU MMU iter even if no SPTES changed
authorBen Gardon <bgardon@google.com>
Sat, 10 Apr 2021 15:12:25 +0000 (11:12 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Apr 2021 06:47:15 +0000 (08:47 +0200)
commit9fa3f2f8794ead35d37a8d1350463646a0ffa4fb
treef693134bbb5cf7e88e83361daf933abd4ac92ba7
parent2d08b4ae1eb3156e80cb9c77d3ee268d4733e7f6
KVM: x86/mmu: Yield in TDU MMU iter even if no SPTES changed

[ Upstream commit 1af4a96025b33587ca953c7ef12a1b20c6e70412 ]

Given certain conditions, some TDP MMU functions may not yield
reliably / frequently enough. For example, if a paging structure was
very large but had few, if any writable entries, wrprot_gfn_range
could traverse many entries before finding a writable entry and yielding
because the check for yielding only happens after an SPTE is modified.

Fix this issue by moving the yield to the beginning of the loop.

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-15-bgardon@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kvm/mmu/tdp_mmu.c