1 /* $NetBSD: nvmm_ioctl.h,v 1.7.4.2 2020/08/29 17:00:28 martin Exp $ */ 2 3 /* 4 * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Maxime Villard. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _NVMM_IOCTL_H_ 33 #define _NVMM_IOCTL_H_ 34 35 #include <sys/ioccom.h> 36 37 #include <dev/virtual/nvmm/nvmm.h> 38 39 struct nvmm_ioc_capability { 40 struct nvmm_capability cap; 41 }; 42 43 struct nvmm_ioc_machine_create { 44 nvmm_machid_t machid; 45 }; 46 47 struct nvmm_ioc_machine_destroy { 48 nvmm_machid_t machid; 49 }; 50 51 struct nvmm_ioc_machine_configure { 52 nvmm_machid_t machid; 53 uint64_t op; 54 void *conf; 55 }; 56 57 struct nvmm_ioc_vcpu_create { 58 nvmm_machid_t machid; 59 nvmm_cpuid_t cpuid; 60 }; 61 62 struct nvmm_ioc_vcpu_destroy { 63 nvmm_machid_t machid; 64 nvmm_cpuid_t cpuid; 65 }; 66 67 struct nvmm_ioc_vcpu_configure { 68 nvmm_machid_t machid; 69 nvmm_cpuid_t cpuid; 70 uint64_t op; 71 void *conf; 72 }; 73 74 struct nvmm_ioc_vcpu_setstate { 75 nvmm_machid_t machid; 76 nvmm_cpuid_t cpuid; 77 }; 78 79 struct nvmm_ioc_vcpu_getstate { 80 nvmm_machid_t machid; 81 nvmm_cpuid_t cpuid; 82 }; 83 84 struct nvmm_ioc_vcpu_inject { 85 nvmm_machid_t machid; 86 nvmm_cpuid_t cpuid; 87 }; 88 89 struct nvmm_ioc_vcpu_run { 90 /* input */ 91 nvmm_machid_t machid; 92 nvmm_cpuid_t cpuid; 93 /* output */ 94 struct nvmm_vcpu_exit exit; 95 }; 96 97 struct nvmm_ioc_hva_map { 98 nvmm_machid_t machid; 99 uintptr_t hva; 100 size_t size; 101 int flags; 102 }; 103 104 struct nvmm_ioc_hva_unmap { 105 nvmm_machid_t machid; 106 uintptr_t hva; 107 size_t size; 108 int flags; 109 }; 110 111 struct nvmm_ioc_gpa_map { 112 nvmm_machid_t machid; 113 uintptr_t hva; 114 gpaddr_t gpa; 115 size_t size; 116 int prot; 117 }; 118 119 struct nvmm_ioc_gpa_unmap { 120 nvmm_machid_t machid; 121 gpaddr_t gpa; 122 size_t size; 123 }; 124 125 struct nvmm_ctl_mach_info { 126 /* input */ 127 nvmm_machid_t machid; 128 /* output */ 129 uint32_t nvcpus; 130 uint64_t nram; 131 pid_t pid; 132 time_t time; 133 }; 134 135 struct nvmm_ioc_ctl { 136 int op; 137 #define NVMM_CTL_MACH_INFO 0 138 139 void *data; 140 size_t size; 141 }; 142 143 #define NVMM_IOC_CAPABILITY _IOR ('N', 0, struct nvmm_ioc_capability) 144 #define NVMM_IOC_MACHINE_CREATE _IOWR('N', 1, struct nvmm_ioc_machine_create) 145 #define NVMM_IOC_MACHINE_DESTROY _IOW ('N', 2, struct nvmm_ioc_machine_destroy) 146 #define NVMM_IOC_MACHINE_CONFIGURE _IOW ('N', 3, struct nvmm_ioc_machine_configure) 147 #define NVMM_IOC_VCPU_CREATE _IOW ('N', 4, struct nvmm_ioc_vcpu_create) 148 #define NVMM_IOC_VCPU_DESTROY _IOW ('N', 5, struct nvmm_ioc_vcpu_destroy) 149 #define NVMM_IOC_VCPU_CONFIGURE _IOW ('N', 6, struct nvmm_ioc_vcpu_configure) 150 #define NVMM_IOC_VCPU_SETSTATE _IOW ('N', 7, struct nvmm_ioc_vcpu_setstate) 151 #define NVMM_IOC_VCPU_GETSTATE _IOW ('N', 8, struct nvmm_ioc_vcpu_getstate) 152 #define NVMM_IOC_VCPU_INJECT _IOW ('N', 9, struct nvmm_ioc_vcpu_inject) 153 #define NVMM_IOC_VCPU_RUN _IOWR('N', 10, struct nvmm_ioc_vcpu_run) 154 #define NVMM_IOC_GPA_MAP _IOW ('N', 11, struct nvmm_ioc_gpa_map) 155 #define NVMM_IOC_GPA_UNMAP _IOW ('N', 12, struct nvmm_ioc_gpa_unmap) 156 #define NVMM_IOC_HVA_MAP _IOW ('N', 13, struct nvmm_ioc_hva_map) 157 #define NVMM_IOC_HVA_UNMAP _IOW ('N', 14, struct nvmm_ioc_hva_unmap) 158 #define NVMM_IOC_CTL _IOW ('N', 20, struct nvmm_ioc_ctl) 159 160 #endif /* _NVMM_IOCTL_H_ */ 161