Skip to content

Commit 3d4415e

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86/mmu: Bug the VM if KVM tries to split a !hugepage SPTE
Bug the VM instead of simply warning if KVM tries to split a SPTE that is non-present or not-huge. KVM is guaranteed to end up in a broken state as the callers fully expect a valid SPTE, e.g. the shadow MMU will add an rmap entry, and all MMUs will account the expected small page. Returning '0' is also technically wrong now that SHADOW_NONPRESENT_VALUE exists, i.e. would cause KVM to create a potential #VE SPTE. While it would be possible to have the callers gracefully handle failure, doing so would provide no practical value as the scenario really should be impossible, while the error handling would add a non-trivial amount of noise. Fixes: a3fe5db ("KVM: x86/mmu: Split huge pages mapped by the TDP MMU when dirty logging is enabled") Cc: David Matlack <dmatlack@google.com> Signed-off-by: Sean Christopherson <seanjc@google.com> Message-ID: <20240712151335.1242633-2-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 208a352 commit 3d4415e

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

arch/x86/kvm/mmu/spte.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,7 @@ u64 make_huge_page_split_spte(struct kvm *kvm, u64 huge_spte, union kvm_mmu_page
296296
{
297297
u64 child_spte;
298298

299-
if (WARN_ON_ONCE(!is_shadow_present_pte(huge_spte)))
300-
return 0;
301-
302-
if (WARN_ON_ONCE(!is_large_pte(huge_spte)))
303-
return 0;
299+
KVM_BUG_ON(!is_shadow_present_pte(huge_spte) || !is_large_pte(huge_spte), kvm);
304300

305301
child_spte = huge_spte;
306302

0 commit comments

Comments
 (0)