lkml.org 
[lkml]   [2022]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] KVM: x86/mmu: Do not create SPTEs for GFNs that exceed host.MAXPHYADDR
From
Date
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


\
 
 \ /
  Last update: 2022-05-02 13:13    [W:1.028 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site