@@ -65,8 +65,7 @@ bool intel_gvt_ggtt_validate_range(struct intel_vgpu *vgpu, u64 addr, u32 size)
/* translate a guest gmadr to host gmadr */
int intel_gvt_ggtt_gmadr_g2h(struct intel_vgpu *vgpu, u64 g_addr, u64 *h_addr)
{
- if (WARN(!vgpu_gmadr_is_valid(vgpu, g_addr),
- "invalid guest gmadr %llx\n", g_addr))
+ if (!vgpu_gmadr_is_valid(vgpu, g_addr))
return -EACCES;
if (vgpu_gmadr_is_aperture(vgpu, g_addr))
@@ -2162,7 +2161,8 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
struct intel_vgpu_mm *ggtt_mm = vgpu->gtt.ggtt_mm;
struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;
unsigned long g_gtt_index = off >> info->gtt_entry_size_shift;
- unsigned long gma, gfn;
+ unsigned long gfn;
+ unsigned long h_gtt_index;
struct intel_gvt_gtt_entry e, m;
dma_addr_t dma_addr;
int ret;
@@ -2172,10 +2172,8 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
if (bytes != 4 && bytes != 8)
return -EINVAL;
- gma = g_gtt_index << I915_GTT_PAGE_SHIFT;
-
/* the VM may configure the whole GM space when ballooning is used */
- if (!vgpu_gmadr_is_valid(vgpu, gma))
+ if (intel_gvt_ggtt_index_g2h(vgpu, g_gtt_index, &h_gtt_index))
return 0;
e.type = GTT_TYPE_GGTT_PTE;
@@ -2259,11 +2257,12 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,
out:
ggtt_set_guest_entry(ggtt_mm, &e, g_gtt_index);
- ggtt_get_host_entry(ggtt_mm, &e, g_gtt_index);
+ ggtt_get_host_entry(ggtt_mm, &e, h_gtt_index);
ggtt_invalidate_pte(vgpu, &e);
- ggtt_set_host_entry(ggtt_mm, &m, g_gtt_index);
+ ggtt_set_host_entry(ggtt_mm, &m, h_gtt_index);
ggtt_invalidate(gvt->dev_priv);
+
return 0;
}