KVM: x86/mmu: Apply retry protection to "fast nTDP unprotect" path
authorSean Christopherson <seanjc@google.com>
Sat, 31 Aug 2024 00:15:23 +0000 (17:15 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 10 Sep 2024 03:16:23 +0000 (20:16 -0700)
commit01dd4d319207c4cfd51a1c9a1812909e944d8c86
treebf230d52547995d19cfb6c602051a8bff9b5ab3a
parent9c19129e535bfff85bdfcb5a804e19e5aae935b2
KVM: x86/mmu: Apply retry protection to "fast nTDP unprotect" path

Move the anti-infinite-loop protection provided by last_retry_{eip,addr}
into kvm_mmu_write_protect_fault() so that it guards unprotect+retry that
never hits the emulator, as well as reexecute_instruction(), which is the
last ditch "might as well try it" logic that kicks in when emulation fails
on an instruction that faulted on a write-protected gfn.

Add a new helper, kvm_mmu_unprotect_gfn_and_retry(), to set the retry
fields and deduplicate other code (with more to come).

Link: https://lore.kernel.org/r/20240831001538.336683-9-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/x86.c