On 23/07/2013 01:36, Tim Angus wrote: > On Mon, 22 Jul 2013 14:36:18 -0500 Harley wrote: >> It looks like the culprit is the range check (MASK_REG in the new vm) >> for OP_STORE4. Commenting out MASK_REG under that case seems to make >> UrbanTerror 4.2 load up. I haven't actually tried a real game though. > > This is probably indicative of a bug in Urban Terror. We have hacks in > sound backends to work around UrT's misuse of the API, but in that case > it's not harmful. Removing a range check would mean compromising > security for the sake of UrT. Hmmm.
I've given this some more consideration. Violating the alignment is bad style for performance reason, but not really dangerous or buggy. So I propose keeping the boundary check, but getting rid of the alignment check. Patches are attached. -- A: Because it fouls the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?
diff -r de1eebcbab05 code/qcommon/vm_x86.c --- code/qcommon/vm_x86.c Mon Jul 15 20:43:44 2013 +0200 +++ code/qcommon/vm_x86.c Tue Jul 23 10:41:43 2013 +0200 @@ -783,7 +783,7 @@ return qtrue; case OP_STORE4: - EmitMovEAXStack(vm, (vm->dataMask & ~3)); + EmitMovEAXStack(vm, vm->dataMask); #if idx64 EmitRexString(0x41, "C7 04 01"); // mov dword ptr [r9 + eax], 0x12345678 Emit4(Constant4()); @@ -798,7 +798,7 @@ return qtrue; case OP_STORE2: - EmitMovEAXStack(vm, (vm->dataMask & ~1)); + EmitMovEAXStack(vm, vm->dataMask); #if idx64 Emit1(0x66); // mov word ptr [r9 + eax], 0x1234 EmitRexString(0x41, "C7 04 01"); @@ -1369,7 +1369,7 @@ case OP_STORE4: EmitMovEAXStack(vm, 0); EmitString("8B 54 9F FC"); // mov edx, dword ptr -4[edi + ebx * 4] - MASK_REG("E2", vm->dataMask & ~3); // and edx, 0x12345678 + MASK_REG("E2", vm->dataMask); // and edx, 0x12345678 #if idx64 EmitRexString(0x41, "89 04 11"); // mov dword ptr [r9 + edx], eax #else @@ -1381,7 +1381,7 @@ case OP_STORE2: EmitMovEAXStack(vm, 0); EmitString("8B 54 9F FC"); // mov edx, dword ptr -4[edi + ebx * 4] - MASK_REG("E2", vm->dataMask & ~1); // and edx, 0x12345678 + MASK_REG("E2", vm->dataMask); // and edx, 0x12345678 #if idx64 Emit1(0x66); // mov word ptr [r9 + edx], eax EmitRexString(0x41, "89 04 11");
diff -r de1eebcbab05 code/qcommon/vm_interpreted.c --- code/qcommon/vm_interpreted.c Mon Jul 15 20:43:44 2013 +0200 +++ code/qcommon/vm_interpreted.c Tue Jul 23 10:41:47 2013 +0200 @@ -436,21 +436,21 @@ return 0; } #endif - r0 = opStack[opStackOfs] = *(int *) &image[r0 & dataMask & ~3 ]; + r0 = opStack[opStackOfs] = *(int *) &image[r0 & dataMask ]; goto nextInstruction2; case OP_LOAD2: - r0 = opStack[opStackOfs] = *(unsigned short *)&image[ r0&dataMask&~1 ]; + r0 = opStack[opStackOfs] = *(unsigned short *)&image[ r0&dataMask ]; goto nextInstruction2; case OP_LOAD1: r0 = opStack[opStackOfs] = image[ r0&dataMask ]; goto nextInstruction2; case OP_STORE4: - *(int *)&image[ r1&(dataMask & ~3) ] = r0; + *(int *)&image[ r1&dataMask ] = r0; opStackOfs -= 2; goto nextInstruction; case OP_STORE2: - *(short *)&image[ r1&(dataMask & ~1) ] = r0; + *(short *)&image[ r1&dataMask ] = r0; opStackOfs -= 2; goto nextInstruction; case OP_STORE1: @@ -460,7 +460,7 @@ case OP_ARG: // single byte offset from programStack - *(int *)&image[ (codeImage[programCounter] + programStack)&dataMask&~3 ] = r0; + *(int *)&image[ (codeImage[programCounter] + programStack)&dataMask ] = r0; opStackOfs--; programCounter += 1; goto nextInstruction;
_______________________________________________ ioquake3 mailing list ioquake3@lists.ioquake.org http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org By sending this message I agree to love ioquake3 and libsdl.