KVM: x86/mmu: Disallow guest from using !visible slots for page tables
authorSean Christopherson <seanjc@google.com>
Sat, 29 Jul 2023 00:51:59 +0000 (17:51 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 31 Aug 2023 18:08:23 +0000 (14:08 -0400)
commitb5b359ac30d458cb3e2a7fb953adeec78fae4e35
treee2745d768d59dd9ec9b157f77baa1c41f89a723f
parent2c6d4c27b92d729a2831df2a873ba6b5f682f435
KVM: x86/mmu: Disallow guest from using !visible slots for page tables

Explicitly inject a page fault if guest attempts to use a !visible gfn
as a page table.  kvm_vcpu_gfn_to_hva_prot() will naturally handle the
case where there is no memslot, but doesn't catch the scenario where the
gfn points at a KVM-internal memslot.

Letting the guest backdoor its way into accessing KVM-internal memslots
isn't dangerous on its own, e.g. at worst the guest can crash itself, but
disallowing the behavior will simplify fixing how KVM handles !visible
guest root gfns (immediately synthesizing a triple fault when loading the
root is architecturally wrong).

Link: https://lore.kernel.org/r/20230729005200.1057358-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/paging_tmpl.h