Commit Graph

61 Commits

Author SHA1 Message Date
Zack Middleton 2e904141ff Make more vm_x86 macros use braces so they work with if blah run macro
MASK_REG in EmitMovEDXStack would incorrectly emit asm if 'andit' was 0.
'andit' would never be 0 though so it wasn't causing issues.

Found by Coverity.
2015-07-12 19:11:13 -05:00
/dev/humancontroller 1ce8ba0cdb Fix return values in nested system calls from QVMs
When the engine is compiled with Clang it appears that the return value
is being written to the WRONG address, either due to the vm_ variables being
changed (unexpectedly) elsewhere, or as a result of bad assembly assumptions;
having a stack variable pointing to where to write the return value seems
to do the trick.

This fixes the case where, for a trap_Register()-like call, weird numbers
are being returned when, during the process, an error message is printed
(which in Tremulous results in a QVM call and (nested) system call).
2015-03-23 20:17:07 -05:00
/dev/humancontroller 7b866ae96d guard against out-of-bounds jump table targets 2014-07-31 03:56:29 -05:00
/dev/humancontroller 8cc817b5a3 remove some redundant exit() calls 2013-05-30 15:41:18 -05:00
/dev/humancontroller 830d93aa38 add some noreturn annotations 2013-05-30 15:39:22 -05:00
Zack Middleton c5af65fe5f Fix passing arg9 (qvm only), arg10, and arg11 to vmMain for native libs and non-i386 compiled or interpated qvms. (Currently they aren't use in vmMain in game, cgame, or ui.)
Fix passing args[11] to args[15] from vm to engine on ppc64 and sparc64. Some of the args are used by game bot prediction syscalls. May have been causing bugs. Note: This was fixed for x86_64 in r2163.
2012-12-15 21:55:07 +00:00
Thilo Schulz 027ea8d6d3 Oops, still need this 2012-08-08 09:42:33 +00:00
Thilo Schulz ffac0e6757 Move argument passing from VM to engine to global variables which allows to get rid of lots of OS specific stuff and also fixes errors that happens when compilers add lots of boilerplate to the DoSyscall() function 2012-08-08 09:34:03 +00:00
Thilo Schulz ebec84c55d Fix q3vm execution on x86/x86_64 MacOSX 2011-09-27 01:38:13 +00:00
Zack Middleton f7a20068ee Support vm syscalls with up to 15 args using 64 bit compiled vm (like interprated vms). 2011-09-09 21:54:14 +00:00
Thilo Schulz a248451e66 Fix warning on MacOSX 2011-08-10 21:21:54 +00:00
Thilo Schulz 99e157e066 - Add x86_64 platform for MacOSX
- Fix compilation on MacOSX gcc
2011-08-10 20:48:53 +00:00
Thilo Schulz 23f6fd1633 Bug 5094 - Code cleanup, patch by Zack Middleton and DevHC. Fixes unused-but-set gcc warnings 2011-07-29 12:27:00 +00:00
Thilo Schulz 2f502aceb2 - Fix opStack size for vm_x86.c
- Change opStack alignment to 16 for vm_x86_64.c
2011-06-27 20:22:32 +00:00
Thilo Schulz 19f54e5400 Allow recursive VM entry for VM operations as well 2011-06-23 00:00:27 +00:00
Thilo Schulz 95691ded36 Fix x64 compilation on MSVC 2011-06-21 12:32:43 +00:00
Thilo Schulz 8b7870b81f Fix wrong macro. MSVC win32 build should work again now. 2011-06-16 02:01:13 +00:00
Thilo Schulz 83522282f1 Various fixes to vm_interpreted.c:
- Add opStack protection
- Fix dataMask check for OP_BLOCK_COPY
- Add instruction number check for conditional jumps
- Make errors in VM_PrepareInterpreter nonfatal
2011-06-16 01:11:45 +00:00
Thilo Schulz a447aa82af Fix #if macros for idx64 and id386 2011-06-15 14:10:20 +00:00
Thilo Schulz 03201aff22 - Add MASM assembler files for MSVC x64 projects to support vm_x86 in x64 mode
- Clean up ftol()/snapvector() mess
- Make use of SSE instructions for ftol()/snapvector() if available
- move ftol/snapvector pure assembler to inline assembler, this will add x86_64 and improve support for different calling conventions
- Set FPU control word at program startup to get consistent behaviour on all platforms
2011-06-13 09:56:39 +00:00
Thilo Schulz 71b8fe477d - Use EmitCallDoSyscall() to call the jump violations function which guarantees 16-byte stack alignment
- Add x64 code for MSVC _asm() blocks, not tested yet.
2011-06-06 14:29:45 +00:00
Thilo Schulz c174143dc2 - Add x86_64 support to vm_x86.c
- Fix warning on mingw64
2011-06-01 15:17:18 +00:00
Thilo Schulz 4b1418c4ad - Implement opStack protection: Use register %ebx for scaled indexed addressing mode to access opStack, make opStack push/pop operate on %bl portion only
- Add a third pass to VM compilation for computation of jump address offsets, removing the need to dereference into vm->instructionPointers[] for every call/jump
- Make use of 0F opcode prefix relative jumps
- Call Com_Memcpy for OP_BLOCK_COPY
- Fix several missing range checks for vm->dataBase memory access
2011-05-23 00:46:46 +00:00
Thilo Schulz b8ef880d85 I don't seem to get these constraints right. This should fix it 2011-05-19 03:47:35 +00:00
Thilo Schulz a42239e1e5 Fix VM call for release version, bug introduced by myself in r1994 2011-05-18 16:06:08 +00:00
Thilo Schulz 3f9ec83ce0 - Use edx for CALLs instead of ecx, as the latter does not require any push to stack
- Make Linux AT&T asm code consistent with the MASM codeblock
2011-05-17 12:07:56 +00:00
Thilo Schulz 017bc7e5da - Add vm_x86.c optimization patch by Eugene C.
- Remove ASM syntax specific code (AT&T vs MASM) for OP_CALL and replace with machine code
2011-05-15 13:15:14 +00:00
Thilo Schulz 716caf396e - Reverting accidentally committed vm_x86.c
- Last commit contained some refactoring for vm_x86_64.c
2011-05-14 14:39:48 +00:00
Thilo Schulz 30059eb8ce ensure that ent->classname is always non-null (for entity numbers up to level.num_entities-1, and ENTITYNUM_WORLD and ENTITYNUM_NONE), for player entities and #ENTITYNUM_NONE in particular, patch by DevHC 2011-05-14 14:34:18 +00:00
Thilo Schulz 36314a1622 Add error handling to malloc as well 2011-05-09 15:40:30 +00:00
Thilo Schulz e05c9ad1c2 - Make some string functions in g_cmds.c cleaner, by DevHC
- embed VM_FREEBUFFERS() macro in do-while-loop
2011-02-10 18:56:18 +00:00
Thilo Schulz 544a1c0c1a - Use MAP_FAILED error code for check whether mmap() was successful
- Replace various malloc() with Z_Malloc
- Fix several memory leaks when VM compilation failed and Com_Error is called
- Make failed mmap/VirtualAlloc/malloc calls fatal
2011-02-10 18:45:28 +00:00
Ludwig Nussel c51d99117c use mmap on freebsd too 2010-11-22 07:12:35 +00:00
Tim Angus 5663ff1362 * (bug #4249) Fix buffer overflow in x86 VM 2009-10-19 23:01:00 +00:00
Ryan C. Gordon 33beb9df27 Patched to compile. 2009-09-15 05:30:08 +00:00
Ryan C. Gordon bccd80e523 Added Intel CC compatibility to vm_x86.c's inline asm.
Fixes Bugzilla #3338.
2009-09-15 03:42:29 +00:00
Ludwig Nussel 84fbc2252f align stack before re-entering engine to make sse work (#4051) 2009-05-02 17:15:51 +00:00
Tim Angus 1af6eb9592 * More robust x86 vm entrypoint/callback assembly (Tron) 2008-08-17 23:22:06 +00:00
Tim Angus 9a5d971705 * Fix memory leak in win32 VM code (arQon/dmitry) 2008-08-06 16:09:29 +00:00
Tim Angus 672cfbf16f * Merge unified-sdl to trunk
* Bump Q3_VERSION to 1.35
2007-09-05 18:17:46 +00:00
Tim Angus 0c99c0c1d2 * Fix a few -pedantic warnings 2007-07-25 21:28:15 +00:00
Thilo Schulz a08a539c10 Fix JIT compiler code execution on NX-protected win32 OS 2006-05-15 15:57:02 +00:00
Ludwig Nussel 39f2e449b6 use mmap to allocate memory for generated code to be able to set PROT_EXEC 2006-03-04 11:14:44 +00:00
Ludwig Nussel 4c242115dc - change long to intptr_t for 64bit windows compatability
- change vmMain arguments back to int. 64bit types are apparently not
  needed there. Only the syscall function needs them.
2006-02-18 19:07:23 +00:00
Tim Angus e74947be2c * x86 OS X support 2006-01-15 15:22:13 +00:00
Tim Angus e95f1f2106 * Fix to the gcc4/-O0 x86 JIT compiler bug 2006-01-06 00:04:05 +00:00
Tim Angus 05e8ab9538 * Added STATUS
* Updated TODO
* Moved ChangeLog to root
* Updated ChangeLog
* s/Foobar/Quake III Arena Source Code/
* Biggest patch EVAR. I wonder how many mail boxes this will fill...
2005-10-29 01:53:09 +00:00
Tim Angus ffdc69f138 * Deleted code/unix/vm_x86.c - wtf was that about anyway?
* Removed HAVE_VM_NATIVE
* Removed DLL_ONLY
* Replace HAVE_VM_COMPILED with NO_VM_COMPILED -- this means the JIT compiler
  should be enabled on the OS X and VC builds now
* Remove the remainder of the freetype building stuff
2005-10-29 00:23:10 +00:00
Tim Angus 35cb35ff61 * (Non-trivial) fix to the "opStack corrupted in compiled code" bug 2005-10-13 14:47:00 +00:00
Ludwig Nussel d5fbff3f44 revert int->long change as it breaks on 64bit. Actually only
VM_CallInterpreted hurts as VM_CallCompiled is only used on 32bit. Use
same arg types for consistency nevertheless.
2005-09-26 22:23:46 +00:00