On Thu, 2022-04-28 at 23:34 +0000, Sean Christopherson wrote: > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 904f0faff218..c10ae25135e3 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -3010,9 +3010,15 @@ static bool handle_abnormal_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fa > /* > * If MMIO caching is disabled, emulate immediately without > * touching the shadow page tables as attempting to install an > - * MMIO SPTE will just be an expensive nop. > + * MMIO SPTE will just be an expensive nop. Do not cache MMIO > + * whose gfn is greater than host.MAXPHYADDR, any guest that > + * generates such gfns is either malicious or in the weeds. > + * Note, it's possible to observe a gfn > host.MAXPHYADDR if > + * and only if host.MAXPHYADDR is inaccurate with respect to > + * hardware behavior, e.g. if KVM itself is running as a VM. > */ > - if (unlikely(!enable_mmio_caching)) { > + if (unlikely(!enable_mmio_caching) || > + unlikely(fault->gfn > kvm_mmu_max_gfn_host())) { Shouldn't we check fault->gfn against cpuid_maxphyaddr(vcpu) instead of kvm_mmu_max_gfn_host() here? > *ret_val = RET_PF_EMULATE; > return true; > } -- Thanks, -Kai