drm/i915/gvt: Verify pfn is "valid" before dereferencing "struct page"
authorSean Christopherson <seanjc@google.com>
Sat, 29 Jul 2023 01:35:07 +0000 (18:35 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 31 Aug 2023 17:48:51 +0000 (13:48 -0400)
commitf046923af79158361295ed4f0a588c80b9fdcc1d
treeff3aaa262330b4db36bd5bbd09b27011cfc18a2b
parent52e322eda3d475614210efbc0f2793a1da9d367a
drm/i915/gvt: Verify pfn is "valid" before dereferencing "struct page"

Check that the pfn found by gfn_to_pfn() is actually backed by "struct
page" memory prior to retrieving and dereferencing the page.  KVM
supports backing guest memory with VM_PFNMAP, VM_IO, etc., and so
there is no guarantee the pfn returned by gfn_to_pfn() has an associated
"struct page".

Fixes: b901b252b6cf ("drm/i915/gvt: Add 2M huge gtt support")
Reviewed-by: Yan Zhao <yan.y.zhao@intel.com>
Tested-by: Yongwei Ma <yongwei.ma@intel.com>
Reviewed-by: Zhi Wang <zhi.a.wang@intel.com>
Link: https://lore.kernel.org/r/20230729013535.1070024-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
drivers/gpu/drm/i915/gvt/gtt.c