OSDN Git Service

KVM: x86/mmu: Yield in TDU MMU iter even if no SPTES changed
authorBen Gardon <bgardon@google.com>
Tue, 2 Feb 2021 18:57:20 +0000 (10:57 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 4 Feb 2021 10:27:41 +0000 (05:27 -0500)
commit1af4a96025b33587ca953c7ef12a1b20c6e70412
tree4807a0d90ad215b5454cc7883247517653362455
parented5e484b79e8a9b8be714bd85b6fc70bd6dc99a7
KVM: x86/mmu: Yield in TDU MMU iter even if no SPTES changed

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>
arch/x86/kvm/mmu/tdp_mmu.c