1 #ifndef _G_HYPERVISOR_NVOC_H_ 2 #define _G_HYPERVISOR_NVOC_H_ 3 #include "nvoc/runtime.h" 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 /* 10 * SPDX-FileCopyrightText: Copyright (c) 2014-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 11 * SPDX-License-Identifier: MIT 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining a 14 * copy of this software and associated documentation files (the "Software"), 15 * to deal in the Software without restriction, including without limitation 16 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 * and/or sell copies of the Software, and to permit persons to whom the 18 * Software is furnished to do so, subject to the following conditions: 19 * 20 * The above copyright notice and this permission notice shall be included in 21 * all copies or substantial portions of the Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 * DEALINGS IN THE SOFTWARE. 30 */ 31 #include "g_hypervisor_nvoc.h" 32 33 #ifndef HYPERVISOR_H 34 #define HYPERVISOR_H 35 36 /**************** Resource Manager Defines and Structures ******************\ 37 * * 38 * Module: hypervisor.h * 39 * Defines and structures used for the hypervisor object. * 40 \***************************************************************************/ 41 42 #include "core/core.h" 43 #include "nvoc/utility.h" 44 #include "nv-hypervisor.h" 45 #include "mem_mgr/mem.h" 46 47 /* ------------------------ Forward Declarations ---------------------------- */ 48 struct OBJOS; 49 50 #ifndef __NVOC_CLASS_OBJOS_TYPEDEF__ 51 #define __NVOC_CLASS_OBJOS_TYPEDEF__ 52 typedef struct OBJOS OBJOS; 53 #endif /* __NVOC_CLASS_OBJOS_TYPEDEF__ */ 54 55 #ifndef __nvoc_class_id_OBJOS 56 #define __nvoc_class_id_OBJOS 0xaa1d70 57 #endif /* __nvoc_class_id_OBJOS */ 58 59 60 61 typedef struct OBJHYPERVISOR *POBJHYPERVISOR; 62 63 #ifndef __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__ 64 #define __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__ 65 typedef struct OBJHYPERVISOR OBJHYPERVISOR; 66 #endif /* __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__ */ 67 68 #ifndef __nvoc_class_id_OBJHYPERVISOR 69 #define __nvoc_class_id_OBJHYPERVISOR 0x33c1ba 70 #endif /* __nvoc_class_id_OBJHYPERVISOR */ 71 72 73 typedef struct HOST_VGPU_DEVICE HOST_VGPU_DEVICE; 74 75 #ifdef NVOC_HYPERVISOR_H_PRIVATE_ACCESS_ALLOWED 76 #define PRIVATE_FIELD(x) x 77 #else 78 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x) 79 #endif 80 struct OBJHYPERVISOR { 81 const struct NVOC_RTTI *__nvoc_rtti; 82 struct Object __nvoc_base_Object; 83 struct Object *__nvoc_pbase_Object; 84 struct OBJHYPERVISOR *__nvoc_pbase_OBJHYPERVISOR; 85 NvBool PDB_PROP_HYPERVISOR_DRIVERVM_ENABLED; 86 NvBool bDetected; 87 NvBool bIsHVMGuest; 88 HYPERVISOR_TYPE type; 89 NvBool bIsHypervHost; 90 NvBool bIsHypervVgpuSupported; 91 }; 92 93 #ifndef __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__ 94 #define __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__ 95 typedef struct OBJHYPERVISOR OBJHYPERVISOR; 96 #endif /* __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__ */ 97 98 #ifndef __nvoc_class_id_OBJHYPERVISOR 99 #define __nvoc_class_id_OBJHYPERVISOR 0x33c1ba 100 #endif /* __nvoc_class_id_OBJHYPERVISOR */ 101 102 extern const struct NVOC_CLASS_DEF __nvoc_class_def_OBJHYPERVISOR; 103 104 #define __staticCast_OBJHYPERVISOR(pThis) \ 105 ((pThis)->__nvoc_pbase_OBJHYPERVISOR) 106 107 #ifdef __nvoc_hypervisor_h_disabled 108 #define __dynamicCast_OBJHYPERVISOR(pThis) ((OBJHYPERVISOR*)NULL) 109 #else //__nvoc_hypervisor_h_disabled 110 #define __dynamicCast_OBJHYPERVISOR(pThis) \ 111 ((OBJHYPERVISOR*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(OBJHYPERVISOR))) 112 #endif //__nvoc_hypervisor_h_disabled 113 114 #define PDB_PROP_HYPERVISOR_DRIVERVM_ENABLED_BASE_CAST 115 #define PDB_PROP_HYPERVISOR_DRIVERVM_ENABLED_BASE_NAME PDB_PROP_HYPERVISOR_DRIVERVM_ENABLED 116 117 NV_STATUS __nvoc_objCreateDynamic_OBJHYPERVISOR(OBJHYPERVISOR**, Dynamic*, NvU32, va_list); 118 119 NV_STATUS __nvoc_objCreate_OBJHYPERVISOR(OBJHYPERVISOR**, Dynamic*, NvU32); 120 #define __objCreate_OBJHYPERVISOR(ppNewObj, pParent, createFlags) \ 121 __nvoc_objCreate_OBJHYPERVISOR((ppNewObj), staticCast((pParent), Dynamic), (createFlags)) 122 123 NvBool hypervisorIsVgxHyper_IMPL(void); 124 125 126 #define hypervisorIsVgxHyper() hypervisorIsVgxHyper_IMPL() 127 #define hypervisorIsVgxHyper_HAL() hypervisorIsVgxHyper() 128 129 NV_STATUS hypervisorInjectInterrupt_IMPL(struct OBJHYPERVISOR *arg0, VGPU_NS_INTR *arg1); 130 131 132 #ifdef __nvoc_hypervisor_h_disabled 133 static inline NV_STATUS hypervisorInjectInterrupt(struct OBJHYPERVISOR *arg0, VGPU_NS_INTR *arg1) { 134 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!"); 135 return NV_ERR_NOT_SUPPORTED; 136 } 137 #else //__nvoc_hypervisor_h_disabled 138 #define hypervisorInjectInterrupt(arg0, arg1) hypervisorInjectInterrupt_IMPL(arg0, arg1) 139 #endif //__nvoc_hypervisor_h_disabled 140 141 #define hypervisorInjectInterrupt_HAL(arg0, arg1) hypervisorInjectInterrupt(arg0, arg1) 142 143 void hypervisorSetHypervVgpuSupported_IMPL(struct OBJHYPERVISOR *arg0); 144 145 146 #ifdef __nvoc_hypervisor_h_disabled 147 static inline void hypervisorSetHypervVgpuSupported(struct OBJHYPERVISOR *arg0) { 148 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!"); 149 } 150 #else //__nvoc_hypervisor_h_disabled 151 #define hypervisorSetHypervVgpuSupported(arg0) hypervisorSetHypervVgpuSupported_IMPL(arg0) 152 #endif //__nvoc_hypervisor_h_disabled 153 154 #define hypervisorSetHypervVgpuSupported_HAL(arg0) hypervisorSetHypervVgpuSupported(arg0) 155 156 NvBool hypervisorCheckForObjectAccess_IMPL(NvHandle hClient); 157 158 #define hypervisorCheckForObjectAccess(hClient) hypervisorCheckForObjectAccess_IMPL(hClient) 159 NvBool hypervisorIsType_IMPL(HYPERVISOR_TYPE hyperType); 160 161 #define hypervisorIsType(hyperType) hypervisorIsType_IMPL(hyperType) 162 NV_STATUS hypervisorConstruct_IMPL(struct OBJHYPERVISOR *arg_); 163 164 #define __nvoc_hypervisorConstruct(arg_) hypervisorConstruct_IMPL(arg_) 165 void hypervisorDestruct_IMPL(struct OBJHYPERVISOR *arg0); 166 167 #define __nvoc_hypervisorDestruct(arg0) hypervisorDestruct_IMPL(arg0) 168 NV_STATUS hypervisorDetection_IMPL(struct OBJHYPERVISOR *arg0, struct OBJOS *arg1); 169 170 #ifdef __nvoc_hypervisor_h_disabled 171 static inline NV_STATUS hypervisorDetection(struct OBJHYPERVISOR *arg0, struct OBJOS *arg1) { 172 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!"); 173 return NV_ERR_NOT_SUPPORTED; 174 } 175 #else //__nvoc_hypervisor_h_disabled 176 #define hypervisorDetection(arg0, arg1) hypervisorDetection_IMPL(arg0, arg1) 177 #endif //__nvoc_hypervisor_h_disabled 178 179 NvBool hypervisorPcieP2pDetection_IMPL(struct OBJHYPERVISOR *arg0, NvU32 arg1); 180 181 #ifdef __nvoc_hypervisor_h_disabled 182 static inline NvBool hypervisorPcieP2pDetection(struct OBJHYPERVISOR *arg0, NvU32 arg1) { 183 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!"); 184 return NV_FALSE; 185 } 186 #else //__nvoc_hypervisor_h_disabled 187 #define hypervisorPcieP2pDetection(arg0, arg1) hypervisorPcieP2pDetection_IMPL(arg0, arg1) 188 #endif //__nvoc_hypervisor_h_disabled 189 190 HYPERVISOR_TYPE hypervisorGetHypervisorType_IMPL(struct OBJHYPERVISOR *arg0); 191 192 #ifdef __nvoc_hypervisor_h_disabled 193 static inline HYPERVISOR_TYPE hypervisorGetHypervisorType(struct OBJHYPERVISOR *arg0) { 194 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!"); 195 HYPERVISOR_TYPE ret; 196 portMemSet(&ret, 0, sizeof(HYPERVISOR_TYPE)); 197 return ret; 198 } 199 #else //__nvoc_hypervisor_h_disabled 200 #define hypervisorGetHypervisorType(arg0) hypervisorGetHypervisorType_IMPL(arg0) 201 #endif //__nvoc_hypervisor_h_disabled 202 203 #undef PRIVATE_FIELD 204 205 206 #ifdef HAVE_DESIGNATED_INITIALIZERS 207 #define SFINIT(f, v) f = v 208 #else 209 #define SFINIT(f, v) v 210 #endif 211 212 // OPS for different hypervisor operations at runtime 213 214 // 215 // A hypervisor specific function for post detection (after hypervisor type 216 // has been identified). As the post detection, there could be hypervisor 217 // specific requirement to detect root/parent/child partition. 218 // 219 typedef NV_STATUS (*HypervisorPostDetection)(struct OBJOS *, NvBool *); 220 221 // 222 // A hypervisor specific function to identify if a hypervisor 223 // is allowed to run GPUs present in the mask (in: param) under 224 // PCI-E P2P configuration 225 // 226 typedef NvBool (*HypervisorIsPcieP2PSupported)(NvU32); 227 228 typedef struct _hypervisor_ops 229 { 230 const char *hypervisorName; 231 const char *hypervisorSig; 232 HypervisorPostDetection hypervisorPostDetection; 233 HypervisorIsPcieP2PSupported hypervisorIsPcieP2PSupported; 234 } HYPERVISOR_OPS, *PHYPERVISOR_OPS; 235 236 extern HYPERVISOR_OPS kvmHypervisorOps; 237 extern HYPERVISOR_OPS xenHypervisorOps; 238 extern HYPERVISOR_OPS hypervHypervisorOps; 239 extern HYPERVISOR_OPS vmwareHypervisorOps; 240 241 #endif // HYPERVISOR_H 242 243 #ifdef __cplusplus 244 } // extern "C" 245 #endif 246 #endif // _G_HYPERVISOR_NVOC_H_ 247