]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: x86/mmu: Skip emulation on page fault iff 1+ SPs were unprotected
authorSean Christopherson <seanjc@google.com>
Sat, 31 Aug 2024 00:15:19 +0000 (17:15 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 10 Sep 2024 03:16:20 +0000 (20:16 -0700)
commit2fb2b7877b3a4cac4de070ef92437b38f13559b0
tree33634259d320f3c9b589aa3bac3f5b124b105d81
parent989a84c93f592e6b288fb3b96d2eeec827d75bef
KVM: x86/mmu: Skip emulation on page fault iff 1+ SPs were unprotected

When doing "fast unprotection" of nested TDP page tables, skip emulation
if and only if at least one gfn was unprotected, i.e. continue with
emulation if simply resuming is likely to hit the same fault and risk
putting the vCPU into an infinite loop.

Note, it's entirely possible to get a false negative, e.g. if a different
vCPU faults on the same gfn and unprotects the gfn first, but that's a
relatively rare edge case, and emulating is still functionally ok, i.e.
saving a few cycles by avoiding emulation isn't worth the risk of putting
the vCPU into an infinite loop.

Opportunistically rewrite the relevant comment to document in gory detail
exactly what scenario the "fast unprotect" logic is handling.

Fixes: 147277540bbc ("kvm: svm: Add support for additional SVM NPF error codes")
Cc: Yuan Yao <yuan.yao@intel.com>
Reviewed-by: Yuan Yao <yuan.yao@intel.com>
Link: https://lore.kernel.org/r/20240831001538.336683-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/mmu.c