Skip to content

Commit c15fcf1

Browse files
yanzhao56bonzini
authored andcommitted
drm/i915/gvt: switch from ->track_flush_slot() to ->track_remove_region()
Switch from the poorly named and flawed ->track_flush_slot() to the newly introduced ->track_remove_region(). From KVMGT's perspective, the two hooks are functionally equivalent, the only difference being that ->track_remove_region() is called only when KVM is 100% certain the memory region will be removed, i.e. is invoked slightly later in KVM's memslot modification flow. Cc: Zhenyu Wang <[email protected]> Suggested-by: Sean Christopherson <[email protected]> Signed-off-by: Yan Zhao <[email protected]> [sean: handle name change, massage changelog, rebase] Tested-by: Yan Zhao <[email protected]> Tested-by: Yongwei Ma <[email protected]> Reviewed-by: Zhi Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent b83ab12 commit c15fcf1

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ struct gvt_dma {
108108

109109
static void kvmgt_page_track_write(gpa_t gpa, const u8 *val, int len,
110110
struct kvm_page_track_notifier_node *node);
111-
static void kvmgt_page_track_flush_slot(struct kvm *kvm,
112-
struct kvm_memory_slot *slot,
113-
struct kvm_page_track_notifier_node *node);
111+
static void kvmgt_page_track_remove_region(gfn_t gfn, unsigned long nr_pages,
112+
struct kvm_page_track_notifier_node *node);
114113

115114
static ssize_t intel_vgpu_show_description(struct mdev_type *mtype, char *buf)
116115
{
@@ -666,7 +665,7 @@ static int intel_vgpu_open_device(struct vfio_device *vfio_dev)
666665
return -EEXIST;
667666

668667
vgpu->track_node.track_write = kvmgt_page_track_write;
669-
vgpu->track_node.track_flush_slot = kvmgt_page_track_flush_slot;
668+
vgpu->track_node.track_remove_region = kvmgt_page_track_remove_region;
670669
kvm_get_kvm(vgpu->vfio_device.kvm);
671670
kvm_page_track_register_notifier(vgpu->vfio_device.kvm,
672671
&vgpu->track_node);
@@ -1617,22 +1616,20 @@ static void kvmgt_page_track_write(gpa_t gpa, const u8 *val, int len,
16171616
mutex_unlock(&info->vgpu_lock);
16181617
}
16191618

1620-
static void kvmgt_page_track_flush_slot(struct kvm *kvm,
1621-
struct kvm_memory_slot *slot,
1622-
struct kvm_page_track_notifier_node *node)
1619+
static void kvmgt_page_track_remove_region(gfn_t gfn, unsigned long nr_pages,
1620+
struct kvm_page_track_notifier_node *node)
16231621
{
16241622
unsigned long i;
1625-
gfn_t gfn;
16261623
struct intel_vgpu *info =
16271624
container_of(node, struct intel_vgpu, track_node);
16281625

16291626
mutex_lock(&info->vgpu_lock);
16301627

1631-
for (i = 0; i < slot->npages; i++) {
1632-
gfn = slot->base_gfn + i;
1633-
if (kvmgt_gfn_is_write_protected(info, gfn))
1634-
kvmgt_protect_table_del(info, gfn);
1628+
for (i = 0; i < nr_pages; i++) {
1629+
if (kvmgt_gfn_is_write_protected(info, gfn + i))
1630+
kvmgt_protect_table_del(info, gfn + i);
16351631
}
1632+
16361633
mutex_unlock(&info->vgpu_lock);
16371634
}
16381635

0 commit comments

Comments
 (0)