drm/i915/gvt: Fix GFX_MODE handling
authorColin Xu <Colin.Xu@intel.com>
Tue, 28 May 2019 03:20:34 +0000 (11:20 +0800)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Thu, 30 May 2019 03:31:43 +0000 (11:31 +0800)
Enter failsafe if vgpu tries to change GFX_MODE controlled by host.

Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: Colin Xu <colin.xu@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/gvt/handlers.c

index b4fc7f9..edb1416 100644 (file)
@@ -1692,8 +1692,22 @@ static int ring_mode_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
        bool enable_execlist;
        int ret;
 
+       (*(u32 *)p_data) &= ~_MASKED_BIT_ENABLE(1);
+       if (IS_COFFEELAKE(vgpu->gvt->dev_priv))
+               (*(u32 *)p_data) &= ~_MASKED_BIT_ENABLE(2);
        write_vreg(vgpu, offset, p_data, bytes);
 
+       if (data & _MASKED_BIT_ENABLE(1)) {
+               enter_failsafe_mode(vgpu, GVT_FAILSAFE_UNSUPPORTED_GUEST);
+               return 0;
+       }
+
+       if (IS_COFFEELAKE(vgpu->gvt->dev_priv) &&
+           data & _MASKED_BIT_ENABLE(2)) {
+               enter_failsafe_mode(vgpu, GVT_FAILSAFE_UNSUPPORTED_GUEST);
+               return 0;
+       }
+
        /* when PPGTT mode enabled, we will check if guest has called
         * pvinfo, if not, we will treat this guest as non-gvtg-aware
         * guest, and stop emulating its cfg space, mmio, gtt, etc.