Changeset 87728 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Feb 12, 2021 2:24:07 AM (4 years ago)
- Location:
- trunk/src/VBox/HostDrivers
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/Makefile.kmk
r87700 r87728 788 788 ifdef VBOX_WITH_KMOD_WRAPPED_R0_MODS 789 789 # 790 # The wrapper modules.791 # 792 INSTALLS.linux += vbox _vmmr0-src793 vbox _vmmr0-src_INST = bin/src/vbox_vmmr0/794 vbox _vmmr0-src_SOURCES = \790 # Common wrapper module files. 791 # 792 INSTALLS.linux += vboxwrappermod-common-src 793 vboxwrappermod-common-src_INST = bin/src/common/ 794 vboxwrappermod-common-src_SOURCES = \ 795 795 linux/SUPWrapperMod-linux.c=>SUPWrapperMod-linux.c \ 796 linux/Makefile-vbox_vmmr0.gmk=>Makefile \797 796 linux/Makefile-wrapper.gmk=>Makefile-wrapper.gmk \ 798 $(PATH_ROOT)/src/VBox/Installer/linux/Makefile-header.gmk=>Makefile-header.gmk \ 799 $(PATH_ROOT)/src/VBox/Installer/linux/Makefile-footer.gmk=>Makefile-footer.gmk \ 800 $(PATH_OBJ)/VMMR0/VMMR0.r0=>VMMR0.r0 \ 801 $(PATH_OBJ)/VMMR0/VMMR0.debug=>VMMR0.debug \ 802 803 INSTALLS.linux += vbox_vboxddr0-src 804 vbox_vboxddr0-src_INST = bin/src/vbox_vboxddr0/ 805 vbox_vboxddr0-src_SOURCES = \ 806 linux/SUPWrapperMod-linux.c=>SUPWrapperMod-linux.c \ 807 linux/Makefile-vbox_vboxddr0.gmk=>Makefile \ 808 linux/Makefile-wrapper.gmk=>Makefile-wrapper.gmk \ 809 $(PATH_ROOT)/src/VBox/Installer/linux/Makefile-header.gmk=>Makefile-header.gmk \ 810 $(PATH_ROOT)/src/VBox/Installer/linux/Makefile-footer.gmk=>Makefile-footer.gmk \ 811 $(PATH_OBJ)/VBoxDDR0/VBoxDDR0.r0=>VBoxDDR0.r0 \ 812 $(PATH_OBJ)/VBoxDDR0/VBoxDDR0.debug=>VBoxDDR0.debug \ 813 797 $(PATH_ROOT)/src/VBox/Installer/linux/Makefile-header.gmk=>Makefile-header.gmk \ 798 $(PATH_ROOT)/src/VBox/Installer/linux/Makefile-footer.gmk=>Makefile-footer.gmk 814 799 endif 800 815 801 endif # supported host arch 816 802 endif # linux freebsd -
trunk/src/VBox/HostDrivers/Support/linux/Makefile-vbox_vboxddr0.gmk
r87700 r87728 30 30 WRAPPER_NEED_VMMR0 := yes 31 31 32 include $(dir $(lastword $(MAKEFILE_LIST))) /Makefile-wrapper.gmk32 include $(dir $(lastword $(MAKEFILE_LIST)))Makefile-wrapper.gmk 33 33 34 34 -
trunk/src/VBox/HostDrivers/Support/linux/Makefile-vbox_vmmr0.gmk
r87700 r87728 31 31 WRAPPED_MODULE_LINUX_EXPORTS := yes 32 32 33 include $(dir $(lastword $(MAKEFILE_LIST))) /Makefile-wrapper.gmk33 include $(dir $(lastword $(MAKEFILE_LIST)))Makefile-wrapper.gmk 34 34 -
trunk/src/VBox/HostDrivers/Support/linux/Makefile-wrapper.gmk
r87700 r87728 35 35 36 36 # Linux kbuild sets this to our source directory if we are called from there 37 obj ?= $(CURDIR) 38 include $(obj)/Makefile-header.gmk 39 VBOXDRV_DIR := $(abspath $(VBOX_MODULE_SRC_DIR)../vboxdrv/)/ 40 VBOX_VMMR0_DIR := $(abspath $(VBOX_MODULE_SRC_DIR)../vbox_vmmr0/)/ 37 ifndef VBOX_MODULE_SRC_DIR 38 VBOX_MODULE_SRC_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))/ 39 endif 40 VBOXDRV_DIR := $(abspath $(VBOX_MODULE_SRC_DIR)../vboxdrv/)/ 41 VBOX_VMMR0_DIR := $(abspath $(VBOX_MODULE_SRC_DIR)../vbox_vmmr0/)/ 42 include $(VBOXDRV_DIR)Makefile-header.gmk 41 43 42 44 # All of these wrappers depend on … … 47 49 endif 48 50 endif 49 $(warning KBUILD_EXTRA_SYMBOLS=$(KBUILD_EXTRA_SYMBOLS) WRAPPER_NEED_VMMR0=$(WRAPPER_NEED_VMMR0))50 51 51 52 VBOXMOD_OBJS = \ … … 66 67 \ 67 68 WRAPPED_MODULE_NAME=\"$(WRAPPED_MODULE_NAME).r0\" \ 68 WRAPPED_MODULE_SYMBOL_INCLUDE=\"$(WRAPPED_MODULE_NAME)-symbols.h\" \ 69 WRAPPER_MODULE_KMOD_NAME=\"$(VBOXMOD_NAME)\" 69 WRAPPED_MODULE_SYMBOL_INCLUDE=\"$(WRAPPED_MODULE_NAME)-symbols.h\" 70 70 ifdef WRAPPED_MODULE_FLAGS 71 71 VBOXMOD_DEFS += WRAPPED_MODULE_FLAGS="$(WRAPPED_MODULE_FLAGS)" … … 87 87 VBOXMOD_DEFS += WRAPPED_MODULE_TERM=NULL 88 88 endif 89 ifdef WRAPPED_MODULE_LICENSE_PROPRIETARY 90 VBOXMOD_DEFS += WRAPPED_MODULE_LICENSE_PROPRIETARY 91 endif 89 92 90 93 VBOXMOD_CFLAGS = -include $(VBOXDRV_DIR)include/VBox/SUPDrvMangling.h \ … … 93 96 ## @todo cleanup 94 97 95 include $( obj)/Makefile-footer.gmk98 include $(VBOXDRV_DIR)Makefile-footer.gmk 96 99 97 100 -
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r87700 r87728 758 758 * with device extension prepended to the argument list. 759 759 */ 760 SUPR0DECL(int) SUPDrvLinuxLdrRegisterWrappedModule(PCSUPLDRWRAPPEDMODULE pWrappedModInfo, void *pvLnxModule, void **phMod) 761 { 762 AssertPtrReturn(pvLnxModule, VERR_INVALID_POINTER); 763 return supdrvLdrRegisterWrappedModule(&g_DevExt, pWrappedModInfo, pvLnxModule, phMod); 760 SUPR0DECL(int) SUPDrvLinuxLdrRegisterWrappedModule(PCSUPLDRWRAPPEDMODULE pWrappedModInfo, 761 const char *pszLnxModName, void **phMod) 762 { 763 /* Locate the module structure for the caller so can later reference 764 and dereference it to prevent unloading while it is being used. 765 766 Before Linux v5.9 this could be done by address (__module_address() 767 or __module_text_address()), but someone (guess who) apparently on 768 a mission to make life miserable for out-of-tree modules or something, 769 decided it was only used by build-in code and unexported both of them. 770 771 I could find no init callouts getting a struct module pointer either, 772 nor any module name hint anywhere I could see. So, we're left with 773 hardcoding the module name via the compiler and pass it along to 774 SUPDrv so we can call find_module() here. 775 776 Sigh^2. */ 777 AssertPtrReturn(pszLnxModName, VERR_INVALID_POINTER); 778 AssertReturn(*pszLnxModName, VERR_INVALID_NAME); 779 struct module *pLnxModule = find_module(pszLnxModName); 780 if (pLnxModule) 781 return supdrvLdrRegisterWrappedModule(&g_DevExt, pWrappedModInfo, pLnxModule, phMod); 782 printk("vboxdrv: find_module(%s) failed in SUPDrvLinuxLdrRegisterWrappedModule!\n", pszLnxModName); 783 return VERR_MODULE_NOT_FOUND; 764 784 } 765 785 EXPORT_SYMBOL(SUPDrvLinuxLdrRegisterWrappedModule); -
trunk/src/VBox/HostDrivers/Support/linux/SUPWrapperMod-linux.c
r87708 r87728 168 168 static int __init VBoxWrapperModInit(void) 169 169 { 170 /* Locate the module structure before we call SUPDrv to register.171 172 Before Linux v5.9 this could be done by address (__module_address()173 or __module_text_address()), but someone (guess who) apparently on174 a mission to make life miserable for out-of-tree modules or something,175 decided it was only used by build-in code and unexported both of them.176 177 I could find no init callouts getting a struct module pointer either,178 nor any module name hint anywhere I could see. So, we're left with179 hardcoding the module name via the compiler and call find_module.180 181 Sigh^2. */182 170 /*printk("vboxwrap/" WRAPPED_MODULE_NAME ": VBoxWrapperModInit\n");*/ 183 struct module *pLnxMod = find_module(WRAPPER_MODULE_KMOD_NAME); 184 if (pLnxMod) 185 { 186 int rc = SUPDrvLinuxLdrRegisterWrappedModule(&g_WrappedMod, pLnxMod, &g_hWrappedRegistration); 187 if (rc == 0) 188 return 0; 189 printk("vboxwrap/" WRAPPED_MODULE_NAME ": SUPDrvLinuxRegisterWrappedModule failed: %d\n", rc); 190 } 191 else 192 printk("vboxwrap/" WRAPPED_MODULE_NAME ": find_module(" WRAPPER_MODULE_KMOD_NAME ") failed\n"); 171 int rc = SUPDrvLinuxLdrRegisterWrappedModule(&g_WrappedMod, KBUILD_MODNAME, &g_hWrappedRegistration); 172 if (rc == 0) 173 return 0; 174 printk("vboxwrap/" WRAPPED_MODULE_NAME ": SUPDrvLinuxRegisterWrappedModule failed: %d\n", rc); 193 175 return -EINVAL; 194 176 } -
trunk/src/VBox/HostDrivers/linux/Makefile
r85943 r87728 30 30 31 31 obj-m = vboxdrv/ 32 ifneq ($(wildcard $(CURDIR)/vboxnetflt/Makefile),)33 34 endif35 ifneq ($(wildcard $(CURDIR)/vboxnetadp/Makefile),)36 37 endif38 ifneq ($(wildcard $(CURDIR)/vboxpci/Makefile),)39 40 endif32 ifneq ($(wildcard $(CURDIR)/vboxnetflt/Makefile),) 33 obj-m += vboxnetflt/ 34 endif 35 ifneq ($(wildcard $(CURDIR)/vboxnetadp/Makefile),) 36 obj-m += vboxnetadp/ 37 endif 38 ifneq ($(wildcard $(CURDIR)/vboxpci/Makefile),) 39 obj-m += vboxpci/ 40 endif 41 41 42 42 else # ! KERNELRELEASE … … 45 45 46 46 KBUILD_VERBOSE ?= 47 KERN_VER ?= $(shell uname -r)48 47 .PHONY: all install clean check unload load \ 49 48 vboxdrv vboxnetflt vboxnetadp vboxpci \ … … 54 53 55 54 # We want to build on Linux 2.6.18 and later kernels. 56 ifneq ($(filter-out 1.% 2.0.% 2.1.% 2.2.% 2.3.% 2.4.% 2.5.%,$(KERN_VER)),) 55 KERN_VER ?= $(shell uname -r) 56 ifneq ($(filter-out 1.% 2.0.% 2.1.% 2.2.% 2.3.% 2.4.% 2.5.%,$(KERN_VER)),) 57 57 58 58 vboxdrv: … … 115 115 install: install-vboxdrv install-vboxnetflt install-vboxnetadp install-vboxpci 116 116 117 else 117 # Look for wrapper modules, sorting them so vmmr0 is first. 118 VBOX_WRAPPER_DIRS := $(notdir $(wildcard $(CURDIR)/vbox_*)) 119 ifneq ($(VBOX_WRAPPER_DIRS),) 120 VBOX_WRAPPER_DIRS := $(filter vbox_vmmr0,$(VBOX_WRAPPER_DIRS)) $(sort $(filter-out vbox_vmmr0,$(VBOX_WRAPPER_DIRS))) 121 endif 122 define wrapper_template 123 $(wrapper): $(subst $(wrapper),,vbox_vmmr0) 124 $$(MAKE) KBUILD_VERBOSE=$$(KBUILD_VERBOSE) -C $(wrapper)/ 125 126 load-$(wrapper): $(if $(eq $(wrapper),vbox_vmmr0),,load-vbox_vmmr0) 127 @if ! grep -q "^$(wrapper) " /proc/modules; then \ 128 echo "Loading $(wrapper)..."; \ 129 /sbin/insmod $(wrapper)/$(wrapper).ko; \ 130 else \ 131 echo "Skipping loading $(wrapper) module (already loaded)."; \ 132 fi 133 134 unload-$(wrapper): 135 @if grep -q "^$(wrapper) " /proc/modules; then \ 136 echo "Unloading $(wrapper)..."; \ 137 /sbin/rmmod $(wrapper)/$(wrapper).ko; \ 138 fi 139 endef 140 $(foreach wrapper,$(VBOX_WRAPPER_DIRS), $(eval $(wrapper_template))) 141 142 wrappers: $(VBOX_WRAPPER_DIRS) 143 load-wrappers: $(addprefix load-,$(VBOX_WRAPPER_DIRS)) 144 unload-wrappers: 145 @for module in $(filter-out vbox_vmmr0,$(VBOX_WRAPPER_DIRS)) $(filter vbox_vmmr0,$(VBOX_WRAPPER_DIRS)); \ 146 do \ 147 if grep -q "^$${module} " /proc/modules; then \ 148 echo "Unloading $${module}..."; \ 149 if \ 150 done 151 152 buildid: 153 @for module in $(foreach module,vboxdrv vboxnetflt vboxnetadp $(VBOX_WRAPPER_DIRS),$(module)/$(module).ko); \ 154 do \ 155 buildid=`readelf -n $${module} | sed -ne 's/^.*Build ID: *\([[:xdigit:]][[:xdigit:]]\)\(.*\)$$/\1\/\2/p' `; \ 156 if [ -n "$${buildid}" ]; then \ 157 mkdir -p ~/.debug/.build-id/`dirname $${buildid}`; \ 158 ln -sfn -- "$(CURDIR)/$${module}" ~/.debug/.build-id/$${buildid}; \ 159 else \ 160 echo "warning: No build ID for $${module}}"; \ 161 fi \ 162 done 163 164 .PHONY: wrappers load-wrappers unload-wrappers buildid $(VBOX_WRAPPER_DIRS) \ 165 $(addprefix load-,$(VBOX_WRAPPER_DIRS)) $(addprefix unload-,$(VBOX_WRAPPER_DIRS)) 166 167 else # Too old: 168 169 VBOX_WRAPPER_DIRS := 118 170 119 171 vboxdrv: … … 122 174 vboxpci: 123 175 install: 124 125 endif 176 wrappers: 177 load-wrappers: 178 unload-wrappers: 179 buildid-wrappers: 180 181 endif 126 182 127 183 clean-vboxdrv: … … 169 225 170 226 endif # ! KERNELRELEASE 227
Note:
See TracChangeset
for help on using the changeset viewer.