#include <linux/errno.h>
#include <linux/file.h>
#include <linux/kvm_host.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/vfio.h>
#include "vfio.h"
Go to the source code of this file.
◆ kvm_vfio_create()
static int kvm_vfio_create |
( |
struct kvm_device * |
dev, |
|
|
u32 |
type |
|
) |
| |
|
static |
Definition at line 364 of file vfio.c.
366 struct kvm_device *tmp;
370 list_for_each_entry(tmp, &dev->kvm->devices, vm_node)
374 kv = kzalloc(
sizeof(*kv), GFP_KERNEL_ACCOUNT);
379 mutex_init(&kv->
lock);
struct list_head file_list
static struct kvm_device_ops kvm_vfio_ops
◆ kvm_vfio_file_add()
static int kvm_vfio_file_add |
( |
struct kvm_device * |
dev, |
|
|
unsigned int |
fd |
|
) |
| |
|
static |
Definition at line 143 of file vfio.c.
160 mutex_lock(&kv->
lock);
162 list_for_each_entry(kvf, &kv->
file_list, node) {
163 if (kvf->
file == filp) {
169 kvf = kzalloc(
sizeof(*kvf), GFP_KERNEL_ACCOUNT);
175 kvf->
file = get_file(filp);
178 kvm_arch_start_assignment(dev->kvm);
183 mutex_unlock(&kv->
lock);
static void kvm_vfio_update_coherency(struct kvm_device *dev)
static bool kvm_vfio_file_is_valid(struct file *file)
static void kvm_vfio_file_set_kvm(struct file *file, struct kvm *kvm)
◆ kvm_vfio_file_del()
static int kvm_vfio_file_del |
( |
struct kvm_device * |
dev, |
|
|
unsigned int |
fd |
|
) |
| |
|
static |
Definition at line 189 of file vfio.c.
202 mutex_lock(&kv->
lock);
204 list_for_each_entry(kvf, &kv->
file_list, node) {
205 if (kvf->
file != f.file)
208 list_del(&kvf->
node);
209 kvm_arch_end_assignment(dev->kvm);
210 #ifdef CONFIG_SPAPR_TCE_IOMMU
211 kvm_spapr_tce_release_vfio_group(dev->kvm, kvf);
222 mutex_unlock(&kv->
lock);
◆ kvm_vfio_file_enforced_coherent()
static bool kvm_vfio_file_enforced_coherent |
( |
struct file * |
file | ) |
|
|
static |
Definition at line 51 of file vfio.c.
53 bool (*fn)(
struct file *file);
56 fn = symbol_get(vfio_file_enforced_coherent);
62 symbol_put(vfio_file_enforced_coherent);
◆ kvm_vfio_file_is_valid()
static bool kvm_vfio_file_is_valid |
( |
struct file * |
file | ) |
|
|
static |
Definition at line 67 of file vfio.c.
69 bool (*fn)(
struct file *file);
72 fn = symbol_get(vfio_file_is_valid);
78 symbol_put(vfio_file_is_valid);
◆ kvm_vfio_file_set_kvm()
static void kvm_vfio_file_set_kvm |
( |
struct file * |
file, |
|
|
struct kvm * |
kvm |
|
) |
| |
|
static |
Definition at line 38 of file vfio.c.
40 void (*fn)(
struct file *file,
struct kvm *kvm);
42 fn = symbol_get(vfio_file_set_kvm);
48 symbol_put(vfio_file_set_kvm);
◆ kvm_vfio_has_attr()
static int kvm_vfio_has_attr |
( |
struct kvm_device * |
dev, |
|
|
struct kvm_device_attr * |
attr |
|
) |
| |
|
static |
Definition at line 312 of file vfio.c.
315 switch (attr->group) {
316 case KVM_DEV_VFIO_FILE:
317 switch (attr->attr) {
318 case KVM_DEV_VFIO_FILE_ADD:
319 case KVM_DEV_VFIO_FILE_DEL:
320 #ifdef CONFIG_SPAPR_TCE_IOMMU
321 case KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE:
◆ kvm_vfio_ops_exit()
void kvm_vfio_ops_exit |
( |
void |
| ) |
|
Definition at line 391 of file vfio.c.
void kvm_unregister_device_ops(u32 type)
◆ kvm_vfio_ops_init()
int kvm_vfio_ops_init |
( |
void |
| ) |
|
Definition at line 386 of file vfio.c.
int kvm_register_device_ops(const struct kvm_device_ops *ops, u32 type)
◆ kvm_vfio_release()
static void kvm_vfio_release |
( |
struct kvm_device * |
dev | ) |
|
|
static |
Definition at line 332 of file vfio.c.
338 #ifdef CONFIG_SPAPR_TCE_IOMMU
339 kvm_spapr_tce_release_vfio_group(dev->kvm, kvf);
343 list_del(&kvf->
node);
345 kvm_arch_end_assignment(dev->kvm);
◆ kvm_vfio_set_attr()
static int kvm_vfio_set_attr |
( |
struct kvm_device * |
dev, |
|
|
struct kvm_device_attr * |
attr |
|
) |
| |
|
static |
Definition at line 300 of file vfio.c.
303 switch (attr->group) {
304 case KVM_DEV_VFIO_FILE:
306 u64_to_user_ptr(attr->addr));
static int kvm_vfio_set_file(struct kvm_device *dev, long attr, void __user *arg)
◆ kvm_vfio_set_file()
static int kvm_vfio_set_file |
( |
struct kvm_device * |
dev, |
|
|
long |
attr, |
|
|
void __user * |
arg |
|
) |
| |
|
static |
Definition at line 274 of file vfio.c.
277 int32_t __user *argp = arg;
281 case KVM_DEV_VFIO_FILE_ADD:
282 if (get_user(fd, argp))
286 case KVM_DEV_VFIO_FILE_DEL:
287 if (get_user(fd, argp))
291 #ifdef CONFIG_SPAPR_TCE_IOMMU
292 case KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE:
293 return kvm_vfio_file_set_spapr_tce(dev, arg);
static int kvm_vfio_file_del(struct kvm_device *dev, unsigned int fd)
static int kvm_vfio_file_add(struct kvm_device *dev, unsigned int fd)
◆ kvm_vfio_update_coherency()
static void kvm_vfio_update_coherency |
( |
struct kvm_device * |
dev | ) |
|
|
static |
Definition at line 120 of file vfio.c.
137 kvm_arch_register_noncoherent_dma(dev->kvm);
139 kvm_arch_unregister_noncoherent_dma(dev->kvm);
static bool kvm_vfio_file_enforced_coherent(struct file *file)
◆ kvm_vfio_ops
struct kvm_device_ops kvm_vfio_ops |
|
static |
Initial value:= {
.name = "kvm-vfio",
}
static void kvm_vfio_release(struct kvm_device *dev)
static int kvm_vfio_create(struct kvm_device *dev, u32 type)
static int kvm_vfio_has_attr(struct kvm_device *dev, struct kvm_device_attr *attr)
static int kvm_vfio_set_attr(struct kvm_device *dev, struct kvm_device_attr *attr)
Definition at line 354 of file vfio.c.