1 /* $NetBSD: hypercall.h,v 1.2 2021/12/18 23:45:31 riastradh Exp $ */ 2 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 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the next 14 * paragraph) shall be included in all copies or substantial portions of the 15 * Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 * SOFTWARE. 24 * 25 * Authors: 26 * Eddie Dong <eddie.dong@intel.com> 27 * Dexuan Cui 28 * Jike Song <jike.song@intel.com> 29 * 30 * Contributors: 31 * Zhi Wang <zhi.a.wang@intel.com> 32 * 33 */ 34 35 #ifndef _GVT_HYPERCALL_H_ 36 #define _GVT_HYPERCALL_H_ 37 38 #include <linux/types.h> 39 40 struct device; 41 42 enum hypervisor_type { 43 INTEL_GVT_HYPERVISOR_XEN = 0, 44 INTEL_GVT_HYPERVISOR_KVM, 45 }; 46 47 /* 48 * Specific GVT-g MPT modules function collections. Currently GVT-g supports 49 * both Xen and KVM by providing dedicated hypervisor-related MPT modules. 50 */ 51 struct intel_gvt_mpt { 52 enum hypervisor_type type; 53 int (*host_init)(struct device *dev, void *gvt, const void *ops); 54 void (*host_exit)(struct device *dev); 55 int (*attach_vgpu)(void *vgpu, unsigned long *handle); 56 void (*detach_vgpu)(void *vgpu); 57 int (*inject_msi)(unsigned long handle, u32 addr, u16 data); 58 unsigned long (*from_virt_to_mfn)(void *p); 59 int (*enable_page_track)(unsigned long handle, u64 gfn); 60 int (*disable_page_track)(unsigned long handle, u64 gfn); 61 int (*read_gpa)(unsigned long handle, unsigned long gpa, void *buf, 62 unsigned long len); 63 int (*write_gpa)(unsigned long handle, unsigned long gpa, void *buf, 64 unsigned long len); 65 unsigned long (*gfn_to_mfn)(unsigned long handle, unsigned long gfn); 66 67 int (*dma_map_guest_page)(unsigned long handle, unsigned long gfn, 68 unsigned long size, dma_addr_t *dma_addr); 69 void (*dma_unmap_guest_page)(unsigned long handle, dma_addr_t dma_addr); 70 71 int (*dma_pin_guest_page)(unsigned long handle, dma_addr_t dma_addr); 72 73 int (*map_gfn_to_mfn)(unsigned long handle, unsigned long gfn, 74 unsigned long mfn, unsigned int nr, bool map); 75 int (*set_trap_area)(unsigned long handle, u64 start, u64 end, 76 bool map); 77 int (*set_opregion)(void *vgpu); 78 int (*set_edid)(void *vgpu, int port_num); 79 int (*get_vfio_device)(void *vgpu); 80 void (*put_vfio_device)(void *vgpu); 81 bool (*is_valid_gfn)(unsigned long handle, unsigned long gfn); 82 }; 83 84 extern struct intel_gvt_mpt xengt_mpt; 85 86 #endif /* _GVT_HYPERCALL_H_ */ 87