Skip to content

Commit b59b2a3

Browse files
yanzhao56zhenyw
authored andcommitted
drm/i915/gvt: subsitute kvm_read/write_guest with vfio_dma_rw
As a device model, it is better to read/write guest memory using vfio interface, so that vfio is able to maintain dirty info of device IOVAs. Cc: Kevin Tian <[email protected]> Signed-off-by: Yan Zhao <[email protected]> Reviewed-by: Zhenyu Wang <[email protected]> Signed-off-by: Zhenyu Wang <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 776d95b commit b59b2a3

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

drivers/gpu/drm/i915/gvt/kvmgt.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,33 +2050,14 @@ static int kvmgt_rw_gpa(unsigned long handle, unsigned long gpa,
20502050
void *buf, unsigned long len, bool write)
20512051
{
20522052
struct kvmgt_guest_info *info;
2053-
struct kvm *kvm;
2054-
int idx, ret;
2055-
bool kthread = current->mm == NULL;
20562053

20572054
if (!handle_valid(handle))
20582055
return -ESRCH;
20592056

20602057
info = (struct kvmgt_guest_info *)handle;
2061-
kvm = info->kvm;
2062-
2063-
if (kthread) {
2064-
if (!mmget_not_zero(kvm->mm))
2065-
return -EFAULT;
2066-
use_mm(kvm->mm);
2067-
}
20682058

2069-
idx = srcu_read_lock(&kvm->srcu);
2070-
ret = write ? kvm_write_guest(kvm, gpa, buf, len) :
2071-
kvm_read_guest(kvm, gpa, buf, len);
2072-
srcu_read_unlock(&kvm->srcu, idx);
2073-
2074-
if (kthread) {
2075-
unuse_mm(kvm->mm);
2076-
mmput(kvm->mm);
2077-
}
2078-
2079-
return ret;
2059+
return vfio_dma_rw(kvmgt_vdev(info->vgpu)->vfio_group,
2060+
gpa, buf, len, write);
20802061
}
20812062

20822063
static int kvmgt_read_gpa(unsigned long handle, unsigned long gpa,

0 commit comments

Comments
 (0)