Changeset 97905 in vbox
- Timestamp:
- Dec 29, 2022 6:22:23 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r97646 r97905 1866 1866 # define RTR0Init RT_MANGLER(RTR0Init) /* r0drv */ 1867 1867 # define RTR0MemAreKrnlAndUsrDifferent RT_MANGLER(RTR0MemAreKrnlAndUsrDifferent) /* r0drv */ 1868 # define RTR0MemExecDonate RT_MANGLER(RTR0MemExecDonate) /* r0drv */1869 1868 # define RTR0MemKernelIsValidAddr RT_MANGLER(RTR0MemKernelIsValidAddr) /* r0drv */ 1870 1869 # define RTR0MemObjAddress RT_MANGLER(RTR0MemObjAddress) /* r0drv */ -
trunk/include/iprt/mem.h
r96407 r97905 467 467 RTDECL(void) RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_PROTO; 468 468 469 #if defined(IN_RING0) && defined(RT_ARCH_AMD64) && defined(RT_OS_LINUX)470 /**471 * Donate read+write+execute memory to the exec heap.472 *473 * This API is specific to AMD64 and Linux/GNU. A kernel module that desires to474 * use RTMemExecAlloc on AMD64 Linux/GNU will have to donate some statically475 * allocated memory in the module if it wishes for GCC generated code to work.476 * GCC can only generate modules that work in the address range ~2GB to ~0477 * currently.478 *479 * The API only accept one single donation.480 *481 * @returns IPRT status code.482 * @param pvMemory Pointer to the memory block.483 * @param cb The size of the memory block.484 */485 RTR0DECL(int) RTR0MemExecDonate(void *pvMemory, size_t cb) RT_NO_THROW_PROTO;486 #endif /* R0+AMD64+LINUX */487 488 469 /** 489 470 * Allocate page aligned memory with default tag. -
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r96407 r97905 175 175 #define DEVICE_NAME_USR "vboxdrvu" 176 176 177 #if (defined(RT_ARCH_AMD64) && RTLNX_VER_MAX(2,6,23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)178 /**179 * Memory for the executable memory heap (in IPRT).180 */181 # ifdef DEBUG182 # define EXEC_MEMORY_SIZE 10485760 /* 10 MB */183 # else184 # define EXEC_MEMORY_SIZE 8388608 /* 8 MB */185 # endif186 extern uint8_t g_abExecMemory[EXEC_MEMORY_SIZE];187 # ifndef VBOX_WITH_TEXT_MODMEM_HACK188 __asm__(".section execmemory, \"awx\", @progbits\n\t"189 ".align 32\n\t"190 ".globl g_abExecMemory\n"191 "g_abExecMemory:\n\t"192 ".zero " RT_XSTR(EXEC_MEMORY_SIZE) "\n\t"193 ".type g_abExecMemory, @object\n\t"194 ".size g_abExecMemory, " RT_XSTR(EXEC_MEMORY_SIZE) "\n\t"195 ".text\n\t");196 # else197 __asm__(".text\n\t"198 ".align 4096\n\t"199 ".globl g_abExecMemory\n"200 "g_abExecMemory:\n\t"201 ".zero " RT_XSTR(EXEC_MEMORY_SIZE) "\n\t"202 ".type g_abExecMemory, @object\n\t"203 ".size g_abExecMemory, " RT_XSTR(EXEC_MEMORY_SIZE) "\n\t"204 ".text\n\t");205 # endif206 #endif207 208 177 /** The file_operations structure. */ 209 178 static struct file_operations gFileOpsVBoxDrvSys = … … 395 364 if (RT_SUCCESS(rc)) 396 365 { 397 #if (defined(RT_ARCH_AMD64) && RTLNX_VER_MAX(2,6,23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)398 # ifdef VBOX_WITH_TEXT_MODMEM_HACK399 set_memory_x(&g_abExecMemory[0], sizeof(g_abExecMemory) / PAGE_SIZE);400 set_memory_rw(&g_abExecMemory[0], sizeof(g_abExecMemory) / PAGE_SIZE);401 # endif402 rc = RTR0MemExecDonate(&g_abExecMemory[0], sizeof(g_abExecMemory));403 printk(KERN_DEBUG "VBoxDrv: dbg - g_abExecMemory=%p\n", (void *)&g_abExecMemory[0]);404 #endif405 366 Log(("VBoxDrv::ModuleInit\n")); 406 367 … … 408 369 * Initialize the device extension. 409 370 */ 410 if (RT_SUCCESS(rc)) 411 rc = supdrvInitDevExt(&g_DevExt, sizeof(SUPDRVSESSION)); 371 rc = supdrvInitDevExt(&g_DevExt, sizeof(SUPDRVSESSION)); 412 372 if (RT_SUCCESS(rc)) 413 373 { -
trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
r97872 r97905 122 122 #endif 123 123 } 124 125 126 /**127 * Donate read+write+execute memory to the exec heap.128 *129 * This API is specific to AMD64 and Linux/GNU. A kernel module that desires to130 * use RTMemExecAlloc on AMD64 Linux/GNU will have to donate some statically131 * allocated memory in the module if it wishes for GCC generated code to work.132 * GCC can only generate modules that work in the address range ~2GB to ~0133 * currently.134 *135 * The API only accept one single donation.136 *137 * @returns IPRT status code.138 * @retval VERR_NOT_SUPPORTED if the code isn't enabled.139 * @param pvMemory Pointer to the memory block.140 * @param cb The size of the memory block.141 */142 RTR0DECL(int) RTR0MemExecDonate(void *pvMemory, size_t cb)143 {144 #ifdef RTMEMALLOC_EXEC_HEAP145 int rc;146 AssertReturn(g_HeapExec == NIL_RTHEAPSIMPLE, VERR_WRONG_ORDER);147 148 rc = RTSpinlockCreate(&g_HeapExecSpinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "RTR0MemExecDonate");149 if (RT_SUCCESS(rc))150 {151 rc = RTHeapSimpleInit(&g_HeapExec, pvMemory, cb);152 if (RT_FAILURE(rc))153 rtR0MemExecCleanup();154 }155 return rc;156 #else157 RT_NOREF_PV(pvMemory); RT_NOREF_PV(cb);158 return VERR_NOT_SUPPORTED;159 #endif160 }161 RT_EXPORT_SYMBOL(RTR0MemExecDonate);162 163 124 164 125
Note:
See TracChangeset
for help on using the changeset viewer.