From: Yan Zhao <yan.y.zhao@intel.com>
To: intel-gvt-dev@lists.freedesktop.org, alex.williamson@redhat.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Yulei Zhang <yulei.zhang@intel.com>,
Zhenyu Wang <zhenyuw@linux.intel.com>
Subject: [PATCH 1/8] drm/i915/gvt: Apply g2h adjust for GTT mmio access
Date: Tue, 19 Feb 2019 02:43:57 -0500 [thread overview]
Message-ID: <20190219074357.14061-1-yan.y.zhao@intel.com> (raw)
In-Reply-To: <20190219074242.14015-1-yan.y.zhao@intel.com>
From: Yulei Zhang <yulei.zhang@intel.com>
Apply guest to host gma conversion while guest try to access the
GTT mmio registers, as after enable live migration the host gma
will be changed due to the resourece re-allocation, but guest
gma should be remaining unchanged, thus g2h conversion is request
for it.
Signed-off-by: Yulei Zhang <yulei.zhang@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
---
drivers/gpu/drm/i915/gvt/gtt.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
index c7103dd2d8d5..8a5d26d1d402 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -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;
}
--
2.17.1
next prev parent reply other threads:[~2019-02-19 7:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-19 7:42 [PATCH 0/8] VFIO Device states interface in GVT Yan Zhao
2019-02-19 7:43 ` Yan Zhao [this message]
2019-02-19 7:45 ` [PATCH 2/8] drm/i915/gvt: Apply g2h adjustment during fence mmio access Yan Zhao
2019-02-19 7:45 ` [PATCH 3/8] drm/i915/gvt: Patch the gma in gpu commands during command parser Yan Zhao
2019-02-19 7:46 ` [PATCH 4/8] drm/i915/gvt: Retrieve the guest gm base address from PVINFO Yan Zhao
2019-02-19 7:46 ` [PATCH 5/8] drm/i915/gvt: Align the guest gm aperture start offset for live migration Yan Zhao
2019-02-19 7:46 ` [PATCH 6/8] drm/i915/gvt: Apply g2h adjustment to buffer start gma for dmabuf Yan Zhao
2019-02-19 7:46 ` [PATCH 7/8] drm/i915/gvt: vGPU device config data save/restore interface Yan Zhao
2019-02-20 9:39 ` Zhenyu Wang
2019-02-19 7:46 ` [PATCH 8/8] drm/i915/gvt: VFIO device states interfaces Yan Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190219074357.14061-1-yan.y.zhao@intel.com \
--to=yan.y.zhao@intel.com \
--cc=alex.williamson@redhat.com \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yulei.zhang@intel.com \
--cc=zhenyuw@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®