Changeset 58872 in vbox
- Timestamp:
- Nov 26, 2015 2:17:48 AM (9 years ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp
r58772 r58872 4650 4650 pReq->u.Out.fNeedsLoading = true; 4651 4651 pReq->u.Out.fNativeLoader = pImage->fNative; 4652 supdrvOSLdrNotifyOpened(pDevExt, pImage );4652 supdrvOSLdrNotifyOpened(pDevExt, pImage, pReq->u.In.szFilename); 4653 4653 4654 4654 supdrvLdrUnlock(pDevExt); … … 5399 5399 supdrvTracerModuleUnloading(pDevExt, pImage); 5400 5400 5401 /* do native unload if appropriate. */ 5401 /* Do native unload if appropriate, then inform the native code about the 5402 unloading (mainly for non-native loading case). */ 5402 5403 if (pImage->fNative) 5403 5404 supdrvOSLdrUnload(pDevExt, pImage); 5405 supdrvOSLdrNotifyUnloaded(pDevExt, pImage); 5404 5406 5405 5407 /* free the image */ -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r58340 r58872 391 391 /** Pointer to the module control structure. */ 392 392 struct modctl *pSolModCtl; 393 #endif 394 #ifdef RT_OS_LINUX 395 /** Hack for seeing the module in perf, dtrace and other stack crawlers. */ 396 struct module *pLnxModHack; 397 /** Hack for seeing the module in perf, dtrace and other stack crawlers . 398 * Required for Linux v3.19+. */ 399 struct supdrv_ftrace_ops *pLnxFTraceHack; 393 400 #endif 394 401 /** Whether it's loaded by the native loader or not. */ … … 848 855 * Notification call indicating that a image is being opened for the first time. 849 856 * 850 * Can be used to log the load address of the image. 857 * Called for both native and non-native images (after supdrvOSLdrOpen). Can be 858 * used to log the load address of the image or inform the kernel about the 859 * alien image. 851 860 * 852 861 * @param pDevExt The device globals. 853 862 * @param pImage The image handle. 854 */ 855 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage); 863 * @param pszFilename The file name - UTF-8, may containing UNIX 864 * slashes on non-UNIX systems. 865 */ 866 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename); 856 867 857 868 /** … … 884 895 885 896 /** 886 * Unload the image .897 * Unload the image (only called if supdrvOSLdrOpen returned success). 887 898 * 888 899 * @param pDevExt The device globals. … … 890 901 */ 891 902 void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage); 903 904 /** 905 * Notification call indicating that a image is being unloaded. 906 * 907 * Called for both native and non-native images. In the former case, it's 908 * called after supdrvOSLdrUnload. 909 * 910 * @param pDevExt The device globals. 911 * @param pImage The image handle. 912 */ 913 void VBOXCALL supdrvOSLdrNotifyUnloaded(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage); 892 914 893 915 -
trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
r58340 r58872 1136 1136 } 1137 1137 1138 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 1138 1139 int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename) 1140 { 1141 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename); 1142 return VERR_NOT_SUPPORTED; 1143 } 1144 1145 1146 int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits) 1147 { 1148 NOREF(pDevExt); NOREF(pImage); NOREF(pv); NOREF(pbImageBits); 1149 return VERR_NOT_SUPPORTED; 1150 } 1151 1152 1153 int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq) 1154 { 1155 NOREF(pDevExt); NOREF(pImage); NOREF(pbImageBits); NOREF(pReq); 1156 return VERR_NOT_SUPPORTED; 1157 } 1158 1159 1160 void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 1161 { 1162 NOREF(pDevExt); NOREF(pImage); 1163 } 1164 1165 1166 void VBOXCALL supdrvOSLdrNotifyLoaded(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 1167 { 1168 NOREF(pDevExt); NOREF(pImage); 1169 } 1170 1171 1172 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename) 1139 1173 { 1140 1174 #if 1 1141 NOREF(pDevExt); NOREF(pImage); 1175 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename); 1142 1176 #else 1143 1177 /* … … 1163 1197 1164 1198 1165 int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename) 1166 { 1167 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename); 1168 return VERR_NOT_SUPPORTED; 1169 } 1170 1171 1172 int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits) 1173 { 1174 NOREF(pDevExt); NOREF(pImage); NOREF(pv); NOREF(pbImageBits); 1175 return VERR_NOT_SUPPORTED; 1176 } 1177 1178 1179 int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq) 1180 { 1181 NOREF(pDevExt); NOREF(pImage); NOREF(pbImageBits); NOREF(pReq); 1182 return VERR_NOT_SUPPORTED; 1183 } 1184 1185 1186 void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 1199 void VBOXCALL supdrvOSLdrNotifyUnloaded(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 1187 1200 { 1188 1201 NOREF(pDevExt); NOREF(pImage); -
trunk/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
r58340 r58872 560 560 561 561 562 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)563 {564 NOREF(pDevExt); NOREF(pImage);565 }566 567 568 562 int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits) 569 563 { … … 581 575 582 576 void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 577 { 578 NOREF(pDevExt); NOREF(pImage); 579 } 580 581 582 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename) 583 { 584 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename); 585 } 586 587 588 void VBOXCALL supdrvOSLdrNotifyUnloaded(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 583 589 { 584 590 NOREF(pDevExt); NOREF(pImage); -
trunk/src/VBox/HostDrivers/Support/linux/Makefile
r57313 r58872 288 288 289 289 # build defs 290 EXTRA_CFLAGS += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG) 290 EXTRA_CFLAGS += -include $(MANGLING) $(INCL) $(KFLAGS) $(KDEBUG) -fno-omit-frame-pointer 291 291 292 292 all: $(MODULE) -
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r58340 r58872 65 65 # include <asm/msr.h> 66 66 #endif 67 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) && defined(CONFIG_DYNAMIC_FTRACE) 68 # include <linux/ftrace.h> 69 #endif 70 67 71 #include <iprt/asm-amd64-x86.h> 68 72 … … 940 944 941 945 942 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)943 {944 NOREF(pDevExt); NOREF(pImage);945 }946 947 948 946 int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits) 949 947 { … … 962 960 void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 963 961 { 962 NOREF(pDevExt); NOREF(pImage); 963 } 964 965 966 /** @def VBOX_WITH_NON_PROD_HACK_FOR_PERF_STACKS 967 * A very crude hack for debugging using perf and dtrace. 968 * 969 * DO ABSOLUTELY NOT ENABLE IN PRODUCTION BUILDS! DEVELOPMENT ONLY!! 970 * DO ABSOLUTELY NOT ENABLE IN PRODUCTION BUILDS! DEVELOPMENT ONLY!! 971 * DO ABSOLUTELY NOT ENABLE IN PRODUCTION BUILDS! DEVELOPMENT ONLY!! 972 * 973 */ 974 #if 0 || defined(DOXYGEN_RUNNING) 975 # define VBOX_WITH_NON_PROD_HACK_FOR_PERF_STACKS 976 #endif 977 978 #if defined(VBOX_WITH_NON_PROD_HACK_FOR_PERF_STACKS) && defined(CONFIG_MODULES_TREE_LOOKUP) 979 /** Whether g_pfnModTreeInsert and g_pfnModTreeRemove have been initialized. 980 * @remarks can still be NULL after init. */ 981 static volatile bool g_fLookedForModTreeFunctions = false; 982 static void (*g_pfnModTreeInsert)(struct mod_tree_node *) = NULL; /**< __mod_tree_insert */ 983 static void (*g_pfnModTreeRemove)(struct mod_tree_node *) = NULL; /**< __mod_tree_remove */ 984 #endif 985 986 #if 0 /* instant host lockup, can't be bothered debugging it */ 987 #if defined(VBOX_WITH_NON_PROD_HACK_FOR_PERF_STACKS) \ 988 && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) \ 989 && defined(CONFIG_MODULES_TREE_LOOKUP) \ 990 && defined(CONFIG_DYNAMIC_FTRACE) 991 992 /** 993 * Using a static array here because that's what is suggested in the docs to 994 * avoid/reduce potential race conditions. 995 */ 996 static struct supdrv_ftrace_ops 997 { 998 struct ftrace_ops Core; 999 bool volatile fUsed; 1000 } g_aFTraceOps[16] __read_mostly; 1001 1002 /** Stub function for the ugly debug hack below. */ 1003 static void notrace __attribute__((optimize("-fomit-frame-pointer"))) 1004 supdrvLnxFTraceStub(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct pt_regs *regs) 1005 { 1006 return; 1007 } 1008 1009 #endif 1010 #endif 1011 1012 1013 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename) 1014 { 1015 #ifdef VBOX_WITH_NON_PROD_HACK_FOR_PERF_STACKS /* Not for production use!! Debugging only! */ 1016 /* 1017 * This trick stops working with 4.2 when CONFIG_MODULES_TREE_LOOKUP is 1018 * defined. The module lookups are done via a tree structure and we 1019 * cannot get at the root of it. :-( 1020 */ 1021 # ifdef CONFIG_KALLSYMS 1022 size_t const cchName = strlen(pImage->szName); 1023 # endif 1024 struct module *pMyMod, *pSelfMod, *pTestMod, *pTestModByName; 1025 IPRT_LINUX_SAVE_EFL_AC(); 1026 1027 pImage->pLnxModHack = NULL; 1028 pImage->pLnxFTraceHack = NULL; 1029 1030 # ifdef CONFIG_MODULES_TREE_LOOKUP 1031 /* 1032 * This is pretty naive, but works for 4.2 on arch linux. I don't think we 1033 * can count on finding __mod_tree_remove in all kernel builds as it's not 1034 * marked noinline like __mod_tree_insert. 1035 */ 1036 if (!g_fLookedForModTreeFunctions) 1037 { 1038 unsigned long ulInsert = kallsyms_lookup_name("__mod_tree_insert"); 1039 unsigned long ulRemove = kallsyms_lookup_name("__mod_tree_remove"); 1040 if (!ulInsert || !ulRemove) 1041 { 1042 g_fLookedForModTreeFunctions = true; 1043 printk(KERN_ERR "vboxdrv: failed to locate __mod_tree_insert and __mod_tree_remove.\n"); 1044 IPRT_LINUX_RESTORE_EFL_AC(); 1045 return; 1046 } 1047 *(unsigned long *)&g_pfnModTreeInsert = ulInsert; 1048 *(unsigned long *)&g_pfnModTreeRemove = ulRemove; 1049 ASMCompilerBarrier(); 1050 g_fLookedForModTreeFunctions = true; 1051 } 1052 else if (!g_pfnModTreeInsert || !g_pfnModTreeRemove) 1053 return; 1054 #endif 1055 1056 /* 1057 * Make sure we've found our own module, otherwise we cannot access the linked list. 1058 */ 1059 mutex_lock(&module_mutex); 1060 pSelfMod = find_module("vboxdrv"); 1061 mutex_unlock(&module_mutex); 1062 if (!pSelfMod) 1063 { 1064 IPRT_LINUX_RESTORE_EFL_AC(); 1065 return; 1066 } 1067 1068 /* 1069 * Cook up a module structure for the image. 1070 * We allocate symbol and string tables in the allocation and the module to keep things simple. 1071 */ 1072 # ifdef CONFIG_KALLSYMS 1073 pMyMod = (struct module *)RTMemAllocZ(sizeof(*pMyMod) 1074 + sizeof(Elf_Sym) * 3 1075 + 1 + cchName * 2 + sizeof("_start") + sizeof("_end") + 4 ); 1076 # else 1077 pMyMod = (struct module *)RTMemAllocZ(sizeof(*pMyMod)); 1078 # endif 1079 if (pMyMod) 1080 { 1081 int rc = VINF_SUCCESS; 1082 //size_t cch; 1083 # ifdef CONFIG_KALLSYMS 1084 Elf_Sym *paSymbols = (Elf_Sym *)(pMyMod + 1); 1085 char *pchStrTab = (char *)(paSymbols + 3); 1086 # endif 1087 1088 pMyMod->state = MODULE_STATE_LIVE; 1089 INIT_LIST_HEAD(&pMyMod->list); /* just in case */ 1090 1091 /* Come up with a good name that perf can translate with minimum help... */ 1092 # if 0 1093 cch = strlen(pszFilename); 1094 if (cch < sizeof(pMyMod->name)) 1095 memcpy(pMyMod->name, pszFilename, cch + 1); 1096 else 1097 { 1098 const char *pszTmp = pszFilename; 1099 for (;;) 1100 { 1101 /* skip one path component. */ 1102 while (*pszTmp == '/') 1103 pszTmp++, cch--; 1104 while (*pszTmp != '/' && *pszTmp != '\0') 1105 pszTmp++, cch--; 1106 1107 /* If we've skipped past the final component, hack something up based on the module name. */ 1108 if (*pszTmp != '/') 1109 { 1110 RTStrPrintf(pMyMod->name, sizeof(pMyMod->name), "/opt/VirtualBox/%s", pImage->szName); 1111 break; 1112 } 1113 /* When we've got space for two dots and the remaining path, we're done. */ 1114 if (cch + 2 < sizeof(pMyMod->name)) 1115 { 1116 pMyMod->name[0] = '.'; 1117 pMyMod->name[1] = '.'; 1118 memcpy(&pMyMod->name[2], pszTmp, cch + 1); 1119 break; 1120 } 1121 } 1122 } 1123 # else 1124 /* Perf only matches up files with a .ko extension (maybe .ko.gz), 1125 so in order for this crap to work smoothly, we append .ko to the 1126 module name and require the user to create symbolic links in 1127 /lib/modules/`uname -r`: 1128 for i in VMMR0.r0 VBoxDDR0.r0 VBoxDD2R0.r0; do 1129 sudo ln -s /mnt/scratch/vbox/svn/trunk/out/linux.amd64/debug/bin/$i /lib/modules/`uname -r`/$i.ko; 1130 done */ 1131 RTStrPrintf(pMyMod->name, sizeof(pMyMod->name), "%s", pImage->szName); 1132 # endif 1133 1134 /* sysfs bits. */ 1135 INIT_LIST_HEAD(&pMyMod->mkobj.kobj.entry); /* rest of kobj is already zeroed, hopefully never accessed... */ 1136 pMyMod->mkobj.mod = pMyMod; 1137 pMyMod->mkobj.drivers_dir = NULL; 1138 pMyMod->mkobj.mp = NULL; 1139 pMyMod->mkobj.kobj_completion = NULL; 1140 1141 pMyMod->modinfo_attrs = NULL; /* hopefully not accessed after setup. */ 1142 pMyMod->holders_dir = NULL; /* hopefully not accessed. */ 1143 pMyMod->version = "N/A"; 1144 pMyMod->srcversion = "N/A"; 1145 1146 /* We export no symbols. */ 1147 pMyMod->num_syms = 0; 1148 pMyMod->syms = NULL; 1149 pMyMod->crcs = NULL; 1150 1151 pMyMod->num_gpl_syms = 0; 1152 pMyMod->gpl_syms = NULL; 1153 pMyMod->gpl_crcs = NULL; 1154 1155 pMyMod->num_gpl_future_syms = 0; 1156 pMyMod->gpl_future_syms = NULL; 1157 pMyMod->gpl_future_crcs = NULL; 1158 1159 # if CONFIG_UNUSED_SYMBOLS 1160 pMyMod->num_unused_syms = 0; 1161 pMyMod->unused_syms = NULL; 1162 pMyMod->unused_crcs = NULL; 1163 1164 pMyMod->num_unused_gpl_syms = 0; 1165 pMyMod->unused_gpl_syms = NULL; 1166 pMyMod->unused_gpl_crcs = NULL; 1167 # endif 1168 /* No kernel parameters either. */ 1169 pMyMod->kp = NULL; 1170 pMyMod->num_kp = 0; 1171 1172 # ifdef CONFIG_MODULE_SIG 1173 /* Pretend ok signature. */ 1174 pMyMod->sig_ok = true; 1175 # endif 1176 /* No exception table. */ 1177 pMyMod->num_exentries = 0; 1178 pMyMod->extable = NULL; 1179 1180 /* No init function */ 1181 pMyMod->init = NULL; 1182 pMyMod->module_init = NULL; 1183 pMyMod->init_size = 0; 1184 pMyMod->init_ro_size = 0; 1185 pMyMod->init_text_size = 0; 1186 1187 /* The module address and size. It's all text. */ 1188 pMyMod->module_core = pImage->pvImage; 1189 pMyMod->core_size = pImage->cbImageBits; 1190 pMyMod->core_text_size = pImage->cbImageBits; 1191 pMyMod->core_ro_size = pImage->cbImageBits; 1192 1193 #ifdef CONFIG_MODULES_TREE_LOOKUP 1194 /* Fill in the self pointers for the tree nodes. */ 1195 pMyMod->mtn_core.mod = pMyMod; 1196 pMyMod->mtn_init.mod = pMyMod; 1197 #endif 1198 /* They invented the tained bit for us, didn't they? */ 1199 pMyMod->taints = 1; 1200 1201 # ifdef CONFIG_GENERIC_BUGS 1202 /* No BUGs in our modules. */ 1203 pMyMod->num_bugs = 0; 1204 INIT_LIST_HEAD(&pMyMod->bug_list); 1205 pMyMod->bug_table = NULL; 1206 # endif 1207 1208 # ifdef CONFIG_KALLSYMS 1209 /* The core stuff is documented as only used when loading. So just zero them. */ 1210 pMyMod->core_num_syms = 0; 1211 pMyMod->core_symtab = NULL; 1212 pMyMod->core_strtab = NULL; 1213 1214 /* Construct a symbol table with start and end symbols. 1215 Note! We don't have our own symbol table at this point, image bit 1216 are not uploaded yet! */ 1217 pMyMod->num_symtab = 3; 1218 pMyMod->symtab = paSymbols; 1219 pMyMod->strtab = pchStrTab; 1220 RT_ZERO(paSymbols[0]); 1221 pchStrTab[0] = '\0'; 1222 paSymbols[1].st_name = 1; 1223 paSymbols[2].st_name = 2 + RTStrPrintf(&pchStrTab[paSymbols[1].st_name], cchName + sizeof("_start"), 1224 "%s_start", pImage->szName); 1225 RTStrPrintf(&pchStrTab[paSymbols[2].st_name], cchName + sizeof("_end"), "%s_end", pImage->szName); 1226 paSymbols[1].st_info = 't'; 1227 paSymbols[2].st_info = 'b'; 1228 paSymbols[1].st_other = 0; 1229 paSymbols[2].st_other = 0; 1230 paSymbols[1].st_shndx = 0; 1231 paSymbols[2].st_shndx = 0; 1232 paSymbols[1].st_value = (uintptr_t)pImage->pvImage; 1233 paSymbols[2].st_value = (uintptr_t)pImage->pvImage + pImage->cbImageBits - 1; 1234 paSymbols[1].st_size = pImage->cbImageBits - 1; 1235 paSymbols[2].st_size = 1; 1236 # endif 1237 /* No arguments, but seems its always non-NULL so put empty string there. */ 1238 pMyMod->args = ""; 1239 1240 # ifdef CONFIG_SMP 1241 /* No per CPU data. */ 1242 pMyMod->percpu = NULL; 1243 pMyMod->percpu_size = 0; 1244 # endif 1245 # ifdef CONFIG_TRACEPOINTS 1246 /* No tracepoints we like to share. */ 1247 pMyMod->num_tracepoints = 0; 1248 pMyMod->tracepoints_ptrs = NULL; 1249 #endif 1250 # ifdef HAVE_JUMP_LABEL 1251 /* No jump lable stuff either. */ 1252 pMyMod->jump_entries = NULL; 1253 pMyMod->num_jump_entries = 0; 1254 # endif 1255 # ifdef CONFIG_TRACING 1256 pMyMod->num_trace_bprintk_fmt = 0; 1257 pMyMod->trace_bprintk_fmt_start = NULL; 1258 # endif 1259 # ifdef CONFIG_EVENT_TRACING 1260 pMyMod->trace_events = NULL; 1261 pMyMod->num_trace_events = 0; 1262 # endif 1263 # ifdef CONFIG_FTRACE_MCOUNT_RECORD 1264 pMyMod->num_ftrace_callsites = 0; 1265 pMyMod->ftrace_callsites = NULL; 1266 # endif 1267 # ifdef CONFIG_MODULE_UNLOAD 1268 /* Dependency lists, not worth sharing */ 1269 INIT_LIST_HEAD(&pMyMod->source_list); 1270 INIT_LIST_HEAD(&pMyMod->target_list); 1271 1272 /* Nobody waiting and no exit function. */ 1273 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0) 1274 pMyMod->waiter = NULL; 1275 # endif 1276 pMyMod->exit = NULL; 1277 1278 /* References, very important as we must not allow the module 1279 to be unloaded using rmmod. */ 1280 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) 1281 atomic_set(&pMyMod->refcnt, 42); 1282 # else 1283 pMyMod->refptr = alloc_percpu(struct module_ref); 1284 if (pMyMod->refptr) 1285 { 1286 int iCpu; 1287 for_each_possible_cpu(iCpu) 1288 { 1289 per_cpu_ptr(pMyMod->refptr, iCpu)->decs = 0; 1290 per_cpu_ptr(pMyMod->refptr, iCpu)->incs = 1; 1291 } 1292 } 1293 else 1294 rc = VERR_NO_MEMORY; 1295 # endif 1296 # endif 1297 # ifdef CONFIG_CONSTRUCTORS 1298 /* No constructors. */ 1299 pMyMod->ctors = NULL; 1300 pMyMod->num_ctors = 0; 1301 # endif 1302 if (RT_SUCCESS(rc)) 1303 { 1304 bool fIsModText; 1305 1306 /* 1307 * Add the module to the list. 1308 */ 1309 mutex_lock(&module_mutex); 1310 list_add_rcu(&pMyMod->list, &pSelfMod->list); 1311 pImage->pLnxModHack = pMyMod; 1312 # ifdef CONFIG_MODULES_TREE_LOOKUP 1313 g_pfnModTreeInsert(&pMyMod->mtn_core); /* __mod_tree_insert */ 1314 # endif 1315 mutex_unlock(&module_mutex); 1316 1317 #if 0 /* Horrible, non-working hack. Debug when __mod_tree_remove can't be found on a box we care about. */ 1318 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) && defined(CONFIG_MODULES_TREE_LOOKUP) 1319 # if defined(CONFIG_DYNAMIC_FTRACE) 1320 /* 1321 * Starting with 4.2 there's the module tree lookup which thwarts 1322 * the above module hack. So, we must install an additional hack 1323 * to get the job done. This relies on dynmaic ftrace trampolines 1324 * and is just as ugly as the above. Only for debugging!! 1325 */ 1326 uint32_t i = 0; 1327 while (i < RT_ELEMENTS(g_aFTraceOps) 1328 && ASMAtomicXchgBool(&g_aFTraceOps[i].fUsed, true) == true) 1329 i++; 1330 if (i < RT_ELEMENTS(g_aFTraceOps)) 1331 { 1332 struct supdrv_ftrace_ops *pOps = &g_aFTraceOps[i]; 1333 pOps->Core.func = supdrvLnxFTraceStub; 1334 pOps->Core.flags = /*FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_STUB |*/ FTRACE_OPS_FL_DYNAMIC; 1335 pOps->Core.trampoline = (uintptr_t)pImage->pvImage; 1336 pOps->Core.trampoline_size = (uintptr_t)pImage->cbImageBits; 1337 1338 rc = register_ftrace_function(&pOps->Core); 1339 if (rc == 0) 1340 pImage->pLnxFTraceHack = pOps; 1341 else 1342 printk(KERN_ERR "vboxdrv: register_ftrace_function failed: %d\n", rc); 1343 } 1344 # else 1345 # error "Sorry, without CONFIG_DYNAMIC_FTRACE currently not possible to get proper stack traces" 1346 # endif 1347 # endif 1348 #endif 1349 /* 1350 * Test it. 1351 */ 1352 mutex_lock(&module_mutex); 1353 pTestModByName = find_module(pMyMod->name); 1354 pTestMod = __module_address((uintptr_t)pImage->pvImage + pImage->cbImageBits / 4); 1355 fIsModText = __module_text_address((uintptr_t)pImage->pvImage + pImage->cbImageBits / 2); 1356 mutex_unlock(&module_mutex); 1357 if ( pTestMod == pMyMod 1358 && pTestModByName == pMyMod 1359 && fIsModText) 1360 printk(KERN_ERR "vboxdrv: fake module works for '%s' (%#lx to %#lx)\n", 1361 pMyMod->name, (unsigned long)paSymbols[1].st_value, (unsigned long)paSymbols[2].st_value); 1362 else 1363 printk(KERN_ERR "vboxdrv: failed to find fake module (pTestMod=%p, pTestModByName=%p, pMyMod=%p, fIsModText=%d)\n", 1364 pTestMod, pTestModByName, pMyMod, fIsModText); 1365 } 1366 else 1367 RTMemFree(pMyMod); 1368 } 1369 1370 IPRT_LINUX_RESTORE_EFL_AC(); 1371 #else 1372 pImage->pLnxModHack = NULL; 1373 pImage->pLnxFTraceHack = NULL; 1374 #endif 1375 NOREF(pDevExt); NOREF(pImage); 1376 } 1377 1378 1379 void VBOXCALL supdrvOSLdrNotifyUnloaded(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 1380 { 1381 #ifdef VBOX_WITH_NON_PROD_HACK_FOR_PERF_STACKS /* Not for production use!! Debugging only! */ 1382 struct module *pMyMod = pImage->pLnxModHack; 1383 pImage->pLnxModHack = NULL; 1384 if (pMyMod) 1385 { 1386 /* 1387 * Remove the fake module list entry and free it. 1388 */ 1389 IPRT_LINUX_SAVE_EFL_AC(); 1390 mutex_lock(&module_mutex); 1391 list_del_rcu(&pMyMod->list); 1392 # ifdef CONFIG_MODULES_TREE_LOOKUP 1393 g_pfnModTreeRemove(&pMyMod->mtn_core); 1394 # endif 1395 synchronize_sched(); 1396 mutex_unlock(&module_mutex); 1397 1398 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) 1399 free_percpu(pMyMod->refptr); 1400 # endif 1401 RTMemFree(pMyMod); 1402 IPRT_LINUX_RESTORE_EFL_AC(); 1403 } 1404 1405 #if 0 /* Butt-ugly and ain't working yet. */ 1406 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) && defined(CONFIG_MODULES_TREE_LOOKUP) 1407 # if defined(CONFIG_DYNAMIC_FTRACE) 1408 { 1409 /* 1410 * Undo the ftrace hack. 1411 */ 1412 struct supdrv_ftrace_ops *pOps = pImage->pLnxFTraceHack; 1413 pImage->pLnxFTraceHack = NULL; 1414 if (pOps) 1415 { 1416 IPRT_LINUX_SAVE_EFL_AC(); 1417 int rc = unregister_ftrace_function(&pOps->Core); 1418 if (rc == 0) 1419 ASMAtomicWriteBool(&pOps->fUsed, false); 1420 else 1421 printk(KERN_ERR "vboxdrv: unregister_ftrace_function failed: %d\n", rc); 1422 IPRT_LINUX_RESTORE_EFL_AC(); 1423 } 1424 } 1425 # else 1426 # error "Sorry, without CONFIG_DYNAMIC_FTRACE currently not possible to get proper stack traces" 1427 # endif 1428 # endif 1429 #endif 1430 1431 #else 1432 Assert(pImage->pLnxModHack == NULL); 1433 #endif 964 1434 NOREF(pDevExt); NOREF(pImage); 965 1435 } -
trunk/src/VBox/HostDrivers/Support/os2/SUPDrv-os2.cpp
r57358 r58872 428 428 429 429 430 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)431 {432 NOREF(pDevExt); NOREF(pImage);433 }434 435 436 430 int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits) 437 431 { … … 449 443 450 444 void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 445 { 446 NOREF(pDevExt); NOREF(pImage); 447 } 448 449 450 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename) 451 { 452 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename); 453 } 454 455 456 void VBOXCALL supdrvOSLdrNotifyUnloaded(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 451 457 { 452 458 NOREF(pDevExt); NOREF(pImage); -
trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c
r58698 r58872 1062 1062 1063 1063 1064 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)1065 {1066 NOREF(pDevExt); NOREF(pImage);1067 }1068 1069 1070 1064 int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits) 1071 1065 { … … 1212 1206 1213 1207 1214 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)1215 {1216 NOREF(pDevExt); NOREF(pImage);1217 }1218 1219 1220 1208 int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits) 1221 1209 { … … 1238 1226 1239 1227 #endif /* !VBOX_WITH_NATIVE_SOLARIS_LOADING */ 1228 1229 1230 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename) 1231 { 1232 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename); 1233 } 1234 1235 1236 void VBOXCALL supdrvOSLdrNotifyUnloaded(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage) 1237 { 1238 NOREF(pDevExt); NOREF(pImage); 1239 } 1240 1240 1241 1241 -
trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
r58340 r58872 1829 1829 1830 1830 1831 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage )1832 { 1833 NOREF(pDevExt); NOREF(pImage); 1831 void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename) 1832 { 1833 NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename); 1834 1834 } 1835 1835
Note:
See TracChangeset
for help on using the changeset viewer.