1 /*- SPDX-License-Identifier: BSD-2-Clause-FreeBSD 2 * Copyright (c) 2009-2012,2016-2017, 2022 Microsoft Corp. 3 * Copyright (c) 2012 NetApp Inc. 4 * Copyright (c) 2012 Citrix Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** 30 * Implements low-level interactions with Hyper-V/Azure 31 */ 32 33 #include <sys/cdefs.h> 34 __FBSDID("$FreeBSD$"); 35 36 #include <sys/param.h> 37 #include <sys/systm.h> 38 #include <sys/kernel.h> 39 #include <sys/malloc.h> 40 #include <sys/timetc.h> 41 42 #include <vm/vm.h> 43 #include <vm/pmap.h> 44 #include <vm/vm_extern.h> 45 #include <vm/vm_kern.h> 46 47 #include <dev/hyperv/include/hyperv.h> 48 #include <dev/hyperv/include/hyperv_busdma.h> 49 #include <dev/hyperv/vmbus/aarch64/hyperv_machdep.h> 50 #include <dev/hyperv/vmbus/aarch64/hyperv_reg.h> 51 #include <dev/hyperv/vmbus/hyperv_var.h> 52 53 void hyperv_init_tc(void); 54 int hypercall_page_setup(vm_paddr_t); 55 void hypercall_disable(void); 56 bool hyperv_identify_features(void); 57 58 u_int hyperv_ver_major; 59 u_int hyperv_features; 60 u_int hyperv_recommends; 61 62 hyperv_tc64_t hyperv_tc64; 63 64 void 65 hyperv_init_tc(void) 66 { 67 hyperv_tc64 = NULL; 68 } 69 70 int 71 hypercall_page_setup(vm_paddr_t hc) 72 { 73 return (0); 74 } 75 76 void 77 hypercall_disable(void) 78 { 79 return; 80 } 81 82 bool 83 hyperv_identify_features(void) 84 { 85 struct hv_get_vp_registers_output result; 86 vm_guest = VM_GUEST_HV; 87 88 hv_get_vpreg_128(CPUID_LEAF_HV_FEATURES, &result); 89 hyperv_features = result.as32.a; 90 hv_get_vpreg_128(CPUID_LEAF_HV_IDENTITY, &result); 91 hyperv_ver_major = result.as32.b >> 16; 92 hv_get_vpreg_128(CPUID_LEAF_HV_RECOMMENDS, &result); 93 hyperv_recommends = result.as32.a; 94 return (true); 95 } 96 /*- SPDX-License-Identifier: BSD-2-Clause-FreeBSD 97 * Copyright (c) 2009-2012,2016-2017, 2022 Microsoft Corp. 98 * Copyright (c) 2012 NetApp Inc. 99 * Copyright (c) 2012 Citrix Inc. 100 * All rights reserved. 101 * 102 * Redistribution and use in source and binary forms, with or without 103 * modification, are permitted provided that the following conditions 104 * are met: 105 * 1. Redistributions of source code must retain the above copyright 106 * notice unmodified, this list of conditions, and the following 107 * disclaimer. 108 * 2. Redistributions in binary form must reproduce the above copyright 109 * notice, this list of conditions and the following disclaimer in the 110 * documentation and/or other materials provided with the distribution. 111 * 112 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 113 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 114 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 115 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 116 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 117 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 118 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 119 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 120 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 121 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 122 */ 123 124 /** 125 * Implements low-level interactions with Hyper-V/Azure 126 */ 127 128 #include <sys/cdefs.h> 129 __FBSDID("$FreeBSD$"); 130 131 #include <sys/param.h> 132 #include <sys/systm.h> 133 #include <sys/kernel.h> 134 #include <sys/malloc.h> 135 #include <sys/timetc.h> 136 137 #include <vm/vm.h> 138 #include <vm/pmap.h> 139 #include <vm/vm_extern.h> 140 #include <vm/vm_kern.h> 141 142 #include <dev/hyperv/include/hyperv.h> 143 #include <dev/hyperv/include/hyperv_busdma.h> 144 #include <dev/hyperv/vmbus/aarch64/hyperv_machdep.h> 145 #include <dev/hyperv/vmbus/aarch64/hyperv_reg.h> 146 #include <dev/hyperv/vmbus/hyperv_var.h> 147 148 void hyperv_init_tc(void); 149 int hypercall_page_setup(vm_paddr_t); 150 void hypercall_disable(void); 151 bool hyperv_identify_features(void); 152 153 u_int hyperv_ver_major; 154 u_int hyperv_features; 155 u_int hyperv_recommends; 156 157 hyperv_tc64_t hyperv_tc64; 158 159 void 160 hyperv_init_tc(void) 161 { 162 hyperv_tc64 = NULL; 163 } 164 165 int 166 hypercall_page_setup(vm_paddr_t hc) 167 { 168 return (0); 169 } 170 171 void 172 hypercall_disable(void) 173 { 174 return; 175 } 176 177 bool 178 hyperv_identify_features(void) 179 { 180 struct hv_get_vp_registers_output result; 181 vm_guest = VM_GUEST_HV; 182 183 hv_get_vpreg_128(CPUID_LEAF_HV_FEATURES, &result); 184 hyperv_features = result.as32.a; 185 hv_get_vpreg_128(CPUID_LEAF_HV_IDENTITY, &result); 186 hyperv_ver_major = result.as32.b >> 16; 187 hv_get_vpreg_128(CPUID_LEAF_HV_RECOMMENDS, &result); 188 hyperv_recommends = result.as32.a; 189 return (true); 190 } 191