kvmgt.c (f2fbc72e6da4f8e01fe5fe3d6871a791e76271c3) kvmgt.c (685a1537f4c603cfcaf4b9be56ff6a571f7ddd08)
1/*
2 * KVMGT - the implementation of Intel mediated pass-through framework for KVM
3 *
4 * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation

--- 99 unchanged lines hidden (view full) ---

108
109static void kvmgt_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa,
110 const u8 *val, int len,
111 struct kvm_page_track_notifier_node *node);
112static void kvmgt_page_track_flush_slot(struct kvm *kvm,
113 struct kvm_memory_slot *slot,
114 struct kvm_page_track_notifier_node *node);
115
1/*
2 * KVMGT - the implementation of Intel mediated pass-through framework for KVM
3 *
4 * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation

--- 99 unchanged lines hidden (view full) ---

108
109static void kvmgt_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa,
110 const u8 *val, int len,
111 struct kvm_page_track_notifier_node *node);
112static void kvmgt_page_track_flush_slot(struct kvm *kvm,
113 struct kvm_memory_slot *slot,
114 struct kvm_page_track_notifier_node *node);
115
116static ssize_t description_show(struct mdev_type *mtype,
117 struct mdev_type_attribute *attr, char *buf)
116static ssize_t intel_vgpu_show_description(struct mdev_type *mtype, char *buf)
118{
119 struct intel_vgpu_type *type =
120 container_of(mtype, struct intel_vgpu_type, type);
121
122 return sprintf(buf, "low_gm_size: %dMB\nhigh_gm_size: %dMB\n"
123 "fence: %d\nresolution: %s\n"
124 "weight: %d\n",
125 BYTES_TO_MB(type->conf->low_mm),
126 BYTES_TO_MB(type->conf->high_mm),
127 type->conf->fence, vgpu_edid_str(type->conf->edid),
128 type->conf->weight);
129}
130
117{
118 struct intel_vgpu_type *type =
119 container_of(mtype, struct intel_vgpu_type, type);
120
121 return sprintf(buf, "low_gm_size: %dMB\nhigh_gm_size: %dMB\n"
122 "fence: %d\nresolution: %s\n"
123 "weight: %d\n",
124 BYTES_TO_MB(type->conf->low_mm),
125 BYTES_TO_MB(type->conf->high_mm),
126 type->conf->fence, vgpu_edid_str(type->conf->edid),
127 type->conf->weight);
128}
129
131static MDEV_TYPE_ATTR_RO(description);
132
133static const struct attribute *gvt_type_attrs[] = {
134 &mdev_type_attr_description.attr,
135 NULL,
136};
137
138static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
139 unsigned long size)
140{
141 vfio_unpin_pages(&vgpu->vfio_device, gfn << PAGE_SHIFT,
142 DIV_ROUND_UP(size, PAGE_SIZE));
143}
144
145/* Pin a normal or compound guest page for dma. */

--- 1398 unchanged lines hidden (view full) ---

1544
1545static struct mdev_driver intel_vgpu_mdev_driver = {
1546 .device_api = VFIO_DEVICE_API_PCI_STRING,
1547 .driver = {
1548 .name = "intel_vgpu_mdev",
1549 .owner = THIS_MODULE,
1550 .dev_groups = intel_vgpu_groups,
1551 },
130static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
131 unsigned long size)
132{
133 vfio_unpin_pages(&vgpu->vfio_device, gfn << PAGE_SHIFT,
134 DIV_ROUND_UP(size, PAGE_SIZE));
135}
136
137/* Pin a normal or compound guest page for dma. */

--- 1398 unchanged lines hidden (view full) ---

1536
1537static struct mdev_driver intel_vgpu_mdev_driver = {
1538 .device_api = VFIO_DEVICE_API_PCI_STRING,
1539 .driver = {
1540 .name = "intel_vgpu_mdev",
1541 .owner = THIS_MODULE,
1542 .dev_groups = intel_vgpu_groups,
1543 },
1552 .probe = intel_vgpu_probe,
1553 .remove = intel_vgpu_remove,
1554 .get_available = intel_vgpu_get_available,
1555 .types_attrs = gvt_type_attrs,
1544 .probe = intel_vgpu_probe,
1545 .remove = intel_vgpu_remove,
1546 .get_available = intel_vgpu_get_available,
1547 .show_description = intel_vgpu_show_description,
1556};
1557
1558int intel_gvt_page_track_add(struct intel_vgpu *info, u64 gfn)
1559{
1560 struct kvm *kvm = info->vfio_device.kvm;
1561 struct kvm_memory_slot *slot;
1562 int idx;
1563

--- 464 unchanged lines hidden ---
1548};
1549
1550int intel_gvt_page_track_add(struct intel_vgpu *info, u64 gfn)
1551{
1552 struct kvm *kvm = info->vfio_device.kvm;
1553 struct kvm_memory_slot *slot;
1554 int idx;
1555

--- 464 unchanged lines hidden ---