mirror of
https://github.com/torvalds/linux.git
synced 2024-12-30 06:41:43 +00:00
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 <kevin.tian@intel.com> Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200313031109.7989-1-yan.y.zhao@intel.com
This commit is contained in:
parent
776d95b768
commit
b59b2a3ee5
@ -2050,33 +2050,14 @@ static int kvmgt_rw_gpa(unsigned long handle, unsigned long gpa,
|
||||
void *buf, unsigned long len, bool write)
|
||||
{
|
||||
struct kvmgt_guest_info *info;
|
||||
struct kvm *kvm;
|
||||
int idx, ret;
|
||||
bool kthread = current->mm == NULL;
|
||||
|
||||
if (!handle_valid(handle))
|
||||
return -ESRCH;
|
||||
|
||||
info = (struct kvmgt_guest_info *)handle;
|
||||
kvm = info->kvm;
|
||||
|
||||
if (kthread) {
|
||||
if (!mmget_not_zero(kvm->mm))
|
||||
return -EFAULT;
|
||||
use_mm(kvm->mm);
|
||||
}
|
||||
|
||||
idx = srcu_read_lock(&kvm->srcu);
|
||||
ret = write ? kvm_write_guest(kvm, gpa, buf, len) :
|
||||
kvm_read_guest(kvm, gpa, buf, len);
|
||||
srcu_read_unlock(&kvm->srcu, idx);
|
||||
|
||||
if (kthread) {
|
||||
unuse_mm(kvm->mm);
|
||||
mmput(kvm->mm);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return vfio_dma_rw(kvmgt_vdev(info->vgpu)->vfio_group,
|
||||
gpa, buf, len, write);
|
||||
}
|
||||
|
||||
static int kvmgt_read_gpa(unsigned long handle, unsigned long gpa,
|
||||
|
Loading…
Reference in New Issue
Block a user