diff options
| -rw-r--r-- | src/qcommon/vm_local.h | 4 | ||||
| -rw-r--r-- | src/qcommon/vm_x86_64.c | 24 | 
2 files changed, 15 insertions, 13 deletions
diff --git a/src/qcommon/vm_local.h b/src/qcommon/vm_local.h index 60709054..c3759d51 100644 --- a/src/qcommon/vm_local.h +++ b/src/qcommon/vm_local.h @@ -23,7 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  #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 diff --git a/src/qcommon/vm_x86_64.c b/src/qcommon/vm_x86_64.c index fcdd4657..ce9680e5 100644 --- a/src/qcommon/vm_x86_64.c +++ b/src/qcommon/vm_x86_64.c @@ -71,15 +71,15 @@ static void VM_Destroy_Compiled(vm_t* self);    |    +- 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  */ @@ -1081,7 +1081,7 @@ int	VM_CallCompiled( vm_t *vm, int *args ) {  	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" \ @@ -1092,10 +1092,10 @@ int	VM_CallCompiled( vm_t *vm, int *args ) {  		"	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 ) {  | 
