drm/i915/gvt: set shadow entry to scratch page while p2m failed
authorXiaoguang Chen <xiaoguang.chen@intel.com>
Tue, 21 Mar 2017 02:54:21 +0000 (10:54 +0800)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Tue, 21 Mar 2017 03:15:40 +0000 (11:15 +0800)
Sometimes guest driver will only update partial of the GGTT entry then
access it. In this situation a failure will happen while translating
the gpa to hpa.
Now in this situation we let the corresponding shadow entry pointing
to a scratch page.

Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
Signed-off-by: Xiaoguang Chen <xiaoguang.chen@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/gvt/gtt.c

index da73127158241bb6659ab1c5c942c30c39fb2a56..b832bea64e0367ed6c25bf031a2a71db82d7edcc 100644 (file)
@@ -1837,11 +1837,15 @@ static int emulate_gtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
                ret = gtt_entry_p2m(vgpu, &e, &m);
                if (ret) {
                        gvt_vgpu_err("fail to translate guest gtt entry\n");
-                       return ret;
+                       /* guest driver may read/write the entry when partial
+                        * update the entry in this situation p2m will fail
+                        * settting the shadow entry to point to a scratch page
+                        */
+                       ops->set_pfn(&m, gvt->gtt.scratch_ggtt_mfn);
                }
        } else {
                m = e;
-               m.val64 = 0;
+               ops->set_pfn(&m, gvt->gtt.scratch_ggtt_mfn);
        }
 
        ggtt_set_shadow_entry(ggtt_mm, &m, g_gtt_index);