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

/*
 * KVMGT - the implementation of Intel mediated pass-through framework for KVM
 *
 * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * Authors:
 *    Kevin Tian <[email protected]>
 *    Jike Song <[email protected]>
 *    Xiaoguang Chen <[email protected]>
 *    Eddie Dong <[email protected]>
 *
 * Contributors:
 *    Niu Bing <[email protected]>
 *    Zhi Wang <[email protected]>
 */

#include <linux/init.h>
#include <linux/mm.h>
#include <linux/kthread.h>
#include <linux/sched/mm.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/rbtree.h>
#include <linux/spinlock.h>
#include <linux/eventfd.h>
#include <linux/mdev.h>
#include <linux/debugfs.h>

#include <linux/nospec.h>

#include <drm/drm_edid.h>

#include "i915_drv.h"
#include "intel_gvt.h"
#include "gvt.h"

MODULE_IMPORT_NS();
MODULE_IMPORT_NS();

/* helper macros copied from vfio-pci */
#define VFIO_PCI_OFFSET_SHIFT
#define VFIO_PCI_OFFSET_TO_INDEX(off)
#define VFIO_PCI_INDEX_TO_OFFSET(index)
#define VFIO_PCI_OFFSET_MASK

#define EDID_BLOB_OFFSET

#define OPREGION_SIGNATURE

struct vfio_region;
struct intel_vgpu_regops {};

struct vfio_region {};

struct vfio_edid_region {};

struct kvmgt_pgfn {};

struct gvt_dma {};

#define vfio_dev_to_vgpu(vfio_dev)

static void kvmgt_page_track_write(gpa_t gpa, const u8 *val, int len,
				   struct kvm_page_track_notifier_node *node);
static void kvmgt_page_track_remove_region(gfn_t gfn, unsigned long nr_pages,
					   struct kvm_page_track_notifier_node *node);

static ssize_t intel_vgpu_show_description(struct mdev_type *mtype, char *buf)
{}

static void gvt_unpin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
		unsigned long size)
{}

/* Pin a normal or compound guest page for dma. */
static int gvt_pin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
		unsigned long size, struct page **page)
{}

static int gvt_dma_map_page(struct intel_vgpu *vgpu, unsigned long gfn,
		dma_addr_t *dma_addr, unsigned long size)
{}

static void gvt_dma_unmap_page(struct intel_vgpu *vgpu, unsigned long gfn,
		dma_addr_t dma_addr, unsigned long size)
{}

static struct gvt_dma *__gvt_cache_find_dma_addr(struct intel_vgpu *vgpu,
		dma_addr_t dma_addr)
{}

static struct gvt_dma *__gvt_cache_find_gfn(struct intel_vgpu *vgpu, gfn_t gfn)
{}

static int __gvt_cache_add(struct intel_vgpu *vgpu, gfn_t gfn,
		dma_addr_t dma_addr, unsigned long size)
{}

static void __gvt_cache_remove_entry(struct intel_vgpu *vgpu,
				struct gvt_dma *entry)
{}

static void gvt_cache_destroy(struct intel_vgpu *vgpu)
{}

static void gvt_cache_init(struct intel_vgpu *vgpu)
{}

static void kvmgt_protect_table_init(struct intel_vgpu *info)
{}

static void kvmgt_protect_table_destroy(struct intel_vgpu *info)
{}

static struct kvmgt_pgfn *
__kvmgt_protect_table_find(struct intel_vgpu *info, gfn_t gfn)
{}

static bool kvmgt_gfn_is_write_protected(struct intel_vgpu *info, gfn_t gfn)
{}

static void kvmgt_protect_table_add(struct intel_vgpu *info, gfn_t gfn)
{}

static void kvmgt_protect_table_del(struct intel_vgpu *info, gfn_t gfn)
{}

static size_t intel_vgpu_reg_rw_opregion(struct intel_vgpu *vgpu, char *buf,
		size_t count, loff_t *ppos, bool iswrite)
{}

static void intel_vgpu_reg_release_opregion(struct intel_vgpu *vgpu,
		struct vfio_region *region)
{}

static const struct intel_vgpu_regops intel_vgpu_regops_opregion =;

static bool edid_valid(const void *edid, size_t size)
{}

static int handle_edid_regs(struct intel_vgpu *vgpu,
			struct vfio_edid_region *region, char *buf,
			size_t count, u16 offset, bool is_write)
{}

static int handle_edid_blob(struct vfio_edid_region *region, char *buf,
			size_t count, u16 offset, bool is_write)
{}

static size_t intel_vgpu_reg_rw_edid(struct intel_vgpu *vgpu, char *buf,
		size_t count, loff_t *ppos, bool iswrite)
{}

static void intel_vgpu_reg_release_edid(struct intel_vgpu *vgpu,
					struct vfio_region *region)
{}

static const struct intel_vgpu_regops intel_vgpu_regops_edid =;

static int intel_vgpu_register_reg(struct intel_vgpu *vgpu,
		unsigned int type, unsigned int subtype,
		const struct intel_vgpu_regops *ops,
		size_t size, u32 flags, void *data)
{}

int intel_gvt_set_opregion(struct intel_vgpu *vgpu)
{}

int intel_gvt_set_edid(struct intel_vgpu *vgpu, int port_num)
{}

static void intel_vgpu_dma_unmap(struct vfio_device *vfio_dev, u64 iova,
				 u64 length)
{}

static bool __kvmgt_vgpu_exist(struct intel_vgpu *vgpu)
{}

static int intel_vgpu_open_device(struct vfio_device *vfio_dev)
{}

static void intel_vgpu_release_msi_eventfd_ctx(struct intel_vgpu *vgpu)
{}

static void intel_vgpu_close_device(struct vfio_device *vfio_dev)
{}

static u64 intel_vgpu_get_bar_addr(struct intel_vgpu *vgpu, int bar)
{}

static int intel_vgpu_bar_rw(struct intel_vgpu *vgpu, int bar, u64 off,
			     void *buf, unsigned int count, bool is_write)
{}

static inline bool intel_vgpu_in_aperture(struct intel_vgpu *vgpu, u64 off)
{}

static int intel_vgpu_aperture_rw(struct intel_vgpu *vgpu, u64 off,
		void *buf, unsigned long count, bool is_write)
{}

static ssize_t intel_vgpu_rw(struct intel_vgpu *vgpu, char *buf,
			size_t count, loff_t *ppos, bool is_write)
{}

static bool gtt_entry(struct intel_vgpu *vgpu, loff_t *ppos)
{}

static ssize_t intel_vgpu_read(struct vfio_device *vfio_dev, char __user *buf,
			size_t count, loff_t *ppos)
{}

static ssize_t intel_vgpu_write(struct vfio_device *vfio_dev,
				const char __user *buf,
				size_t count, loff_t *ppos)
{}

static int intel_vgpu_mmap(struct vfio_device *vfio_dev,
		struct vm_area_struct *vma)
{}

static int intel_vgpu_get_irq_count(struct intel_vgpu *vgpu, int type)
{}

static int intel_vgpu_set_intx_mask(struct intel_vgpu *vgpu,
			unsigned int index, unsigned int start,
			unsigned int count, u32 flags,
			void *data)
{}

static int intel_vgpu_set_intx_unmask(struct intel_vgpu *vgpu,
			unsigned int index, unsigned int start,
			unsigned int count, u32 flags, void *data)
{}

static int intel_vgpu_set_intx_trigger(struct intel_vgpu *vgpu,
		unsigned int index, unsigned int start, unsigned int count,
		u32 flags, void *data)
{}

static int intel_vgpu_set_msi_trigger(struct intel_vgpu *vgpu,
		unsigned int index, unsigned int start, unsigned int count,
		u32 flags, void *data)
{}

static int intel_vgpu_set_irqs(struct intel_vgpu *vgpu, u32 flags,
		unsigned int index, unsigned int start, unsigned int count,
		void *data)
{}

static long intel_vgpu_ioctl(struct vfio_device *vfio_dev, unsigned int cmd,
			     unsigned long arg)
{}

static ssize_t
vgpu_id_show(struct device *dev, struct device_attribute *attr,
	     char *buf)
{}

static DEVICE_ATTR_RO(vgpu_id);

static struct attribute *intel_vgpu_attrs[] =;

static const struct attribute_group intel_vgpu_group =;

static const struct attribute_group *intel_vgpu_groups[] =;

static int intel_vgpu_init_dev(struct vfio_device *vfio_dev)
{}

static void intel_vgpu_release_dev(struct vfio_device *vfio_dev)
{}

static const struct vfio_device_ops intel_vgpu_dev_ops =;

static int intel_vgpu_probe(struct mdev_device *mdev)
{}

static void intel_vgpu_remove(struct mdev_device *mdev)
{}

static unsigned int intel_vgpu_get_available(struct mdev_type *mtype)
{}

static struct mdev_driver intel_vgpu_mdev_driver =;

int intel_gvt_page_track_add(struct intel_vgpu *info, u64 gfn)
{}

int intel_gvt_page_track_remove(struct intel_vgpu *info, u64 gfn)
{}

static void kvmgt_page_track_write(gpa_t gpa, const u8 *val, int len,
				   struct kvm_page_track_notifier_node *node)
{}

static void kvmgt_page_track_remove_region(gfn_t gfn, unsigned long nr_pages,
					   struct kvm_page_track_notifier_node *node)
{}

void intel_vgpu_detach_regions(struct intel_vgpu *vgpu)
{}

int intel_gvt_dma_map_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
		unsigned long size, dma_addr_t *dma_addr)
{}

int intel_gvt_dma_pin_guest_page(struct intel_vgpu *vgpu, dma_addr_t dma_addr)
{}

static void __gvt_dma_release(struct kref *ref)
{}

void intel_gvt_dma_unmap_guest_page(struct intel_vgpu *vgpu,
		dma_addr_t dma_addr)
{}

static void init_device_info(struct intel_gvt *gvt)
{}

static void intel_gvt_test_and_emulate_vblank(struct intel_gvt *gvt)
{}

static int gvt_service_thread(void *data)
{}

static void clean_service_thread(struct intel_gvt *gvt)
{}

static int init_service_thread(struct intel_gvt *gvt)
{}

/**
 * intel_gvt_clean_device - clean a GVT device
 * @i915: i915 private
 *
 * This function is called at the driver unloading stage, to free the
 * resources owned by a GVT device.
 *
 */
static void intel_gvt_clean_device(struct drm_i915_private *i915)
{}

/**
 * intel_gvt_init_device - initialize a GVT device
 * @i915: drm i915 private data
 *
 * This function is called at the initialization stage, to initialize
 * necessary GVT components.
 *
 * Returns:
 * Zero on success, negative error code if failed.
 *
 */
static int intel_gvt_init_device(struct drm_i915_private *i915)
{}

static void intel_gvt_pm_resume(struct drm_i915_private *i915)
{}

static const struct intel_vgpu_ops intel_gvt_vgpu_ops =;

static int __init kvmgt_init(void)
{}

static void __exit kvmgt_exit(void)
{}

module_init();
module_exit(kvmgt_exit);

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();