[quake3-commits] r1993 - trunk/code/qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon May 16 14:17:01 EDT 2011


Author: thilo
Date: 2011-05-16 14:17:01 -0400 (Mon, 16 May 2011)
New Revision: 1993

Modified:
   trunk/code/qcommon/vm_local.h
   trunk/code/qcommon/vm_x86_64.c
Log:
- Set default opStack size to 256
- Fix integer wraparound. opStack offset in rbx will always be >= 0


Modified: trunk/code/qcommon/vm_local.h
===================================================================
--- trunk/code/qcommon/vm_local.h	2011-05-16 17:55:07 UTC (rev 1992)
+++ trunk/code/qcommon/vm_local.h	2011-05-16 18:17:01 UTC (rev 1993)
@@ -22,7 +22,9 @@
 #include "q_shared.h"
 #include "qcommon.h"
 
-#define	OPSTACK_SIZE	1024
+// don't change, this is hardcoded into x86 VMs, opStack protection relies
+// on this
+#define	OPSTACK_SIZE	256
 #define	OPSTACK_MASK	(OPSTACK_SIZE-1)
 
 // don't change

Modified: trunk/code/qcommon/vm_x86_64.c
===================================================================
--- trunk/code/qcommon/vm_x86_64.c	2011-05-16 17:55:07 UTC (rev 1992)
+++ trunk/code/qcommon/vm_x86_64.c	2011-05-16 18:17:01 UTC (rev 1993)
@@ -70,15 +70,15 @@
   |
   +- r8
 
-  eax	scratch
-  bl	opStack offset
-  ecx	scratch (required for shifts)
-  edx	scratch (required for divisions)
-  rsi	scratch
-  rdi	program frame pointer (programStack)
-  r8    pointer data (vm->dataBase)
-  r9    opStack data base (vm->opStack + OPSTACK_SIZE / 2)
-  r10   start of generated code
+  eax		scratch
+  rbx/bl	opStack offset
+  ecx		scratch (required for shifts)
+  edx		scratch (required for divisions)
+  rsi		scratch
+  rdi		program frame pointer (programStack)
+  r8		pointer data (vm->dataBase)
+  r9		opStack data base (opStack)
+  r10		start of generated code
 */
 
 
@@ -1080,7 +1080,7 @@
 	opStack = PADP(stack, 4);
 
 	__asm__ __volatile__ (
-		"	movq $-0x80,%%rbx	\r\n" \
+		"	movq $0x0,%%rbx		\r\n" \
 		"	movl %5,%%edi		\r\n" \
 		"	movq %4,%%r8		\r\n" \
 		"	movq %3,%%r9		\r\n" \
@@ -1091,10 +1091,10 @@
 		"	movl %%edi, %0		\r\n" \
 		"	movq %%rbx, %1		\r\n" \
 		: "=g" (programStack), "=g" (opStackRet)
-		: "g" (entryPoint), "g" (((intptr_t ) opStack) + OPSTACK_SIZE / 2), "g" (vm->dataBase), "g" (programStack)
+		: "g" (entryPoint), "g" (opStack), "g" (vm->dataBase), "g" (programStack)
 		: "%rsi", "%rdi", "%rax", "%rbx", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r15", "%xmm0"
 	);
-	if(opStackRet != -(OPSTACK_SIZE / 2) + 4 || *opStack != 0xDEADBEEF)
+	if(opStackRet != 4 || *opStack != 0xDEADBEEF)
 		Com_Error(ERR_DROP, "opStack corrupted in compiled code (offset %ld)", opStackRet);
 
 	if ( programStack != stackOnEntry - 48 ) {



More information about the quake3-commits mailing list